@navios/core 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (93) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/lib/{index-BJjk2X1S.d.mts → index-6S7veHKD.d.mts} +845 -294
  3. package/lib/index-6S7veHKD.d.mts.map +1 -0
  4. package/lib/{index-DZ6NU03y.d.cts → index-r0i2txmg.d.cts} +845 -294
  5. package/lib/index-r0i2txmg.d.cts.map +1 -0
  6. package/lib/index.cjs +4420 -84
  7. package/lib/index.cjs.map +1 -0
  8. package/lib/index.d.cts +2 -2
  9. package/lib/index.d.mts +2 -2
  10. package/lib/index.mjs +4328 -3
  11. package/lib/index.mjs.map +1 -0
  12. package/lib/legacy-compat/index.cjs +41 -126
  13. package/lib/legacy-compat/index.cjs.map +1 -1
  14. package/lib/legacy-compat/index.d.cts +4 -60
  15. package/lib/legacy-compat/index.d.cts.map +1 -1
  16. package/lib/legacy-compat/index.d.mts +4 -60
  17. package/lib/legacy-compat/index.d.mts.map +1 -1
  18. package/lib/legacy-compat/index.mjs +14 -119
  19. package/lib/legacy-compat/index.mjs.map +1 -1
  20. package/lib/navios.factory-BanZIvtR.cjs +4134 -0
  21. package/lib/navios.factory-BanZIvtR.cjs.map +1 -0
  22. package/lib/navios.factory-C75yZCoD.mjs +3831 -0
  23. package/lib/navios.factory-C75yZCoD.mjs.map +1 -0
  24. package/lib/testing/index.cjs +3 -3
  25. package/lib/testing/index.cjs.map +1 -1
  26. package/lib/testing/index.d.cts +1 -1
  27. package/lib/testing/index.d.mts +1 -1
  28. package/lib/testing/index.mjs +2 -2
  29. package/lib/tokens-4J9sredA.mjs +100 -0
  30. package/lib/tokens-4J9sredA.mjs.map +1 -0
  31. package/lib/tokens-BuXXB01L.cjs +196 -0
  32. package/lib/tokens-BuXXB01L.cjs.map +1 -0
  33. package/lib/{use-guards.decorator-Be_QUx6b.mjs → use-guards.decorator-BecoQSmE.mjs} +3 -70
  34. package/lib/use-guards.decorator-BecoQSmE.mjs.map +1 -0
  35. package/lib/{use-guards.decorator-B6tghdxM.cjs → use-guards.decorator-DgD-kxF5.cjs} +7 -158
  36. package/lib/use-guards.decorator-DgD-kxF5.cjs.map +1 -0
  37. package/package.json +4 -4
  38. package/src/__tests__/attribute.factory.spec.mts +300 -0
  39. package/src/__tests__/console-logger.service.spec.mts +312 -0
  40. package/src/__tests__/guard-runner.service.spec.mts +399 -0
  41. package/src/__tests__/logger.service.spec.mts +147 -0
  42. package/src/__tests__/responders.spec.mts +6 -5
  43. package/src/factories/adapter.factory.mts +20 -0
  44. package/src/factories/endpoint-adapter.factory.mts +1 -1
  45. package/src/factories/http-adapter.factory.mts +1 -1
  46. package/src/factories/index.mts +1 -0
  47. package/src/factories/multipart-adapter.factory.mts +1 -1
  48. package/src/factories/reply.factory.mts +1 -1
  49. package/src/factories/request.factory.mts +1 -1
  50. package/src/factories/stream-adapter.factory.mts +1 -1
  51. package/src/factories/xml-stream-adapter.factory.mts +1 -1
  52. package/src/index.mts +1 -0
  53. package/src/interfaces/abstract-adapter.interface.mts +32 -0
  54. package/src/interfaces/abstract-http-adapter.interface.mts +27 -20
  55. package/src/interfaces/abstract-http-handler-adapter.interface.mts +86 -2
  56. package/src/interfaces/adapter-environment.interface.mts +74 -0
  57. package/src/interfaces/index.mts +2 -0
  58. package/src/interfaces/plugin.interface.mts +50 -16
  59. package/src/legacy-compat/attribute.factory.mts +2 -2
  60. package/src/legacy-compat/decorators/controller.decorator.mts +1 -1
  61. package/src/legacy-compat/decorators/endpoint.decorator.mts +1 -1
  62. package/src/legacy-compat/decorators/header.decorator.mts +2 -1
  63. package/src/legacy-compat/decorators/http-code.decorator.mts +2 -1
  64. package/src/legacy-compat/decorators/index.mts +2 -2
  65. package/src/legacy-compat/decorators/module.decorator.mts +1 -1
  66. package/src/legacy-compat/decorators/multipart.decorator.mts +1 -1
  67. package/src/legacy-compat/decorators/stream.decorator.mts +1 -1
  68. package/src/legacy-compat/decorators/use-guards.decorator.mts +1 -1
  69. package/src/legacy-compat/index.mts +10 -5
  70. package/src/logger/console-logger.service.mts +97 -7
  71. package/src/metadata/module.metadata.mts +43 -0
  72. package/src/navios.application.mts +172 -60
  73. package/src/navios.environment.mts +22 -12
  74. package/src/navios.factory.mts +31 -10
  75. package/src/services/abstract-handler-adapter.service.mts +366 -0
  76. package/src/services/index.mts +1 -0
  77. package/src/services/module-loader.service.mts +1 -0
  78. package/src/tokens/adapter.token.mts +6 -0
  79. package/src/tokens/http-adapter.token.mts +1 -1
  80. package/src/tokens/index.mts +1 -0
  81. package/src/utils/adapter-supports.util.mts +47 -0
  82. package/src/utils/index.mts +1 -0
  83. package/lib/index-BJjk2X1S.d.mts.map +0 -1
  84. package/lib/index-DZ6NU03y.d.cts.map +0 -1
  85. package/lib/src-C46ePe3d.cjs +0 -8022
  86. package/lib/src-C46ePe3d.cjs.map +0 -1
  87. package/lib/src-K2k0riYJ.mjs +0 -7587
  88. package/lib/src-K2k0riYJ.mjs.map +0 -1
  89. package/lib/use-guards.decorator-B6tghdxM.cjs.map +0 -1
  90. package/lib/use-guards.decorator-Be_QUx6b.mjs.map +0 -1
  91. package/src/legacy-compat/context-compat.mts +0 -95
  92. package/src/legacy-compat/decorators/factory.decorator.mts +0 -37
  93. package/src/legacy-compat/decorators/injectable.decorator.mts +0 -41
@@ -0,0 +1,3831 @@
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
+ * @deprecated Use InstanceResolverService instead
1948
+ */ const ControllerResolverService = _InstanceResolverService;
1949
+
1950
+ //#endregion
1951
+ //#region src/services/abstract-handler-adapter.service.mts
1952
+ const defaultOptions = {
1953
+ adapter: [],
1954
+ validateResponses: true,
1955
+ enableRequestId: false
1956
+ };
1957
+ /**
1958
+ * Abstract base class for HTTP handler adapter services.
1959
+ *
1960
+ * Provides shared logic for:
1961
+ * - Controller resolution (singleton vs request-scoped)
1962
+ * - Argument formatting (sync/async detection)
1963
+ * - Handler generation with static/dynamic branching
1964
+ * - Standardized error handling
1965
+ *
1966
+ * Adapters implement abstract methods for framework-specific behavior:
1967
+ * - Request parsing (query, body, URL params)
1968
+ * - Response creation
1969
+ * - Schema provision
1970
+ *
1971
+ * Supports all adapter types:
1972
+ * - Endpoint adapters: JSON request/response with validation
1973
+ * - Stream adapters: Streaming responses with extra context
1974
+ * - Multipart adapters: Form data parsing (extends endpoint)
1975
+ *
1976
+ * @typeParam TRequest - Framework request type (BunRequest, FastifyRequest)
1977
+ * @typeParam TReply - Framework reply type (void for Bun, FastifyReply)
1978
+ * @typeParam TConfig - Endpoint configuration type
1979
+ */ var AbstractHandlerAdapterService = class {
1980
+ instanceResolver = inject(_InstanceResolverService);
1981
+ options = optional(NaviosOptionsToken) ?? defaultOptions;
1982
+ /**
1983
+ * Prepares argument getters for parsing request data.
1984
+ *
1985
+ * Public alias for createArgumentGetters to satisfy interface contracts.
1986
+ * Subclasses should override createArgumentGetters instead.
1987
+ *
1988
+ * @param handlerMetadata - Handler metadata with schemas and configuration
1989
+ * @returns Array of getter functions
1990
+ */ prepareArguments(handlerMetadata) {
1991
+ return this.createArgumentGetters(handlerMetadata);
1992
+ }
1993
+ /**
1994
+ * Checks if the handler has any validation schemas defined.
1995
+ *
1996
+ * Override in subclasses to add additional schema checks
1997
+ * (e.g., response schema validation for endpoint adapters).
1998
+ *
1999
+ * @param handlerMetadata - Handler metadata with configuration
2000
+ * @returns true if handler has schemas
2001
+ */ hasSchema(handlerMetadata) {
2002
+ const config = handlerMetadata.config;
2003
+ return !!config.requestSchema || !!config.querySchema;
2004
+ }
2005
+ /**
2006
+ * Provides schema information for the framework's validation system.
2007
+ *
2008
+ * Override in subclasses for frameworks that support schema registration
2009
+ * (e.g., Fastify). Default returns empty object (suitable for Bun).
2010
+ *
2011
+ * @param handlerMetadata - Handler metadata with configuration
2012
+ * @returns Schema object for framework registration
2013
+ */ provideSchema(_handlerMetadata) {
2014
+ return {};
2015
+ }
2016
+ /**
2017
+ * Creates a request handler function for the endpoint.
2018
+ *
2019
+ * This method orchestrates the entire handler creation:
2020
+ * 1. Prepares argument getters for request parsing
2021
+ * 2. Builds optimized formatArguments function (sync/async)
2022
+ * 3. Resolves the controller (singleton vs request-scoped)
2023
+ * 4. Creates appropriate handler (static or dynamic)
2024
+ *
2025
+ * @param controller - Controller class containing the handler method
2026
+ * @param handlerMetadata - Handler metadata with configuration
2027
+ * @returns Handler result (static or dynamic)
2028
+ */ async provideHandler(controller, handlerMetadata) {
2029
+ const getters = this.createArgumentGetters(handlerMetadata);
2030
+ const formatArguments = this.buildFormatArguments(getters);
2031
+ const hasArguments = getters.length > 0;
2032
+ const context = {
2033
+ methodName: handlerMetadata.classMethod,
2034
+ statusCode: handlerMetadata.successStatusCode,
2035
+ headers: handlerMetadata.headers,
2036
+ handlerMetadata,
2037
+ hasArguments
2038
+ };
2039
+ const resolution = await this.instanceResolver.resolve(controller);
2040
+ if (resolution.cached) {
2041
+ const cachedController = resolution.instance;
2042
+ const boundMethod = cachedController[context.methodName].bind(cachedController);
2043
+ return this.createStaticHandler(boundMethod, formatArguments, context);
2044
+ }
2045
+ return this.createDynamicHandler(resolution, formatArguments, context);
2046
+ }
2047
+ /**
2048
+ * Builds a formatArguments function from argument getters.
2049
+ *
2050
+ * Automatically detects sync vs async getters and optimizes accordingly:
2051
+ * - If all getters are sync: returns sync function (no Promise overhead)
2052
+ * - If any getter is async: returns async function with Promise.all
2053
+ * - If no getters: returns frozen empty object (zero allocation)
2054
+ *
2055
+ * This method is public to allow composition-based adapters (like XML adapter)
2056
+ * to reuse the optimized formatArguments logic without inheritance.
2057
+ *
2058
+ * @param getters - Array of argument getter functions
2059
+ * @returns Function to format arguments from request
2060
+ */ buildFormatArguments(getters) {
2061
+ if (getters.length === 0) {
2062
+ const emptyArgs = Object.freeze({});
2063
+ return () => emptyArgs;
2064
+ }
2065
+ if (getters.some((g) => g.constructor.name === "AsyncFunction")) return async (request) => {
2066
+ const argument = {};
2067
+ const promises = [];
2068
+ for (const getter of getters) {
2069
+ const res = getter(argument, request);
2070
+ if (res instanceof Promise) promises.push(res);
2071
+ }
2072
+ await Promise.all(promises);
2073
+ return argument;
2074
+ };
2075
+ return (request) => {
2076
+ const argument = {};
2077
+ for (const getter of getters) getter(argument, request);
2078
+ return argument;
2079
+ };
2080
+ }
2081
+ /**
2082
+ * Checks if the URL pattern contains URL parameters.
2083
+ *
2084
+ * @param config - Endpoint configuration
2085
+ * @returns true if URL contains '$' parameter markers
2086
+ */ hasUrlParams(config) {
2087
+ return config.url.includes("$");
2088
+ }
2089
+ /**
2090
+ * Wraps handler execution with standardized error handling.
2091
+ *
2092
+ * Re-throws HttpExceptions as-is for framework error handlers.
2093
+ * Other errors are re-thrown for global error handling.
2094
+ *
2095
+ * @param fn - Handler function to wrap
2096
+ * @returns Wrapped function with error handling
2097
+ */ wrapWithErrorHandling(fn) {
2098
+ return async (...args) => {
2099
+ try {
2100
+ return await fn(...args);
2101
+ } catch (error) {
2102
+ if (error && typeof error === "object" && "statusCode" in error) throw error;
2103
+ throw error;
2104
+ }
2105
+ };
2106
+ }
2107
+ };
2108
+
2109
+ //#endregion
2110
+ //#region src/services/guard-runner.service.mts
2111
+ function applyDecs2203RFactory$3() {
2112
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2113
+ return function addInitializer(initializer) {
2114
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
2115
+ assertCallable(initializer, "An initializer");
2116
+ initializers.push(initializer);
2117
+ };
2118
+ }
2119
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
2120
+ var kindStr;
2121
+ switch (kind) {
2122
+ case 1:
2123
+ kindStr = "accessor";
2124
+ break;
2125
+ case 2:
2126
+ kindStr = "method";
2127
+ break;
2128
+ case 3:
2129
+ kindStr = "getter";
2130
+ break;
2131
+ case 4:
2132
+ kindStr = "setter";
2133
+ break;
2134
+ default: kindStr = "field";
2135
+ }
2136
+ var ctx = {
2137
+ kind: kindStr,
2138
+ name: isPrivate ? "#" + name : name,
2139
+ static: isStatic,
2140
+ private: isPrivate,
2141
+ metadata
2142
+ };
2143
+ var decoratorFinishedRef = { v: false };
2144
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
2145
+ var get, set;
2146
+ if (kind === 0) if (isPrivate) {
2147
+ get = desc.get;
2148
+ set = desc.set;
2149
+ } else {
2150
+ get = function() {
2151
+ return this[name];
2152
+ };
2153
+ set = function(v) {
2154
+ this[name] = v;
2155
+ };
2156
+ }
2157
+ else if (kind === 2) get = function() {
2158
+ return desc.value;
2159
+ };
2160
+ else {
2161
+ if (kind === 1 || kind === 3) get = function() {
2162
+ return desc.get.call(this);
2163
+ };
2164
+ if (kind === 1 || kind === 4) set = function(v) {
2165
+ desc.set.call(this, v);
2166
+ };
2167
+ }
2168
+ ctx.access = get && set ? {
2169
+ get,
2170
+ set
2171
+ } : get ? { get } : { set };
2172
+ try {
2173
+ return dec(value, ctx);
2174
+ } finally {
2175
+ decoratorFinishedRef.v = true;
2176
+ }
2177
+ }
2178
+ function assertNotFinished(decoratorFinishedRef, fnName) {
2179
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
2180
+ }
2181
+ function assertCallable(fn, hint) {
2182
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
2183
+ }
2184
+ function assertValidReturnValue(kind, value) {
2185
+ var type = typeof value;
2186
+ if (kind === 1) {
2187
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2188
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
2189
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
2190
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
2191
+ } else if (type !== "function") {
2192
+ var hint;
2193
+ if (kind === 0) hint = "field";
2194
+ else if (kind === 10) hint = "class";
2195
+ else hint = "method";
2196
+ throw new TypeError(hint + " decorators must return a function or void 0");
2197
+ }
2198
+ }
2199
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
2200
+ var decs = decInfo[0];
2201
+ var desc, init, value;
2202
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
2203
+ get: decInfo[3],
2204
+ set: decInfo[4]
2205
+ };
2206
+ else if (kind === 3) desc = { get: decInfo[3] };
2207
+ else if (kind === 4) desc = { set: decInfo[3] };
2208
+ else desc = { value: decInfo[3] };
2209
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
2210
+ if (kind === 1) value = {
2211
+ get: desc.get,
2212
+ set: desc.set
2213
+ };
2214
+ else if (kind === 2) value = desc.value;
2215
+ else if (kind === 3) value = desc.get;
2216
+ else if (kind === 4) value = desc.set;
2217
+ var newValue, get, set;
2218
+ if (typeof decs === "function") {
2219
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2220
+ if (newValue !== void 0) {
2221
+ assertValidReturnValue(kind, newValue);
2222
+ if (kind === 0) init = newValue;
2223
+ else if (kind === 1) {
2224
+ init = newValue.init;
2225
+ get = newValue.get || value.get;
2226
+ set = newValue.set || value.set;
2227
+ value = {
2228
+ get,
2229
+ set
2230
+ };
2231
+ } else value = newValue;
2232
+ }
2233
+ } else for (var i = decs.length - 1; i >= 0; i--) {
2234
+ var dec = decs[i];
2235
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2236
+ if (newValue !== void 0) {
2237
+ assertValidReturnValue(kind, newValue);
2238
+ var newInit;
2239
+ if (kind === 0) newInit = newValue;
2240
+ else if (kind === 1) {
2241
+ newInit = newValue.init;
2242
+ get = newValue.get || value.get;
2243
+ set = newValue.set || value.set;
2244
+ value = {
2245
+ get,
2246
+ set
2247
+ };
2248
+ } else value = newValue;
2249
+ if (newInit !== void 0) if (init === void 0) init = newInit;
2250
+ else if (typeof init === "function") init = [init, newInit];
2251
+ else init.push(newInit);
2252
+ }
2253
+ }
2254
+ if (kind === 0 || kind === 1) {
2255
+ if (init === void 0) init = function(instance, init$1) {
2256
+ return init$1;
2257
+ };
2258
+ else if (typeof init !== "function") {
2259
+ var ownInitializers = init;
2260
+ init = function(instance, init$1) {
2261
+ var value$1 = init$1;
2262
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
2263
+ return value$1;
2264
+ };
2265
+ } else {
2266
+ var originalInitializer = init;
2267
+ init = function(instance, init$1) {
2268
+ return originalInitializer.call(instance, init$1);
2269
+ };
2270
+ }
2271
+ ret.push(init);
2272
+ }
2273
+ if (kind !== 0) {
2274
+ if (kind === 1) {
2275
+ desc.get = value.get;
2276
+ desc.set = value.set;
2277
+ } else if (kind === 2) desc.value = value;
2278
+ else if (kind === 3) desc.get = value;
2279
+ else if (kind === 4) desc.set = value;
2280
+ if (isPrivate) if (kind === 1) {
2281
+ ret.push(function(instance, args) {
2282
+ return value.get.call(instance, args);
2283
+ });
2284
+ ret.push(function(instance, args) {
2285
+ return value.set.call(instance, args);
2286
+ });
2287
+ } else if (kind === 2) ret.push(value);
2288
+ else ret.push(function(instance, args) {
2289
+ return value.call(instance, args);
2290
+ });
2291
+ else Object.defineProperty(base, name, desc);
2292
+ }
2293
+ }
2294
+ function applyMemberDecs(Class, decInfos, metadata) {
2295
+ var ret = [];
2296
+ var protoInitializers;
2297
+ var staticInitializers;
2298
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
2299
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
2300
+ for (var i = 0; i < decInfos.length; i++) {
2301
+ var decInfo = decInfos[i];
2302
+ if (!Array.isArray(decInfo)) continue;
2303
+ var kind = decInfo[1];
2304
+ var name = decInfo[2];
2305
+ var isPrivate = decInfo.length > 3;
2306
+ var isStatic = kind >= 5;
2307
+ var base;
2308
+ var initializers;
2309
+ if (isStatic) {
2310
+ base = Class;
2311
+ kind = kind - 5;
2312
+ staticInitializers = staticInitializers || [];
2313
+ initializers = staticInitializers;
2314
+ } else {
2315
+ base = Class.prototype;
2316
+ protoInitializers = protoInitializers || [];
2317
+ initializers = protoInitializers;
2318
+ }
2319
+ if (kind !== 0 && !isPrivate) {
2320
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
2321
+ var existingKind = existingNonFields.get(name) || 0;
2322
+ 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);
2323
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
2324
+ else existingNonFields.set(name, true);
2325
+ }
2326
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
2327
+ }
2328
+ pushInitializers(ret, protoInitializers);
2329
+ pushInitializers(ret, staticInitializers);
2330
+ return ret;
2331
+ }
2332
+ function pushInitializers(ret, initializers) {
2333
+ if (initializers) ret.push(function(instance) {
2334
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
2335
+ return instance;
2336
+ });
2337
+ }
2338
+ function applyClassDecs(targetClass, classDecs, metadata) {
2339
+ if (classDecs.length > 0) {
2340
+ var initializers = [];
2341
+ var newClass = targetClass;
2342
+ var name = targetClass.name;
2343
+ for (var i = classDecs.length - 1; i >= 0; i--) {
2344
+ var decoratorFinishedRef = { v: false };
2345
+ try {
2346
+ var nextNewClass = classDecs[i](newClass, {
2347
+ kind: "class",
2348
+ name,
2349
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
2350
+ metadata
2351
+ });
2352
+ } finally {
2353
+ decoratorFinishedRef.v = true;
2354
+ }
2355
+ if (nextNewClass !== void 0) {
2356
+ assertValidReturnValue(10, nextNewClass);
2357
+ newClass = nextNewClass;
2358
+ }
2359
+ }
2360
+ return [defineMetadata(newClass, metadata), function() {
2361
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
2362
+ }];
2363
+ }
2364
+ }
2365
+ function defineMetadata(Class, metadata) {
2366
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
2367
+ configurable: true,
2368
+ enumerable: true,
2369
+ value: metadata
2370
+ });
2371
+ }
2372
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
2373
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
2374
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
2375
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
2376
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
2377
+ return {
2378
+ e,
2379
+ get c() {
2380
+ return applyClassDecs(targetClass, classDecs, metadata);
2381
+ }
2382
+ };
2383
+ };
2384
+ }
2385
+ function _apply_decs_2203_r$3(targetClass, memberDecs, classDecs, parentClass) {
2386
+ return (_apply_decs_2203_r$3 = applyDecs2203RFactory$3())(targetClass, memberDecs, classDecs, parentClass);
2387
+ }
2388
+ var _dec$3, _initClass$3;
2389
+ let _GuardRunnerService;
2390
+ _dec$3 = Injectable();
2391
+ var GuardRunnerService = class {
2392
+ static {
2393
+ ({c: [_GuardRunnerService, _initClass$3]} = _apply_decs_2203_r$3(this, [], [_dec$3]));
2394
+ }
2395
+ errorProducer = inject(_ErrorResponseProducerService);
2396
+ logger = inject(Logger, { context: _GuardRunnerService.name });
2397
+ /**
2398
+ * Runs guards that need to be resolved from a scoped container.
2399
+ * Use this when guards have request-scoped dependencies.
2400
+ */ async runGuards(allGuards, executionContext, context) {
2401
+ const guardsArray = Array.from(allGuards).reverse();
2402
+ const guardInstances = await Promise.all(guardsArray.map(async (guard) => {
2403
+ const guardInstance = await context.get(guard);
2404
+ if (!guardInstance.canActivate) throw new Error(`[Navios] Guard ${guard.name} does not implement canActivate()`);
2405
+ return guardInstance;
2406
+ }));
2407
+ return this.executeGuards(guardInstances, executionContext);
2408
+ }
2409
+ /**
2410
+ * Runs pre-resolved guard instances.
2411
+ * Use this when all guards are singletons and have been pre-resolved at startup.
2412
+ */ async runGuardsStatic(guardInstances, executionContext) {
2413
+ return this.executeGuards(guardInstances, executionContext);
2414
+ }
2415
+ /**
2416
+ * Shared guard execution logic.
2417
+ * Iterates through guard instances and calls canActivate on each.
2418
+ */ async executeGuards(guardInstances, executionContext) {
2419
+ let canActivate = true;
2420
+ for (const guardInstance of guardInstances) try {
2421
+ canActivate = await guardInstance.canActivate(executionContext);
2422
+ if (!canActivate) break;
2423
+ } catch (error) {
2424
+ if (error instanceof HttpException) {
2425
+ executionContext.getReply().status(error.statusCode).send(error.response);
2426
+ return false;
2427
+ } else {
2428
+ this.logger.error("Error running guard", error);
2429
+ const errorResponse = this.errorProducer.respond(FrameworkError.InternalServerError, error);
2430
+ executionContext.getReply().status(errorResponse.statusCode).send(errorResponse.payload);
2431
+ return false;
2432
+ }
2433
+ }
2434
+ if (!canActivate) {
2435
+ const errorResponse = this.errorProducer.respond(FrameworkError.Forbidden, null);
2436
+ executionContext.getReply().status(errorResponse.statusCode).send(errorResponse.payload);
2437
+ return false;
2438
+ }
2439
+ return canActivate;
2440
+ }
2441
+ makeContext(moduleMetadata, controllerMetadata, endpoint) {
2442
+ const guards = /* @__PURE__ */ new Set();
2443
+ const endpointGuards = endpoint.guards;
2444
+ const controllerGuards = controllerMetadata.guards;
2445
+ const moduleGuards = moduleMetadata.guards;
2446
+ if (endpointGuards.size > 0) for (const guard of endpointGuards) guards.add(guard);
2447
+ if (controllerGuards.size > 0) for (const guard of controllerGuards) guards.add(guard);
2448
+ if (moduleGuards.size > 0) for (const guard of moduleGuards) guards.add(guard);
2449
+ return guards;
2450
+ }
2451
+ static {
2452
+ _initClass$3();
2453
+ }
2454
+ };
2455
+
2456
+ //#endregion
2457
+ //#region src/services/module-loader.service.mts
2458
+ function applyDecs2203RFactory$2() {
2459
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2460
+ return function addInitializer(initializer) {
2461
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
2462
+ assertCallable(initializer, "An initializer");
2463
+ initializers.push(initializer);
2464
+ };
2465
+ }
2466
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
2467
+ var kindStr;
2468
+ switch (kind) {
2469
+ case 1:
2470
+ kindStr = "accessor";
2471
+ break;
2472
+ case 2:
2473
+ kindStr = "method";
2474
+ break;
2475
+ case 3:
2476
+ kindStr = "getter";
2477
+ break;
2478
+ case 4:
2479
+ kindStr = "setter";
2480
+ break;
2481
+ default: kindStr = "field";
2482
+ }
2483
+ var ctx = {
2484
+ kind: kindStr,
2485
+ name: isPrivate ? "#" + name : name,
2486
+ static: isStatic,
2487
+ private: isPrivate,
2488
+ metadata
2489
+ };
2490
+ var decoratorFinishedRef = { v: false };
2491
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
2492
+ var get, set;
2493
+ if (kind === 0) if (isPrivate) {
2494
+ get = desc.get;
2495
+ set = desc.set;
2496
+ } else {
2497
+ get = function() {
2498
+ return this[name];
2499
+ };
2500
+ set = function(v) {
2501
+ this[name] = v;
2502
+ };
2503
+ }
2504
+ else if (kind === 2) get = function() {
2505
+ return desc.value;
2506
+ };
2507
+ else {
2508
+ if (kind === 1 || kind === 3) get = function() {
2509
+ return desc.get.call(this);
2510
+ };
2511
+ if (kind === 1 || kind === 4) set = function(v) {
2512
+ desc.set.call(this, v);
2513
+ };
2514
+ }
2515
+ ctx.access = get && set ? {
2516
+ get,
2517
+ set
2518
+ } : get ? { get } : { set };
2519
+ try {
2520
+ return dec(value, ctx);
2521
+ } finally {
2522
+ decoratorFinishedRef.v = true;
2523
+ }
2524
+ }
2525
+ function assertNotFinished(decoratorFinishedRef, fnName) {
2526
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
2527
+ }
2528
+ function assertCallable(fn, hint) {
2529
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
2530
+ }
2531
+ function assertValidReturnValue(kind, value) {
2532
+ var type = typeof value;
2533
+ if (kind === 1) {
2534
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2535
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
2536
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
2537
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
2538
+ } else if (type !== "function") {
2539
+ var hint;
2540
+ if (kind === 0) hint = "field";
2541
+ else if (kind === 10) hint = "class";
2542
+ else hint = "method";
2543
+ throw new TypeError(hint + " decorators must return a function or void 0");
2544
+ }
2545
+ }
2546
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
2547
+ var decs = decInfo[0];
2548
+ var desc, init, value;
2549
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
2550
+ get: decInfo[3],
2551
+ set: decInfo[4]
2552
+ };
2553
+ else if (kind === 3) desc = { get: decInfo[3] };
2554
+ else if (kind === 4) desc = { set: decInfo[3] };
2555
+ else desc = { value: decInfo[3] };
2556
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
2557
+ if (kind === 1) value = {
2558
+ get: desc.get,
2559
+ set: desc.set
2560
+ };
2561
+ else if (kind === 2) value = desc.value;
2562
+ else if (kind === 3) value = desc.get;
2563
+ else if (kind === 4) value = desc.set;
2564
+ var newValue, get, set;
2565
+ if (typeof decs === "function") {
2566
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2567
+ if (newValue !== void 0) {
2568
+ assertValidReturnValue(kind, newValue);
2569
+ if (kind === 0) init = newValue;
2570
+ else if (kind === 1) {
2571
+ init = newValue.init;
2572
+ get = newValue.get || value.get;
2573
+ set = newValue.set || value.set;
2574
+ value = {
2575
+ get,
2576
+ set
2577
+ };
2578
+ } else value = newValue;
2579
+ }
2580
+ } else for (var i = decs.length - 1; i >= 0; i--) {
2581
+ var dec = decs[i];
2582
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2583
+ if (newValue !== void 0) {
2584
+ assertValidReturnValue(kind, newValue);
2585
+ var newInit;
2586
+ if (kind === 0) newInit = newValue;
2587
+ else if (kind === 1) {
2588
+ newInit = newValue.init;
2589
+ get = newValue.get || value.get;
2590
+ set = newValue.set || value.set;
2591
+ value = {
2592
+ get,
2593
+ set
2594
+ };
2595
+ } else value = newValue;
2596
+ if (newInit !== void 0) if (init === void 0) init = newInit;
2597
+ else if (typeof init === "function") init = [init, newInit];
2598
+ else init.push(newInit);
2599
+ }
2600
+ }
2601
+ if (kind === 0 || kind === 1) {
2602
+ if (init === void 0) init = function(instance, init$1) {
2603
+ return init$1;
2604
+ };
2605
+ else if (typeof init !== "function") {
2606
+ var ownInitializers = init;
2607
+ init = function(instance, init$1) {
2608
+ var value$1 = init$1;
2609
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
2610
+ return value$1;
2611
+ };
2612
+ } else {
2613
+ var originalInitializer = init;
2614
+ init = function(instance, init$1) {
2615
+ return originalInitializer.call(instance, init$1);
2616
+ };
2617
+ }
2618
+ ret.push(init);
2619
+ }
2620
+ if (kind !== 0) {
2621
+ if (kind === 1) {
2622
+ desc.get = value.get;
2623
+ desc.set = value.set;
2624
+ } else if (kind === 2) desc.value = value;
2625
+ else if (kind === 3) desc.get = value;
2626
+ else if (kind === 4) desc.set = value;
2627
+ if (isPrivate) if (kind === 1) {
2628
+ ret.push(function(instance, args) {
2629
+ return value.get.call(instance, args);
2630
+ });
2631
+ ret.push(function(instance, args) {
2632
+ return value.set.call(instance, args);
2633
+ });
2634
+ } else if (kind === 2) ret.push(value);
2635
+ else ret.push(function(instance, args) {
2636
+ return value.call(instance, args);
2637
+ });
2638
+ else Object.defineProperty(base, name, desc);
2639
+ }
2640
+ }
2641
+ function applyMemberDecs(Class, decInfos, metadata) {
2642
+ var ret = [];
2643
+ var protoInitializers;
2644
+ var staticInitializers;
2645
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
2646
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
2647
+ for (var i = 0; i < decInfos.length; i++) {
2648
+ var decInfo = decInfos[i];
2649
+ if (!Array.isArray(decInfo)) continue;
2650
+ var kind = decInfo[1];
2651
+ var name = decInfo[2];
2652
+ var isPrivate = decInfo.length > 3;
2653
+ var isStatic = kind >= 5;
2654
+ var base;
2655
+ var initializers;
2656
+ if (isStatic) {
2657
+ base = Class;
2658
+ kind = kind - 5;
2659
+ staticInitializers = staticInitializers || [];
2660
+ initializers = staticInitializers;
2661
+ } else {
2662
+ base = Class.prototype;
2663
+ protoInitializers = protoInitializers || [];
2664
+ initializers = protoInitializers;
2665
+ }
2666
+ if (kind !== 0 && !isPrivate) {
2667
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
2668
+ var existingKind = existingNonFields.get(name) || 0;
2669
+ 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);
2670
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
2671
+ else existingNonFields.set(name, true);
2672
+ }
2673
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
2674
+ }
2675
+ pushInitializers(ret, protoInitializers);
2676
+ pushInitializers(ret, staticInitializers);
2677
+ return ret;
2678
+ }
2679
+ function pushInitializers(ret, initializers) {
2680
+ if (initializers) ret.push(function(instance) {
2681
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
2682
+ return instance;
2683
+ });
2684
+ }
2685
+ function applyClassDecs(targetClass, classDecs, metadata) {
2686
+ if (classDecs.length > 0) {
2687
+ var initializers = [];
2688
+ var newClass = targetClass;
2689
+ var name = targetClass.name;
2690
+ for (var i = classDecs.length - 1; i >= 0; i--) {
2691
+ var decoratorFinishedRef = { v: false };
2692
+ try {
2693
+ var nextNewClass = classDecs[i](newClass, {
2694
+ kind: "class",
2695
+ name,
2696
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
2697
+ metadata
2698
+ });
2699
+ } finally {
2700
+ decoratorFinishedRef.v = true;
2701
+ }
2702
+ if (nextNewClass !== void 0) {
2703
+ assertValidReturnValue(10, nextNewClass);
2704
+ newClass = nextNewClass;
2705
+ }
2706
+ }
2707
+ return [defineMetadata(newClass, metadata), function() {
2708
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
2709
+ }];
2710
+ }
2711
+ }
2712
+ function defineMetadata(Class, metadata) {
2713
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
2714
+ configurable: true,
2715
+ enumerable: true,
2716
+ value: metadata
2717
+ });
2718
+ }
2719
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
2720
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
2721
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
2722
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
2723
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
2724
+ return {
2725
+ e,
2726
+ get c() {
2727
+ return applyClassDecs(targetClass, classDecs, metadata);
2728
+ }
2729
+ };
2730
+ };
2731
+ }
2732
+ function _apply_decs_2203_r$2(targetClass, memberDecs, classDecs, parentClass) {
2733
+ return (_apply_decs_2203_r$2 = applyDecs2203RFactory$2())(targetClass, memberDecs, classDecs, parentClass);
2734
+ }
2735
+ var _dec$2, _initClass$2;
2736
+ let _ModuleLoaderService;
2737
+ _dec$2 = Injectable();
2738
+ var ModuleLoaderService = class {
2739
+ static {
2740
+ ({c: [_ModuleLoaderService, _initClass$2]} = _apply_decs_2203_r$2(this, [], [_dec$2]));
2741
+ }
2742
+ logger = inject(Logger, { context: _ModuleLoaderService.name });
2743
+ container = inject(Container);
2744
+ modulesMetadata = /* @__PURE__ */ new Map();
2745
+ loadedModules = /* @__PURE__ */ new Map();
2746
+ initialized = false;
2747
+ async loadModules(appModule) {
2748
+ if (this.initialized) return;
2749
+ await this.traverseModules(appModule);
2750
+ this.initialized = true;
2751
+ }
2752
+ /**
2753
+ * Extends the module tree with additional modules or controllers.
2754
+ *
2755
+ * This method is designed to be called by plugins during registration,
2756
+ * which happens after initial module loading but before route registration.
2757
+ *
2758
+ * @param extensions - Array of module extensions to add
2759
+ * @throws Error if not initialized (loadModules must be called first)
2760
+ *
2761
+ * @example
2762
+ * ```typescript
2763
+ * // In plugin registration
2764
+ * const moduleLoader = await context.container.get(ModuleLoaderService)
2765
+ * await moduleLoader.extendModules([{
2766
+ * controllers: [OpenApiJsonController, OpenApiYamlController],
2767
+ * moduleName: 'OpenApiBunModule',
2768
+ * }])
2769
+ * ```
2770
+ */ async extendModules(extensions) {
2771
+ if (!this.initialized) throw new Error("ModuleLoaderService must be initialized before extending. Call loadModules() first.");
2772
+ for (const extension of extensions) if (extension.module) await this.traverseModules(extension.module);
2773
+ else if (extension.controllers && extension.moduleName) await this.registerControllers(extension.controllers, extension.moduleName);
2774
+ else if (extension.controllers) throw new Error("moduleName is required when providing controllers without a module");
2775
+ }
2776
+ /**
2777
+ * Registers controllers under a synthetic module.
2778
+ * Used when plugins want to add controllers without a full module class.
2779
+ */ async registerControllers(controllers, moduleName) {
2780
+ if (this.modulesMetadata.has(moduleName)) {
2781
+ const existing = this.modulesMetadata.get(moduleName);
2782
+ for (const controller of controllers) existing.controllers.add(controller);
2783
+ this.logger.debug(`Extended module ${moduleName} with ${controllers.length} controllers`);
2784
+ } else {
2785
+ const metadata = {
2786
+ controllers: new Set(controllers),
2787
+ imports: /* @__PURE__ */ new Set(),
2788
+ guards: /* @__PURE__ */ new Set(),
2789
+ overrides: /* @__PURE__ */ new Set(),
2790
+ customAttributes: /* @__PURE__ */ new Map(),
2791
+ customEntries: /* @__PURE__ */ new Map()
2792
+ };
2793
+ this.modulesMetadata.set(moduleName, metadata);
2794
+ this.logger.debug(`Created module ${moduleName} with ${controllers.length} controllers`);
2795
+ }
2796
+ }
2797
+ async traverseModules(module, parentMetadata) {
2798
+ const metadata = extractModuleMetadata(module);
2799
+ if (parentMetadata) this.mergeMetadata(metadata, parentMetadata);
2800
+ const moduleName = getInjectableToken(module).id;
2801
+ if (this.modulesMetadata.has(moduleName)) return;
2802
+ try {
2803
+ this.modulesMetadata.set(moduleName, metadata);
2804
+ const imports = metadata.imports ?? /* @__PURE__ */ new Set();
2805
+ const loadingPromises = Array.from(imports).map(async (importedModule) => this.traverseModules(importedModule, metadata));
2806
+ await Promise.all(loadingPromises);
2807
+ this.validateOverrides(metadata, moduleName);
2808
+ const instance = await this.container.get(module);
2809
+ if (instance.onModuleInit) await instance.onModuleInit();
2810
+ this.logger.debug(`Module ${moduleName} loaded`);
2811
+ this.loadedModules.set(moduleName, instance);
2812
+ } catch (error) {
2813
+ this.logger.error(`Error loading module ${moduleName}`, error);
2814
+ throw error;
2815
+ }
2816
+ }
2817
+ validateOverrides(metadata, moduleName) {
2818
+ if (!metadata.overrides || metadata.overrides.size === 0) return;
2819
+ const registry = this.container.getRegistry();
2820
+ for (const overrideClass of metadata.overrides) try {
2821
+ const overrideToken = getInjectableToken(overrideClass);
2822
+ const allRegistrations = registry.getAll(overrideToken);
2823
+ if (allRegistrations.length === 0) {
2824
+ this.logger.warn(`[Navios] Override ${overrideClass.name} in module ${moduleName} is not registered. Make sure it has @Injectable decorator.`);
2825
+ continue;
2826
+ }
2827
+ const highestPriorityRegistration = allRegistrations[0];
2828
+ if (highestPriorityRegistration.target !== overrideClass) {
2829
+ const overrideRegistration = allRegistrations.find((r) => r.target === overrideClass);
2830
+ if (!overrideRegistration) this.logger.warn(`[Navios] Override ${overrideClass.name} in module ${moduleName} is registered but not found in registry for token ${overrideToken.toString()}.`);
2831
+ 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.`);
2832
+ } else this.logger.debug(`[Navios] Override ${overrideClass.name} in module ${moduleName} is active (priority: ${highestPriorityRegistration.priority})`);
2833
+ } catch (error) {
2834
+ this.logger.warn(`[Navios] Failed to validate override ${overrideClass.name} in module ${moduleName}: ${error}`);
2835
+ }
2836
+ }
2837
+ mergeMetadata(metadata, parentMetadata) {
2838
+ if (parentMetadata.guards) for (const guard of parentMetadata.guards) metadata.guards.add(guard);
2839
+ if (parentMetadata.customAttributes) for (const [key, value] of parentMetadata.customAttributes) {
2840
+ if (metadata.customAttributes.has(key)) continue;
2841
+ metadata.customAttributes.set(key, value);
2842
+ }
2843
+ }
2844
+ getAllModules() {
2845
+ return this.modulesMetadata;
2846
+ }
2847
+ dispose() {
2848
+ this.modulesMetadata.clear();
2849
+ this.loadedModules.clear();
2850
+ this.initialized = false;
2851
+ }
2852
+ static {
2853
+ _initClass$2();
2854
+ }
2855
+ };
2856
+
2857
+ //#endregion
2858
+ //#region src/utils/adapter-supports.util.mts
2859
+ /**
2860
+ * Type guard to check if adapter implements a specific method.
2861
+ * Narrows the adapter type to include the method.
2862
+ *
2863
+ * @example
2864
+ * ```typescript
2865
+ * if (adapterSupports(adapter, 'getServer')) {
2866
+ * const server = adapter.getServer() // TypeScript knows this exists
2867
+ * }
2868
+ * ```
2869
+ */ function adapterSupports(adapter, method) {
2870
+ return adapter !== null && typeof adapter[method] === "function";
2871
+ }
2872
+ /**
2873
+ * Asserts adapter supports a method, throws if not.
2874
+ * Narrows type after assertion.
2875
+ *
2876
+ * @example
2877
+ * ```typescript
2878
+ * assertAdapterSupports(adapter, 'enableCors')
2879
+ * adapter.enableCors(options) // TypeScript knows this exists
2880
+ * ```
2881
+ */ function assertAdapterSupports(adapter, method) {
2882
+ if (!adapterSupports(adapter, method)) throw new Error(`Current adapter does not implement '${method}()'`);
2883
+ }
2884
+
2885
+ //#endregion
2886
+ //#region src/navios.environment.mts
2887
+ function applyDecs2203RFactory$1() {
2888
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2889
+ return function addInitializer(initializer) {
2890
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
2891
+ assertCallable(initializer, "An initializer");
2892
+ initializers.push(initializer);
2893
+ };
2894
+ }
2895
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
2896
+ var kindStr;
2897
+ switch (kind) {
2898
+ case 1:
2899
+ kindStr = "accessor";
2900
+ break;
2901
+ case 2:
2902
+ kindStr = "method";
2903
+ break;
2904
+ case 3:
2905
+ kindStr = "getter";
2906
+ break;
2907
+ case 4:
2908
+ kindStr = "setter";
2909
+ break;
2910
+ default: kindStr = "field";
2911
+ }
2912
+ var ctx = {
2913
+ kind: kindStr,
2914
+ name: isPrivate ? "#" + name : name,
2915
+ static: isStatic,
2916
+ private: isPrivate,
2917
+ metadata
2918
+ };
2919
+ var decoratorFinishedRef = { v: false };
2920
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
2921
+ var get, set;
2922
+ if (kind === 0) if (isPrivate) {
2923
+ get = desc.get;
2924
+ set = desc.set;
2925
+ } else {
2926
+ get = function() {
2927
+ return this[name];
2928
+ };
2929
+ set = function(v) {
2930
+ this[name] = v;
2931
+ };
2932
+ }
2933
+ else if (kind === 2) get = function() {
2934
+ return desc.value;
2935
+ };
2936
+ else {
2937
+ if (kind === 1 || kind === 3) get = function() {
2938
+ return desc.get.call(this);
2939
+ };
2940
+ if (kind === 1 || kind === 4) set = function(v) {
2941
+ desc.set.call(this, v);
2942
+ };
2943
+ }
2944
+ ctx.access = get && set ? {
2945
+ get,
2946
+ set
2947
+ } : get ? { get } : { set };
2948
+ try {
2949
+ return dec(value, ctx);
2950
+ } finally {
2951
+ decoratorFinishedRef.v = true;
2952
+ }
2953
+ }
2954
+ function assertNotFinished(decoratorFinishedRef, fnName) {
2955
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
2956
+ }
2957
+ function assertCallable(fn, hint) {
2958
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
2959
+ }
2960
+ function assertValidReturnValue(kind, value) {
2961
+ var type = typeof value;
2962
+ if (kind === 1) {
2963
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2964
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
2965
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
2966
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
2967
+ } else if (type !== "function") {
2968
+ var hint;
2969
+ if (kind === 0) hint = "field";
2970
+ else if (kind === 10) hint = "class";
2971
+ else hint = "method";
2972
+ throw new TypeError(hint + " decorators must return a function or void 0");
2973
+ }
2974
+ }
2975
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
2976
+ var decs = decInfo[0];
2977
+ var desc, init, value;
2978
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
2979
+ get: decInfo[3],
2980
+ set: decInfo[4]
2981
+ };
2982
+ else if (kind === 3) desc = { get: decInfo[3] };
2983
+ else if (kind === 4) desc = { set: decInfo[3] };
2984
+ else desc = { value: decInfo[3] };
2985
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
2986
+ if (kind === 1) value = {
2987
+ get: desc.get,
2988
+ set: desc.set
2989
+ };
2990
+ else if (kind === 2) value = desc.value;
2991
+ else if (kind === 3) value = desc.get;
2992
+ else if (kind === 4) value = desc.set;
2993
+ var newValue, get, set;
2994
+ if (typeof decs === "function") {
2995
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2996
+ if (newValue !== void 0) {
2997
+ assertValidReturnValue(kind, newValue);
2998
+ if (kind === 0) init = newValue;
2999
+ else if (kind === 1) {
3000
+ init = newValue.init;
3001
+ get = newValue.get || value.get;
3002
+ set = newValue.set || value.set;
3003
+ value = {
3004
+ get,
3005
+ set
3006
+ };
3007
+ } else value = newValue;
3008
+ }
3009
+ } else for (var i = decs.length - 1; i >= 0; i--) {
3010
+ var dec = decs[i];
3011
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
3012
+ if (newValue !== void 0) {
3013
+ assertValidReturnValue(kind, newValue);
3014
+ var newInit;
3015
+ if (kind === 0) newInit = newValue;
3016
+ else if (kind === 1) {
3017
+ newInit = newValue.init;
3018
+ get = newValue.get || value.get;
3019
+ set = newValue.set || value.set;
3020
+ value = {
3021
+ get,
3022
+ set
3023
+ };
3024
+ } else value = newValue;
3025
+ if (newInit !== void 0) if (init === void 0) init = newInit;
3026
+ else if (typeof init === "function") init = [init, newInit];
3027
+ else init.push(newInit);
3028
+ }
3029
+ }
3030
+ if (kind === 0 || kind === 1) {
3031
+ if (init === void 0) init = function(instance, init$1) {
3032
+ return init$1;
3033
+ };
3034
+ else if (typeof init !== "function") {
3035
+ var ownInitializers = init;
3036
+ init = function(instance, init$1) {
3037
+ var value$1 = init$1;
3038
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
3039
+ return value$1;
3040
+ };
3041
+ } else {
3042
+ var originalInitializer = init;
3043
+ init = function(instance, init$1) {
3044
+ return originalInitializer.call(instance, init$1);
3045
+ };
3046
+ }
3047
+ ret.push(init);
3048
+ }
3049
+ if (kind !== 0) {
3050
+ if (kind === 1) {
3051
+ desc.get = value.get;
3052
+ desc.set = value.set;
3053
+ } else if (kind === 2) desc.value = value;
3054
+ else if (kind === 3) desc.get = value;
3055
+ else if (kind === 4) desc.set = value;
3056
+ if (isPrivate) if (kind === 1) {
3057
+ ret.push(function(instance, args) {
3058
+ return value.get.call(instance, args);
3059
+ });
3060
+ ret.push(function(instance, args) {
3061
+ return value.set.call(instance, args);
3062
+ });
3063
+ } else if (kind === 2) ret.push(value);
3064
+ else ret.push(function(instance, args) {
3065
+ return value.call(instance, args);
3066
+ });
3067
+ else Object.defineProperty(base, name, desc);
3068
+ }
3069
+ }
3070
+ function applyMemberDecs(Class, decInfos, metadata) {
3071
+ var ret = [];
3072
+ var protoInitializers;
3073
+ var staticInitializers;
3074
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
3075
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
3076
+ for (var i = 0; i < decInfos.length; i++) {
3077
+ var decInfo = decInfos[i];
3078
+ if (!Array.isArray(decInfo)) continue;
3079
+ var kind = decInfo[1];
3080
+ var name = decInfo[2];
3081
+ var isPrivate = decInfo.length > 3;
3082
+ var isStatic = kind >= 5;
3083
+ var base;
3084
+ var initializers;
3085
+ if (isStatic) {
3086
+ base = Class;
3087
+ kind = kind - 5;
3088
+ staticInitializers = staticInitializers || [];
3089
+ initializers = staticInitializers;
3090
+ } else {
3091
+ base = Class.prototype;
3092
+ protoInitializers = protoInitializers || [];
3093
+ initializers = protoInitializers;
3094
+ }
3095
+ if (kind !== 0 && !isPrivate) {
3096
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
3097
+ var existingKind = existingNonFields.get(name) || 0;
3098
+ 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);
3099
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
3100
+ else existingNonFields.set(name, true);
3101
+ }
3102
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
3103
+ }
3104
+ pushInitializers(ret, protoInitializers);
3105
+ pushInitializers(ret, staticInitializers);
3106
+ return ret;
3107
+ }
3108
+ function pushInitializers(ret, initializers) {
3109
+ if (initializers) ret.push(function(instance) {
3110
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
3111
+ return instance;
3112
+ });
3113
+ }
3114
+ function applyClassDecs(targetClass, classDecs, metadata) {
3115
+ if (classDecs.length > 0) {
3116
+ var initializers = [];
3117
+ var newClass = targetClass;
3118
+ var name = targetClass.name;
3119
+ for (var i = classDecs.length - 1; i >= 0; i--) {
3120
+ var decoratorFinishedRef = { v: false };
3121
+ try {
3122
+ var nextNewClass = classDecs[i](newClass, {
3123
+ kind: "class",
3124
+ name,
3125
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
3126
+ metadata
3127
+ });
3128
+ } finally {
3129
+ decoratorFinishedRef.v = true;
3130
+ }
3131
+ if (nextNewClass !== void 0) {
3132
+ assertValidReturnValue(10, nextNewClass);
3133
+ newClass = nextNewClass;
3134
+ }
3135
+ }
3136
+ return [defineMetadata(newClass, metadata), function() {
3137
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
3138
+ }];
3139
+ }
3140
+ }
3141
+ function defineMetadata(Class, metadata) {
3142
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
3143
+ configurable: true,
3144
+ enumerable: true,
3145
+ value: metadata
3146
+ });
3147
+ }
3148
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
3149
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
3150
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
3151
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
3152
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
3153
+ return {
3154
+ e,
3155
+ get c() {
3156
+ return applyClassDecs(targetClass, classDecs, metadata);
3157
+ }
3158
+ };
3159
+ };
3160
+ }
3161
+ function _apply_decs_2203_r$1(targetClass, memberDecs, classDecs, parentClass) {
3162
+ return (_apply_decs_2203_r$1 = applyDecs2203RFactory$1())(targetClass, memberDecs, classDecs, parentClass);
3163
+ }
3164
+ var _dec$1, _initClass$1;
3165
+ let _NaviosEnvironment;
3166
+ _dec$1 = Injectable();
3167
+ var NaviosEnvironment = class {
3168
+ static {
3169
+ ({c: [_NaviosEnvironment, _initClass$1]} = _apply_decs_2203_r$1(this, [], [_dec$1]));
3170
+ }
3171
+ adapterConfigured = false;
3172
+ tokens = /* @__PURE__ */ new Map();
3173
+ setupEnvironment(tokens) {
3174
+ const hasAdapterToken = tokens.has(AdapterToken);
3175
+ if (hasAdapterToken && this.adapterConfigured) throw new Error("Adapter already configured. Only one adapter per application.");
3176
+ for (const [token, value] of tokens) this.tokens.set(token, value);
3177
+ if (hasAdapterToken) this.adapterConfigured = true;
3178
+ }
3179
+ getToken(token) {
3180
+ return this.tokens.get(token);
3181
+ }
3182
+ hasAdapterSetup() {
3183
+ return this.adapterConfigured;
3184
+ }
3185
+ static {
3186
+ _initClass$1();
3187
+ }
3188
+ };
3189
+
3190
+ //#endregion
3191
+ //#region src/navios.application.mts
3192
+ function applyDecs2203RFactory() {
3193
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
3194
+ return function addInitializer(initializer) {
3195
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
3196
+ assertCallable(initializer, "An initializer");
3197
+ initializers.push(initializer);
3198
+ };
3199
+ }
3200
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
3201
+ var kindStr;
3202
+ switch (kind) {
3203
+ case 1:
3204
+ kindStr = "accessor";
3205
+ break;
3206
+ case 2:
3207
+ kindStr = "method";
3208
+ break;
3209
+ case 3:
3210
+ kindStr = "getter";
3211
+ break;
3212
+ case 4:
3213
+ kindStr = "setter";
3214
+ break;
3215
+ default: kindStr = "field";
3216
+ }
3217
+ var ctx = {
3218
+ kind: kindStr,
3219
+ name: isPrivate ? "#" + name : name,
3220
+ static: isStatic,
3221
+ private: isPrivate,
3222
+ metadata
3223
+ };
3224
+ var decoratorFinishedRef = { v: false };
3225
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
3226
+ var get, set;
3227
+ if (kind === 0) if (isPrivate) {
3228
+ get = desc.get;
3229
+ set = desc.set;
3230
+ } else {
3231
+ get = function() {
3232
+ return this[name];
3233
+ };
3234
+ set = function(v) {
3235
+ this[name] = v;
3236
+ };
3237
+ }
3238
+ else if (kind === 2) get = function() {
3239
+ return desc.value;
3240
+ };
3241
+ else {
3242
+ if (kind === 1 || kind === 3) get = function() {
3243
+ return desc.get.call(this);
3244
+ };
3245
+ if (kind === 1 || kind === 4) set = function(v) {
3246
+ desc.set.call(this, v);
3247
+ };
3248
+ }
3249
+ ctx.access = get && set ? {
3250
+ get,
3251
+ set
3252
+ } : get ? { get } : { set };
3253
+ try {
3254
+ return dec(value, ctx);
3255
+ } finally {
3256
+ decoratorFinishedRef.v = true;
3257
+ }
3258
+ }
3259
+ function assertNotFinished(decoratorFinishedRef, fnName) {
3260
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
3261
+ }
3262
+ function assertCallable(fn, hint) {
3263
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
3264
+ }
3265
+ function assertValidReturnValue(kind, value) {
3266
+ var type = typeof value;
3267
+ if (kind === 1) {
3268
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
3269
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
3270
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
3271
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
3272
+ } else if (type !== "function") {
3273
+ var hint;
3274
+ if (kind === 0) hint = "field";
3275
+ else if (kind === 10) hint = "class";
3276
+ else hint = "method";
3277
+ throw new TypeError(hint + " decorators must return a function or void 0");
3278
+ }
3279
+ }
3280
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
3281
+ var decs = decInfo[0];
3282
+ var desc, init, value;
3283
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
3284
+ get: decInfo[3],
3285
+ set: decInfo[4]
3286
+ };
3287
+ else if (kind === 3) desc = { get: decInfo[3] };
3288
+ else if (kind === 4) desc = { set: decInfo[3] };
3289
+ else desc = { value: decInfo[3] };
3290
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
3291
+ if (kind === 1) value = {
3292
+ get: desc.get,
3293
+ set: desc.set
3294
+ };
3295
+ else if (kind === 2) value = desc.value;
3296
+ else if (kind === 3) value = desc.get;
3297
+ else if (kind === 4) value = desc.set;
3298
+ var newValue, get, set;
3299
+ if (typeof decs === "function") {
3300
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
3301
+ if (newValue !== void 0) {
3302
+ assertValidReturnValue(kind, newValue);
3303
+ if (kind === 0) init = newValue;
3304
+ else if (kind === 1) {
3305
+ init = newValue.init;
3306
+ get = newValue.get || value.get;
3307
+ set = newValue.set || value.set;
3308
+ value = {
3309
+ get,
3310
+ set
3311
+ };
3312
+ } else value = newValue;
3313
+ }
3314
+ } else for (var i = decs.length - 1; i >= 0; i--) {
3315
+ var dec = decs[i];
3316
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
3317
+ if (newValue !== void 0) {
3318
+ assertValidReturnValue(kind, newValue);
3319
+ var newInit;
3320
+ if (kind === 0) newInit = newValue;
3321
+ else if (kind === 1) {
3322
+ newInit = newValue.init;
3323
+ get = newValue.get || value.get;
3324
+ set = newValue.set || value.set;
3325
+ value = {
3326
+ get,
3327
+ set
3328
+ };
3329
+ } else value = newValue;
3330
+ if (newInit !== void 0) if (init === void 0) init = newInit;
3331
+ else if (typeof init === "function") init = [init, newInit];
3332
+ else init.push(newInit);
3333
+ }
3334
+ }
3335
+ if (kind === 0 || kind === 1) {
3336
+ if (init === void 0) init = function(instance, init$1) {
3337
+ return init$1;
3338
+ };
3339
+ else if (typeof init !== "function") {
3340
+ var ownInitializers = init;
3341
+ init = function(instance, init$1) {
3342
+ var value$1 = init$1;
3343
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
3344
+ return value$1;
3345
+ };
3346
+ } else {
3347
+ var originalInitializer = init;
3348
+ init = function(instance, init$1) {
3349
+ return originalInitializer.call(instance, init$1);
3350
+ };
3351
+ }
3352
+ ret.push(init);
3353
+ }
3354
+ if (kind !== 0) {
3355
+ if (kind === 1) {
3356
+ desc.get = value.get;
3357
+ desc.set = value.set;
3358
+ } else if (kind === 2) desc.value = value;
3359
+ else if (kind === 3) desc.get = value;
3360
+ else if (kind === 4) desc.set = value;
3361
+ if (isPrivate) if (kind === 1) {
3362
+ ret.push(function(instance, args) {
3363
+ return value.get.call(instance, args);
3364
+ });
3365
+ ret.push(function(instance, args) {
3366
+ return value.set.call(instance, args);
3367
+ });
3368
+ } else if (kind === 2) ret.push(value);
3369
+ else ret.push(function(instance, args) {
3370
+ return value.call(instance, args);
3371
+ });
3372
+ else Object.defineProperty(base, name, desc);
3373
+ }
3374
+ }
3375
+ function applyMemberDecs(Class, decInfos, metadata) {
3376
+ var ret = [];
3377
+ var protoInitializers;
3378
+ var staticInitializers;
3379
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
3380
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
3381
+ for (var i = 0; i < decInfos.length; i++) {
3382
+ var decInfo = decInfos[i];
3383
+ if (!Array.isArray(decInfo)) continue;
3384
+ var kind = decInfo[1];
3385
+ var name = decInfo[2];
3386
+ var isPrivate = decInfo.length > 3;
3387
+ var isStatic = kind >= 5;
3388
+ var base;
3389
+ var initializers;
3390
+ if (isStatic) {
3391
+ base = Class;
3392
+ kind = kind - 5;
3393
+ staticInitializers = staticInitializers || [];
3394
+ initializers = staticInitializers;
3395
+ } else {
3396
+ base = Class.prototype;
3397
+ protoInitializers = protoInitializers || [];
3398
+ initializers = protoInitializers;
3399
+ }
3400
+ if (kind !== 0 && !isPrivate) {
3401
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
3402
+ var existingKind = existingNonFields.get(name) || 0;
3403
+ 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);
3404
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
3405
+ else existingNonFields.set(name, true);
3406
+ }
3407
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
3408
+ }
3409
+ pushInitializers(ret, protoInitializers);
3410
+ pushInitializers(ret, staticInitializers);
3411
+ return ret;
3412
+ }
3413
+ function pushInitializers(ret, initializers) {
3414
+ if (initializers) ret.push(function(instance) {
3415
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
3416
+ return instance;
3417
+ });
3418
+ }
3419
+ function applyClassDecs(targetClass, classDecs, metadata) {
3420
+ if (classDecs.length > 0) {
3421
+ var initializers = [];
3422
+ var newClass = targetClass;
3423
+ var name = targetClass.name;
3424
+ for (var i = classDecs.length - 1; i >= 0; i--) {
3425
+ var decoratorFinishedRef = { v: false };
3426
+ try {
3427
+ var nextNewClass = classDecs[i](newClass, {
3428
+ kind: "class",
3429
+ name,
3430
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
3431
+ metadata
3432
+ });
3433
+ } finally {
3434
+ decoratorFinishedRef.v = true;
3435
+ }
3436
+ if (nextNewClass !== void 0) {
3437
+ assertValidReturnValue(10, nextNewClass);
3438
+ newClass = nextNewClass;
3439
+ }
3440
+ }
3441
+ return [defineMetadata(newClass, metadata), function() {
3442
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
3443
+ }];
3444
+ }
3445
+ }
3446
+ function defineMetadata(Class, metadata) {
3447
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
3448
+ configurable: true,
3449
+ enumerable: true,
3450
+ value: metadata
3451
+ });
3452
+ }
3453
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
3454
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
3455
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
3456
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
3457
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
3458
+ return {
3459
+ e,
3460
+ get c() {
3461
+ return applyClassDecs(targetClass, classDecs, metadata);
3462
+ }
3463
+ };
3464
+ };
3465
+ }
3466
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
3467
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
3468
+ }
3469
+ var _dec, _initClass;
3470
+ let _NaviosApplication;
3471
+ _dec = Injectable();
3472
+ var NaviosApplication = class {
3473
+ static {
3474
+ ({c: [_NaviosApplication, _initClass]} = _apply_decs_2203_r(this, [], [_dec]));
3475
+ }
3476
+ environment = inject(_NaviosEnvironment);
3477
+ moduleLoader = inject(_ModuleLoaderService);
3478
+ adapter = null;
3479
+ logger = inject(Logger, { context: _NaviosApplication.name });
3480
+ container = inject(Container);
3481
+ appModule = null;
3482
+ options = { adapter: [] };
3483
+ plugins = [];
3484
+ /**
3485
+ * Indicates whether the application has been initialized.
3486
+ * Set to `true` after `init()` completes successfully.
3487
+ */ isInitialized = false;
3488
+ /**
3489
+ * Sets up the application with the provided module and options.
3490
+ * This is called automatically by NaviosFactory.create().
3491
+ *
3492
+ * @param appModule - The root application module
3493
+ * @param options - Application configuration options
3494
+ * @internal
3495
+ */ async setup(appModule, options = { adapter: [] }) {
3496
+ this.appModule = appModule;
3497
+ this.options = options;
3498
+ if (this.environment.hasAdapterSetup()) this.adapter = await this.container.get(AdapterToken);
3499
+ }
3500
+ /**
3501
+ * Gets the dependency injection container used by this application.
3502
+ *
3503
+ * @returns The Container instance
3504
+ */ getContainer() {
3505
+ return this.container;
3506
+ }
3507
+ /**
3508
+ * Returns the current adapter instance.
3509
+ *
3510
+ * @returns The adapter instance
3511
+ * @throws Error if adapter is not initialized
3512
+ */ getAdapter() {
3513
+ if (!this.adapter) throw new Error("Adapter not initialized");
3514
+ return this.adapter;
3515
+ }
3516
+ /**
3517
+ * Registers a plugin to be initialized after modules are loaded.
3518
+ *
3519
+ * Plugins are initialized in the order they are registered,
3520
+ * after all modules are loaded but before the server starts listening.
3521
+ *
3522
+ * @param definition - Plugin definition with options
3523
+ * @returns this for method chaining
3524
+ *
3525
+ * @example
3526
+ * ```typescript
3527
+ * import { defineOpenApiPlugin } from '@navios/openapi-fastify'
3528
+ *
3529
+ * app.usePlugin(defineOpenApiPlugin({
3530
+ * info: { title: 'My API', version: '1.0.0' },
3531
+ * }))
3532
+ * ```
3533
+ */ usePlugin(definition) {
3534
+ this.plugins.push(definition);
3535
+ return this;
3536
+ }
3537
+ /**
3538
+ * Initializes the application.
3539
+ *
3540
+ * This method:
3541
+ * - Loads all modules and their dependencies
3542
+ * - Sets up the adapter if one is configured
3543
+ * - Calls onModuleInit hooks on all modules
3544
+ * - Initializes registered plugins
3545
+ * - Marks the application as initialized
3546
+ *
3547
+ * Must be called before `listen()`.
3548
+ *
3549
+ * @throws Error if app module is not set
3550
+ *
3551
+ * @example
3552
+ * ```typescript
3553
+ * const app = await NaviosFactory.create(AppModule, {
3554
+ * adapter: defineFastifyEnvironment(),
3555
+ * })
3556
+ * await app.init()
3557
+ * await app.listen({ port: 3000 })
3558
+ * ```
3559
+ */ async init() {
3560
+ if (!this.appModule) throw new Error("App module is not set. Call setAppModule() first.");
3561
+ await this.moduleLoader.loadModules(this.appModule);
3562
+ if (this.environment.hasAdapterSetup() && this.adapter) await this.adapter.setupAdapter(this.options);
3563
+ await this.initPlugins();
3564
+ await this.initModules();
3565
+ if (this.adapter) await this.adapter.ready();
3566
+ this.isInitialized = true;
3567
+ this.logger.debug("Navios application initialized");
3568
+ }
3569
+ async initModules() {
3570
+ const modules = this.moduleLoader.getAllModules();
3571
+ if (this.adapter) await this.adapter.onModulesInit(modules);
3572
+ }
3573
+ async initPlugins() {
3574
+ if (this.plugins.length === 0) return;
3575
+ if (!this.adapter) throw new Error("Cannot initialize plugins without an adapter");
3576
+ const context = {
3577
+ modules: this.moduleLoader.getAllModules(),
3578
+ adapter: this.adapter,
3579
+ container: this.container,
3580
+ moduleLoader: this.moduleLoader
3581
+ };
3582
+ for (const { plugin, options } of this.plugins) {
3583
+ this.logger.debug(`Initializing plugin: ${plugin.name}`);
3584
+ await plugin.register(context, options);
3585
+ }
3586
+ }
3587
+ async get(token, args) {
3588
+ return this.container.get(token, args);
3589
+ }
3590
+ /**
3591
+ * Configures the adapter with additional options before initialization.
3592
+ *
3593
+ * This method allows setting adapter-specific configuration options
3594
+ * before the adapter is initialized. Must be called before `init()`.
3595
+ *
3596
+ * @param options - Adapter-specific configuration options
3597
+ * @returns this for method chaining
3598
+ * @throws Error if called after init() or if adapter doesn't support configure
3599
+ *
3600
+ * @example
3601
+ * ```typescript
3602
+ * // With Fastify adapter
3603
+ * app.configure({ trustProxy: true, logger: true })
3604
+ *
3605
+ * // With Bun adapter
3606
+ * app.configure({ development: true })
3607
+ * ```
3608
+ */ configure(options) {
3609
+ if (this.isInitialized) throw new Error("configure() must be called before init()");
3610
+ assertAdapterSupports(this.adapter, "configure");
3611
+ this.adapter.configure(options);
3612
+ return this;
3613
+ }
3614
+ /**
3615
+ * Enables CORS (Cross-Origin Resource Sharing) for the application.
3616
+ *
3617
+ * @param options - CORS configuration options (adapter-specific)
3618
+ * @throws Error if adapter doesn't support enableCors
3619
+ *
3620
+ * @example
3621
+ * ```typescript
3622
+ * app.enableCors({
3623
+ * origin: ['http://localhost:3000', 'https://example.com'],
3624
+ * methods: ['GET', 'POST', 'PUT', 'DELETE'],
3625
+ * credentials: true,
3626
+ * })
3627
+ * ```
3628
+ */ enableCors(options) {
3629
+ assertAdapterSupports(this.adapter, "enableCors");
3630
+ this.adapter.enableCors(options);
3631
+ }
3632
+ /**
3633
+ * Enables multipart/form-data support for file uploads.
3634
+ *
3635
+ * @param options - Multipart configuration options (adapter-specific)
3636
+ * @throws Error if adapter doesn't support enableMultipart
3637
+ *
3638
+ * @example
3639
+ * ```typescript
3640
+ * app.enableMultipart({
3641
+ * limits: {
3642
+ * fileSize: 1024 * 1024 * 10, // 10MB
3643
+ * },
3644
+ * })
3645
+ * ```
3646
+ */ enableMultipart(options) {
3647
+ assertAdapterSupports(this.adapter, "enableMultipart");
3648
+ this.adapter.enableMultipart(options);
3649
+ }
3650
+ /**
3651
+ * Sets a global prefix for all routes.
3652
+ *
3653
+ * @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
3654
+ * @throws Error if adapter doesn't support setGlobalPrefix
3655
+ *
3656
+ * @example
3657
+ * ```typescript
3658
+ * app.setGlobalPrefix('/api/v1')
3659
+ * // All routes will be prefixed with /api/v1
3660
+ * ```
3661
+ */ setGlobalPrefix(prefix) {
3662
+ assertAdapterSupports(this.adapter, "setGlobalPrefix");
3663
+ this.adapter.setGlobalPrefix(prefix);
3664
+ }
3665
+ /**
3666
+ * Gets the underlying HTTP server instance.
3667
+ *
3668
+ * The type of the returned server depends on the adapter used:
3669
+ * - Fastify adapter: Returns FastifyInstance
3670
+ * - Bun adapter: Returns Bun.Server
3671
+ *
3672
+ * @returns The HTTP server instance
3673
+ * @throws Error if adapter doesn't support getServer
3674
+ *
3675
+ * @example
3676
+ * ```typescript
3677
+ * const server = app.getServer()
3678
+ * // Use adapter-specific server methods
3679
+ * ```
3680
+ */ getServer() {
3681
+ assertAdapterSupports(this.adapter, "getServer");
3682
+ return this.adapter.getServer();
3683
+ }
3684
+ /**
3685
+ * Starts the HTTP server and begins listening for requests.
3686
+ *
3687
+ * @param options - Listen options (port, host, etc.)
3688
+ * @throws Error if adapter doesn't support listen
3689
+ *
3690
+ * @example
3691
+ * ```typescript
3692
+ * await app.listen({ port: 3000, host: '0.0.0.0' })
3693
+ * ```
3694
+ */ async listen(options) {
3695
+ assertAdapterSupports(this.adapter, "listen");
3696
+ return this.adapter.listen(options);
3697
+ }
3698
+ /**
3699
+ * Disposes of application resources.
3700
+ *
3701
+ * Cleans up the adapter and module loader.
3702
+ * This method is called automatically by `close()`.
3703
+ */ async dispose() {
3704
+ if (this.adapter) await this.adapter.dispose();
3705
+ if (this.moduleLoader) this.moduleLoader.dispose();
3706
+ }
3707
+ /**
3708
+ * Closes the application and cleans up all resources.
3709
+ *
3710
+ * This is an alias for `dispose()`.
3711
+ *
3712
+ * @example
3713
+ * ```typescript
3714
+ * // Graceful shutdown
3715
+ * process.on('SIGTERM', async () => {
3716
+ * await app.close()
3717
+ * process.exit(0)
3718
+ * })
3719
+ * ```
3720
+ */ async close() {
3721
+ await this.dispose();
3722
+ }
3723
+ static {
3724
+ _initClass();
3725
+ }
3726
+ };
3727
+
3728
+ //#endregion
3729
+ //#region src/navios.factory.mts
3730
+ /**
3731
+ * Factory class for creating and configuring Navios applications.
3732
+ *
3733
+ * This is the main entry point for bootstrapping a Navios application.
3734
+ * It handles dependency injection container setup, adapter registration,
3735
+ * and logger configuration.
3736
+ *
3737
+ * @example
3738
+ * ```typescript
3739
+ * import { NaviosFactory } from '@navios/core'
3740
+ * import { defineFastifyEnvironment } from '@navios/adapter-fastify'
3741
+ *
3742
+ * const app = await NaviosFactory.create(AppModule, {
3743
+ * adapter: defineFastifyEnvironment(),
3744
+ * logger: ['log', 'error', 'warn'],
3745
+ * })
3746
+ *
3747
+ * await app.init()
3748
+ * await app.listen({ port: 3000 })
3749
+ * ```
3750
+ */ var NaviosFactory = class {
3751
+ /**
3752
+ * Creates a new Navios application instance.
3753
+ *
3754
+ * This method sets up the dependency injection container, registers the adapter,
3755
+ * configures logging, and initializes the application with the provided module.
3756
+ *
3757
+ * @typeParam Environment - Adapter environment interface for type-safe access
3758
+ * to adapter-specific features. When specified, methods like `getServer()`,
3759
+ * `enableCors()`, `listen()`, and `configure()` will have proper types.
3760
+ *
3761
+ * @param appModule - The root application module class decorated with @Module()
3762
+ * @param options - Configuration options for the application
3763
+ * @param options.adapter - Adapter environment (required for server functionality)
3764
+ * @param options.logger - Logger configuration. Can be:
3765
+ * - A LoggerService instance for custom logging
3766
+ * - An array of LogLevel strings to enable specific log levels
3767
+ * - `false` to disable logging
3768
+ * @param options.container - Optional custom dependency injection container (useful for testing)
3769
+ * @returns A configured NaviosApplication instance ready to be initialized
3770
+ *
3771
+ * @example
3772
+ * ```typescript
3773
+ * // Basic setup with Fastify adapter
3774
+ * const app = await NaviosFactory.create(AppModule, {
3775
+ * adapter: defineFastifyEnvironment(),
3776
+ * })
3777
+ *
3778
+ * // Type-safe setup with Fastify environment
3779
+ * import { FastifyEnvironment } from '@navios/adapter-fastify'
3780
+ *
3781
+ * const app = await NaviosFactory.create<FastifyEnvironment>(AppModule, {
3782
+ * adapter: defineFastifyEnvironment(),
3783
+ * })
3784
+ * app.configure({ trustProxy: true })
3785
+ * const server = app.getServer() // FastifyInstance
3786
+ *
3787
+ * // With custom logger configuration
3788
+ * const app = await NaviosFactory.create(AppModule, {
3789
+ * adapter: defineFastifyEnvironment(),
3790
+ * logger: ['error', 'warn', 'log'],
3791
+ * })
3792
+ *
3793
+ * // With custom container for testing
3794
+ * const container = new Container()
3795
+ * const app = await NaviosFactory.create(AppModule, {
3796
+ * adapter: defineFastifyEnvironment(),
3797
+ * container,
3798
+ * })
3799
+ * ```
3800
+ */ static async create(appModule, options = { adapter: [] }) {
3801
+ const container = options.container ?? new Container(options.registry);
3802
+ if (options.enableRequestId === true) setRequestIdEnabled(true);
3803
+ container.addInstance(NaviosOptionsToken, options);
3804
+ await this.registerLoggerConfiguration(container, options);
3805
+ const adapters = Array.isArray(options.adapter) ? options.adapter : [options.adapter];
3806
+ for (const adapter of adapters) await this.registerEnvironment(container, adapter);
3807
+ const app = await container.get(_NaviosApplication);
3808
+ await app.setup(appModule, options);
3809
+ return app;
3810
+ }
3811
+ static async registerEnvironment(container, environment = {}) {
3812
+ const naviosEnvironment = await container.get(_NaviosEnvironment);
3813
+ const { tokens } = environment;
3814
+ if (tokens) naviosEnvironment.setupEnvironment(tokens);
3815
+ }
3816
+ static async registerLoggerConfiguration(container, options) {
3817
+ const { logger } = options;
3818
+ if (Array.isArray(logger) || isNil(logger) || options.enableRequestId) {
3819
+ (await container.get(LoggerOutput))?.setup({
3820
+ logLevels: Array.isArray(logger) ? logger : void 0,
3821
+ requestId: options.enableRequestId ?? false
3822
+ });
3823
+ return;
3824
+ }
3825
+ if (logger !== true && !isNil(logger)) container.addInstance(LoggerOutput, logger);
3826
+ }
3827
+ };
3828
+
3829
+ //#endregion
3830
+ export { isFunction as A, isLogLevelEnabled as B, generateRequestId as C, addLeadingSlash as D, setRequestIdEnabled as E, isString as F, yellow as G, isLogLevel as H, isSymbol as I, isUndefined as L, isNumber as M, isObject as N, isConstructor as O, isPlainObject as P, normalizePath as R, loggerOptionsSchema as S, runWithRequestId as T, LOG_LEVELS as U, filterLogLevels as V, clc as W, HttpException as _, assertAdapterSupports as a, Logger as b, AbstractHandlerAdapterService as c, _ErrorResponseProducerService as d, ForbiddenResponderToken as f, FrameworkError as g, ValidationErrorResponderToken as h, adapterSupports as i, isNil as j, isEmpty as k, ControllerResolverService as l, NotFoundResponderToken as m, _NaviosApplication as n, _ModuleLoaderService as o, InternalServerErrorResponderToken as p, _NaviosEnvironment as r, _GuardRunnerService as s, NaviosFactory as t, _InstanceResolverService as u, _LoggerInstance as v, getRequestId as w, LoggerOutput as x, _ConsoleLogger as y, stripEndSlash as z };
3831
+ //# sourceMappingURL=navios.factory-C75yZCoD.mjs.map