@navios/core 1.1.0 → 2.0.0-alpha.1

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