@navios/core 0.1.13 → 0.1.15

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 (36) hide show
  1. package/dist/_tsup-dts-rollup.d.mts +133 -49
  2. package/dist/_tsup-dts-rollup.d.ts +133 -49
  3. package/dist/index.d.mts +8 -2
  4. package/dist/index.d.ts +8 -2
  5. package/dist/index.js +1184 -1090
  6. package/dist/index.mjs +1179 -1090
  7. package/package.json +1 -1
  8. package/src/adapters/endpoint-adapter.service.mts +75 -0
  9. package/src/adapters/handler-adapter.interface.mts +21 -0
  10. package/src/adapters/index.mts +4 -0
  11. package/src/adapters/multipart-adapter.service.mts +130 -0
  12. package/src/adapters/stream-adapter.service.mts +95 -0
  13. package/src/attribute.factory.mts +13 -13
  14. package/src/config/config.provider.mts +8 -2
  15. package/src/decorators/controller.decorator.mts +0 -2
  16. package/src/decorators/endpoint.decorator.mts +7 -3
  17. package/src/decorators/header.decorator.mts +1 -6
  18. package/src/decorators/http-code.decorator.mts +1 -6
  19. package/src/decorators/module.decorator.mts +13 -15
  20. package/src/decorators/multipart.decorator.mts +7 -3
  21. package/src/decorators/stream.decorator.mts +7 -3
  22. package/src/index.mts +1 -0
  23. package/src/logger/console-logger.service.mts +41 -3
  24. package/src/logger/logger.service.mts +0 -1
  25. package/src/metadata/controller.metadata.mts +3 -3
  26. package/src/metadata/{endpoint.metadata.mts → handler.metadata.mts} +17 -24
  27. package/src/metadata/index.mts +1 -1
  28. package/src/navios.application.mts +3 -4
  29. package/src/service-locator/__tests__/injection-token.spec.mts +10 -5
  30. package/src/service-locator/decorators/injectable.decorator.mts +53 -4
  31. package/src/service-locator/inject.mts +14 -0
  32. package/src/service-locator/interfaces/factory.interface.mts +9 -1
  33. package/src/service-locator/service-locator.mts +1 -0
  34. package/src/service-locator/sync-injector.mts +14 -0
  35. package/src/services/controller-adapter.service.mts +59 -240
  36. package/src/services/execution-context.mts +4 -3
package/dist/index.js CHANGED
@@ -88,11 +88,12 @@ __export(src_exports, {
88
88
  ControllerAdapterService: () => ControllerAdapterService,
89
89
  ControllerMetadataKey: () => ControllerMetadataKey,
90
90
  Endpoint: () => Endpoint,
91
+ EndpointAdapterService: () => EndpointAdapterService,
92
+ EndpointAdapterToken: () => EndpointAdapterToken,
91
93
  EndpointMetadataKey: () => EndpointMetadataKey,
92
- EndpointType: () => EndpointType,
93
94
  ErrorsEnum: () => ErrorsEnum,
94
95
  EventEmitter: () => EventEmitter,
95
- ExecutionContext: () => ExecutionContext2,
96
+ ExecutionContext: () => ExecutionContext,
96
97
  ExecutionContextInjectionToken: () => ExecutionContextInjectionToken,
97
98
  ExecutionContextToken: () => ExecutionContextToken,
98
99
  FactoryInjectionToken: () => FactoryInjectionToken,
@@ -122,6 +123,8 @@ __export(src_exports, {
122
123
  ModuleLoaderService: () => ModuleLoaderService,
123
124
  ModuleMetadataKey: () => ModuleMetadataKey,
124
125
  Multipart: () => Multipart,
126
+ MultipartAdapterService: () => MultipartAdapterService,
127
+ MultipartAdapterToken: () => MultipartAdapterToken,
125
128
  NaviosApplication: () => NaviosApplication,
126
129
  NaviosFactory: () => NaviosFactory,
127
130
  NotFoundException: () => NotFoundException,
@@ -134,6 +137,8 @@ __export(src_exports, {
134
137
  ServiceLocatorInstanceHolderStatus: () => ServiceLocatorInstanceHolderStatus,
135
138
  ServiceLocatorManager: () => ServiceLocatorManager,
136
139
  Stream: () => Stream,
140
+ StreamAdapterService: () => StreamAdapterService,
141
+ StreamAdapterToken: () => StreamAdapterToken,
137
142
  UnauthorizedException: () => UnauthorizedException,
138
143
  UnknownError: () => UnknownError,
139
144
  UseGuards: () => UseGuards,
@@ -177,117 +182,6 @@ __export(src_exports, {
177
182
  });
178
183
  module.exports = __toCommonJS(src_exports);
179
184
 
180
- // packages/core/src/config/utils/helpers.mts
181
- var import_node_process = require("process");
182
- function envInt(key, defaultValue) {
183
- const envKey = import_node_process.env[key] || process.env[key];
184
- return envKey ? parseInt(envKey, 10) : defaultValue;
185
- }
186
- function envString(key, defaultValue) {
187
- return import_node_process.env[key] || process.env[key] || defaultValue || void 0;
188
- }
189
-
190
- // packages/core/src/config/config.provider.mts
191
- var import_zod3 = require("zod");
192
-
193
- // packages/core/src/logger/utils/cli-colors.util.mts
194
- var isColorAllowed = () => !process.env.NO_COLOR;
195
- var colorIfAllowed = (colorFn) => (text) => isColorAllowed() ? colorFn(text) : text;
196
- var clc = {
197
- bold: colorIfAllowed((text) => `\x1B[1m${text}\x1B[0m`),
198
- green: colorIfAllowed((text) => `\x1B[32m${text}\x1B[39m`),
199
- yellow: colorIfAllowed((text) => `\x1B[33m${text}\x1B[39m`),
200
- red: colorIfAllowed((text) => `\x1B[31m${text}\x1B[39m`),
201
- magentaBright: colorIfAllowed((text) => `\x1B[95m${text}\x1B[39m`),
202
- cyanBright: colorIfAllowed((text) => `\x1B[96m${text}\x1B[39m`)
203
- };
204
- var yellow = colorIfAllowed(
205
- (text) => `\x1B[38;5;3m${text}\x1B[39m`
206
- );
207
-
208
- // packages/core/src/logger/log-levels.mts
209
- var LOG_LEVELS = [
210
- "verbose",
211
- "debug",
212
- "log",
213
- "warn",
214
- "error",
215
- "fatal"
216
- ];
217
-
218
- // packages/core/src/logger/utils/is-log-level.util.mts
219
- function isLogLevel(maybeLogLevel) {
220
- return LOG_LEVELS.includes(maybeLogLevel);
221
- }
222
-
223
- // packages/core/src/logger/utils/filter-log-levelts.util.mts
224
- function filterLogLevels(parseableString = "") {
225
- const sanitizedString = parseableString.replaceAll(" ", "").toLowerCase();
226
- if (sanitizedString[0] === ">") {
227
- const orEqual = sanitizedString[1] === "=";
228
- const logLevelIndex = LOG_LEVELS.indexOf(
229
- sanitizedString.substring(orEqual ? 2 : 1)
230
- );
231
- if (logLevelIndex === -1) {
232
- throw new Error(`parse error (unknown log level): ${sanitizedString}`);
233
- }
234
- return LOG_LEVELS.slice(orEqual ? logLevelIndex : logLevelIndex + 1);
235
- } else if (sanitizedString.includes(",")) {
236
- return sanitizedString.split(",").filter(isLogLevel);
237
- }
238
- return isLogLevel(sanitizedString) ? [sanitizedString] : LOG_LEVELS;
239
- }
240
-
241
- // packages/core/src/logger/utils/is-log-level-enabled.mts
242
- var LOG_LEVEL_VALUES = {
243
- verbose: 0,
244
- debug: 1,
245
- log: 2,
246
- warn: 3,
247
- error: 4,
248
- fatal: 5
249
- };
250
- function isLogLevelEnabled(targetLevel, logLevels) {
251
- var _a;
252
- if (!logLevels || Array.isArray(logLevels) && (logLevels == null ? void 0 : logLevels.length) === 0) {
253
- return false;
254
- }
255
- if (logLevels.includes(targetLevel)) {
256
- return true;
257
- }
258
- const highestLogLevelValue = (_a = logLevels.map((level) => LOG_LEVEL_VALUES[level]).sort((a, b) => b - a)) == null ? void 0 : _a[0];
259
- const targetLevelValue = LOG_LEVEL_VALUES[targetLevel];
260
- return targetLevelValue >= highestLogLevelValue;
261
- }
262
-
263
- // packages/core/src/logger/utils/shared.utils.mts
264
- var isUndefined = (obj) => typeof obj === "undefined";
265
- var isObject = (fn) => !isNil(fn) && typeof fn === "object";
266
- var isPlainObject = (fn) => {
267
- if (!isObject(fn)) {
268
- return false;
269
- }
270
- const proto = Object.getPrototypeOf(fn);
271
- if (proto === null) {
272
- return true;
273
- }
274
- const ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
275
- return typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
276
- };
277
- var addLeadingSlash = (path) => path && typeof path === "string" ? path.charAt(0) !== "/" && path.substring(0, 2) !== "{/" ? "/" + path : path : "";
278
- var normalizePath = (path) => path ? path.startsWith("/") ? ("/" + path.replace(/\/+$/, "")).replace(/\/+/g, "/") : "/" + path.replace(/\/+$/, "") : "/";
279
- var stripEndSlash = (path) => path[path.length - 1] === "/" ? path.slice(0, path.length - 1) : path;
280
- var isFunction = (val) => typeof val === "function";
281
- var isString = (val) => typeof val === "string";
282
- var isNumber = (val) => typeof val === "number";
283
- var isConstructor = (val) => val === "constructor";
284
- var isNil = (val) => isUndefined(val) || val === null;
285
- var isEmpty = (array) => !(array && array.length > 0);
286
- var isSymbol = (val) => typeof val === "symbol";
287
-
288
- // packages/core/src/logger/console-logger.service.mts
289
- var import_util = require("util");
290
-
291
185
  // packages/core/src/service-locator/decorators/injectable.decorator.mts
292
186
  var import_common2 = require("@navios/common");
293
187
 
@@ -421,8 +315,8 @@ var ServiceLocatorEventBus = class {
421
315
  }
422
316
  listeners = /* @__PURE__ */ new Map();
423
317
  on(ns, event, listener) {
424
- var _a;
425
- (_a = this.logger) == null ? void 0 : _a.debug(`[ServiceLocatorEventBus]#on(): ns:${ns} event:${event}`);
318
+ var _a3;
319
+ (_a3 = this.logger) == null ? void 0 : _a3.debug(`[ServiceLocatorEventBus]#on(): ns:${ns} event:${event}`);
426
320
  if (!this.listeners.has(ns)) {
427
321
  this.listeners.set(ns, /* @__PURE__ */ new Map());
428
322
  }
@@ -432,9 +326,9 @@ var ServiceLocatorEventBus = class {
432
326
  }
433
327
  nsEvents.get(event).add(listener);
434
328
  return () => {
435
- var _a2;
329
+ var _a4;
436
330
  nsEvents.get(event).delete(listener);
437
- if (((_a2 = nsEvents.get(event)) == null ? void 0 : _a2.size) === 0) {
331
+ if (((_a4 = nsEvents.get(event)) == null ? void 0 : _a4.size) === 0) {
438
332
  nsEvents.delete(event);
439
333
  }
440
334
  if (nsEvents.size === 0) {
@@ -443,20 +337,20 @@ var ServiceLocatorEventBus = class {
443
337
  };
444
338
  }
445
339
  async emit(key, event) {
446
- var _a, _b, _c;
340
+ var _a3, _b, _c;
447
341
  if (!this.listeners.has(key)) {
448
342
  return;
449
343
  }
450
344
  const events = this.listeners.get(key);
451
345
  const preEvent = `pre:${event}`;
452
346
  const postEvent = `post:${event}`;
453
- (_a = this.logger) == null ? void 0 : _a.debug(`[ServiceLocatorEventBus]#emit(): ${key}:${preEvent}`);
347
+ (_a3 = this.logger) == null ? void 0 : _a3.debug(`[ServiceLocatorEventBus]#emit(): ${key}:${preEvent}`);
454
348
  await Promise.allSettled(
455
349
  [...events.get(preEvent) ?? []].map((listener) => listener(preEvent))
456
350
  ).then((results) => {
457
351
  results.filter((result) => result.status === "rejected").forEach((result) => {
458
- var _a2;
459
- (_a2 = this.logger) == null ? void 0 : _a2.warn(
352
+ var _a4;
353
+ (_a4 = this.logger) == null ? void 0 : _a4.warn(
460
354
  `[ServiceLocatorEventBus]#emit(): ${key}:${preEvent} rejected with`,
461
355
  result.reason
462
356
  );
@@ -467,8 +361,8 @@ var ServiceLocatorEventBus = class {
467
361
  [...events.get(event) ?? []].map((listener) => listener(event))
468
362
  ).then((results) => {
469
363
  const res2 = results.filter((result) => result.status === "rejected").map((result) => {
470
- var _a2;
471
- (_a2 = this.logger) == null ? void 0 : _a2.warn(
364
+ var _a4;
365
+ (_a4 = this.logger) == null ? void 0 : _a4.warn(
472
366
  `[ServiceLocatorEventBus]#emit(): ${key}:${event} rejected with`,
473
367
  result.reason
474
368
  );
@@ -484,8 +378,8 @@ var ServiceLocatorEventBus = class {
484
378
  [...events.get(postEvent) ?? []].map((listener) => listener(postEvent))
485
379
  ).then((results) => {
486
380
  results.filter((result) => result.status === "rejected").forEach((result) => {
487
- var _a2;
488
- (_a2 = this.logger) == null ? void 0 : _a2.warn(
381
+ var _a4;
382
+ (_a4 = this.logger) == null ? void 0 : _a4.warn(
489
383
  `[ServiceLocatorEventBus]#emit(): ${key}:${postEvent} rejected with`,
490
384
  result.reason
491
385
  );
@@ -516,13 +410,13 @@ var ServiceLocatorManager = class {
516
410
  }
517
411
  instancesHolders = /* @__PURE__ */ new Map();
518
412
  get(name2) {
519
- var _a, _b, _c;
413
+ var _a3, _b, _c;
520
414
  const holder = this.instancesHolders.get(name2);
521
415
  if (holder) {
522
416
  if (holder.ttl !== Infinity) {
523
417
  const now = Date.now();
524
418
  if (now - holder.createdAt > holder.ttl) {
525
- (_a = this.logger) == null ? void 0 : _a.log(
419
+ (_a3 = this.logger) == null ? void 0 : _a3.log(
526
420
  `[ServiceLocatorManager]#getInstanceHolder() TTL expired for ${holder.name}`
527
421
  );
528
422
  return [new InstanceExpired(holder.name), holder];
@@ -597,14 +491,15 @@ var ServiceLocator = class {
597
491
  destroyPromise: null,
598
492
  creationPromise: null
599
493
  });
494
+ this.eventBus.emit(instanceName, "create");
600
495
  }
601
496
  removeInstance(token) {
602
497
  const instanceName = this.getInstanceIdentifier(token, void 0);
603
498
  return this.invalidate(instanceName);
604
499
  }
605
500
  registerAbstractFactory(token, factory, type = "Singleton" /* Singleton */) {
606
- var _a;
607
- (_a = this.logger) == null ? void 0 : _a.log(
501
+ var _a3;
502
+ (_a3 = this.logger) == null ? void 0 : _a3.log(
608
503
  `[ServiceLocator]#registerAbstractFactory(): Registering abstract factory for ${name}`
609
504
  );
610
505
  if (type === "Instance" /* Instance */) {
@@ -616,7 +511,7 @@ var ServiceLocator = class {
616
511
  }
617
512
  }
618
513
  resolveTokenArgs(token, args) {
619
- var _a, _b;
514
+ var _a3, _b;
620
515
  let realArgs = args;
621
516
  if (token instanceof BoundInjectionToken) {
622
517
  realArgs = token.value;
@@ -630,7 +525,7 @@ var ServiceLocator = class {
630
525
  if (!token.schema) {
631
526
  return [void 0, realArgs];
632
527
  }
633
- const validatedArgs = (_a = token.schema) == null ? void 0 : _a.safeParse(realArgs);
528
+ const validatedArgs = (_a3 = token.schema) == null ? void 0 : _a3.safeParse(realArgs);
634
529
  if (validatedArgs && !validatedArgs.success) {
635
530
  (_b = this.logger) == null ? void 0 : _b.error(
636
531
  `[ServiceLocator]#getInstance(): Error validating args for ${token.name.toString()}`,
@@ -648,7 +543,7 @@ var ServiceLocator = class {
648
543
  return this.makeInstanceName(token, realArgs);
649
544
  }
650
545
  async getInstance(token, args) {
651
- var _a, _b;
546
+ var _a3, _b;
652
547
  const [err, realArgs] = this.resolveTokenArgs(token, args);
653
548
  if (err instanceof UnknownError) {
654
549
  throw err;
@@ -668,7 +563,7 @@ var ServiceLocator = class {
668
563
  }
669
564
  switch (error.code) {
670
565
  case "InstanceDestroying" /* InstanceDestroying */:
671
- (_a = this.logger) == null ? void 0 : _a.log(
566
+ (_a3 = this.logger) == null ? void 0 : _a3.log(
672
567
  `[ServiceLocator]#getInstance() TTL expired for ${holder == null ? void 0 : holder.name}`
673
568
  );
674
569
  await (holder == null ? void 0 : holder.destroyPromise);
@@ -694,15 +589,15 @@ var ServiceLocator = class {
694
589
  return instance;
695
590
  }
696
591
  notifyListeners(name2, event = "create") {
697
- var _a;
698
- (_a = this.logger) == null ? void 0 : _a.log(
592
+ var _a3;
593
+ (_a3 = this.logger) == null ? void 0 : _a3.log(
699
594
  `[ServiceLocator]#notifyListeners() Notifying listeners for ${name2} with event ${event}`
700
595
  );
701
596
  return this.eventBus.emit(name2, event);
702
597
  }
703
598
  async createInstance(instanceName, token, args) {
704
- var _a;
705
- (_a = this.logger) == null ? void 0 : _a.log(
599
+ var _a3;
600
+ (_a3 = this.logger) == null ? void 0 : _a3.log(
706
601
  `[ServiceLocator]#createInstance() Creating instance for ${instanceName}`
707
602
  );
708
603
  let realToken = token instanceof BoundInjectionToken || token instanceof FactoryInjectionToken ? token.token : token;
@@ -717,8 +612,8 @@ var ServiceLocator = class {
717
612
  }
718
613
  }
719
614
  async createInstanceFromAbstractFactory(instanceName, token, args) {
720
- var _a;
721
- (_a = this.logger) == null ? void 0 : _a.log(
615
+ var _a3;
616
+ (_a3 = this.logger) == null ? void 0 : _a3.log(
722
617
  `[ServiceLocator]#createInstanceFromAbstractFactory(): Creating instance for ${instanceName} from abstract factory`
723
618
  );
724
619
  const ctx = this.createContextForAbstractFactory(instanceName);
@@ -738,14 +633,14 @@ var ServiceLocator = class {
738
633
  kind: "abstractFactory" /* AbstractFactory */,
739
634
  // @ts-expect-error TS2322 This is correct type
740
635
  creationPromise: abstractFactory(ctx, args).then(async (instance) => {
741
- var _a2;
636
+ var _a4;
742
637
  holder.instance = instance;
743
638
  holder.status = "created" /* Created */;
744
639
  holder.deps = ctx.getDependencies();
745
640
  holder.destroyListeners = ctx.getDestroyListeners();
746
641
  holder.ttl = ctx.getTtl();
747
642
  if (holder.deps.length > 0) {
748
- (_a2 = this.logger) == null ? void 0 : _a2.log(
643
+ (_a4 = this.logger) == null ? void 0 : _a4.log(
749
644
  `[ServiceLocator]#createInstanceFromAbstractFactory(): Adding subscriptions for ${instanceName} dependencies for their invalidations: ${holder.deps.join(
750
645
  ", "
751
646
  )}`
@@ -766,8 +661,8 @@ var ServiceLocator = class {
766
661
  await this.notifyListeners(instanceName);
767
662
  return [void 0, instance];
768
663
  }).catch((error) => {
769
- var _a2;
770
- (_a2 = this.logger) == null ? void 0 : _a2.error(
664
+ var _a4;
665
+ (_a4 = this.logger) == null ? void 0 : _a4.error(
771
666
  `[ServiceLocator]#createInstanceFromAbstractFactory(): Error creating instance for ${instanceName}`,
772
667
  error
773
668
  );
@@ -844,8 +739,8 @@ var ServiceLocator = class {
844
739
  return holder.instance;
845
740
  }
846
741
  invalidate(service, round = 1) {
847
- var _a, _b, _c, _d, _e;
848
- (_a = this.logger) == null ? void 0 : _a.log(
742
+ var _a3, _b, _c, _d, _e;
743
+ (_a3 = this.logger) == null ? void 0 : _a3.log(
849
744
  `[ServiceLocator]#invalidate(): Starting Invalidating process of ${service}`
850
745
  );
851
746
  const toInvalidate = this.manager.filter(
@@ -866,9 +761,9 @@ var ServiceLocator = class {
866
761
  );
867
762
  promises.push(
868
763
  (_d = holder.creationPromise) == null ? void 0 : _d.then(() => {
869
- var _a2;
764
+ var _a4;
870
765
  if (round > 3) {
871
- (_a2 = this.logger) == null ? void 0 : _a2.error(
766
+ (_a4 = this.logger) == null ? void 0 : _a4.error(
872
767
  `[ServiceLocator]#invalidate(): ${key} creation is triggering a new invalidation round, but it is still not created`
873
768
  );
874
769
  return;
@@ -895,9 +790,9 @@ var ServiceLocator = class {
895
790
  async ready() {
896
791
  return Promise.all(
897
792
  Array.from(this.manager.filter(() => true)).map(([, holder]) => {
898
- var _a;
793
+ var _a3;
899
794
  if (holder.status === "creating" /* Creating */) {
900
- return (_a = holder.creationPromise) == null ? void 0 : _a.then(() => null);
795
+ return (_a3 = holder.creationPromise) == null ? void 0 : _a3.then(() => null);
901
796
  }
902
797
  if (holder.status === "destroying" /* Destroying */) {
903
798
  return holder.destroyPromise.then(() => null);
@@ -1058,7 +953,7 @@ var InjectableType = /* @__PURE__ */ ((InjectableType2) => {
1058
953
  InjectableType2["Factory"] = "Factory";
1059
954
  return InjectableType2;
1060
955
  })(InjectableType || {});
1061
- var InjectableTokenMeta = Symbol("InjectableTokenMeta");
956
+ var InjectableTokenMeta = Symbol.for("InjectableTokenMeta");
1062
957
  function Injectable({
1063
958
  scope = "Singleton" /* Singleton */,
1064
959
  type = "Class" /* Class */,
@@ -1172,117 +1067,927 @@ function override(token, target) {
1172
1067
  };
1173
1068
  }
1174
1069
 
1175
- // packages/core/src/logger/console-logger.service.mts
1176
- var DEFAULT_DEPTH = 5;
1177
- var DEFAULT_LOG_LEVELS = [
1178
- "log",
1179
- "error",
1180
- "warn",
1181
- "debug",
1182
- "verbose",
1183
- "fatal"
1184
- ];
1185
- var dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
1186
- year: "numeric",
1187
- hour: "numeric",
1188
- minute: "numeric",
1189
- second: "numeric",
1190
- day: "2-digit",
1191
- month: "2-digit"
1192
- });
1193
- var _ConsoleLogger_decorators, _init;
1194
- _ConsoleLogger_decorators = [Injectable()];
1195
- var _ConsoleLogger = class _ConsoleLogger {
1196
- /**
1197
- * The options of the logger.
1198
- */
1199
- options;
1200
- /**
1201
- * The context of the logger (can be set manually or automatically inferred).
1202
- */
1203
- context;
1204
- /**
1205
- * The original context of the logger (set in the constructor).
1206
- */
1207
- originalContext;
1208
- /**
1209
- * The options used for the "inspect" method.
1210
- */
1211
- inspectOptions;
1212
- /**
1213
- * The last timestamp at which the log message was printed.
1214
- */
1215
- static lastTimestampAt;
1216
- constructor(contextOrOptions, options) {
1217
- let [context, opts] = isString(contextOrOptions) ? [contextOrOptions, options] : options ? [void 0, options] : [contextOrOptions == null ? void 0 : contextOrOptions.context, contextOrOptions];
1218
- opts = opts ?? {};
1219
- opts.logLevels ??= DEFAULT_LOG_LEVELS;
1220
- opts.colors ??= opts.colors ?? (opts.json ? false : true);
1221
- opts.prefix ??= "Navios";
1222
- this.options = opts;
1223
- this.inspectOptions = this.getInspectOptions();
1224
- if (context) {
1225
- this.context = context;
1226
- this.originalContext = context;
1070
+ // packages/core/src/adapters/stream-adapter.service.mts
1071
+ var StreamAdapterToken = InjectionToken.create(
1072
+ Symbol.for("StreamAdapterService")
1073
+ );
1074
+ var _StreamAdapterService_decorators, _init;
1075
+ _StreamAdapterService_decorators = [Injectable({
1076
+ token: StreamAdapterToken
1077
+ })];
1078
+ var StreamAdapterService = class {
1079
+ hasSchema(handlerMetadata) {
1080
+ const config = handlerMetadata.config;
1081
+ return !!config.requestSchema || !!config.querySchema;
1082
+ }
1083
+ prepareArguments(handlerMetadata) {
1084
+ const config = handlerMetadata.config;
1085
+ const getters = [];
1086
+ if (config.querySchema) {
1087
+ getters.push((target, request) => {
1088
+ target.params = request.query;
1089
+ });
1227
1090
  }
1228
- }
1229
- log(message, ...optionalParams) {
1230
- if (!this.isLevelEnabled("log")) {
1231
- return;
1091
+ if (config.requestSchema) {
1092
+ getters.push((target, request) => {
1093
+ target.data = request.body;
1094
+ });
1232
1095
  }
1233
- const { messages, context } = this.getContextAndMessagesToPrint([
1234
- message,
1235
- ...optionalParams
1236
- ]);
1237
- this.printMessages(messages, context, "log");
1238
- }
1239
- error(message, ...optionalParams) {
1240
- if (!this.isLevelEnabled("error")) {
1241
- return;
1096
+ if (config.url.includes("$")) {
1097
+ getters.push((target, request) => {
1098
+ target.urlParams = request.params;
1099
+ });
1242
1100
  }
1243
- const { messages, context, stack } = this.getContextAndStackAndMessagesToPrint([message, ...optionalParams]);
1244
- this.printMessages(messages, context, "error", "stderr", stack);
1245
- this.printStackTrace(stack);
1101
+ return getters;
1102
+ }
1103
+ provideHandler(controller, executionContext, handlerMetadata) {
1104
+ const getters = this.prepareArguments(handlerMetadata);
1105
+ const formatArguments = async (request) => {
1106
+ const argument = {};
1107
+ const promises = [];
1108
+ for (const getter of getters) {
1109
+ const res = getter(argument, request);
1110
+ if (res instanceof Promise) {
1111
+ promises.push(res);
1112
+ }
1113
+ }
1114
+ await Promise.all(promises);
1115
+ return argument;
1116
+ };
1117
+ return async function(request, reply) {
1118
+ const controllerInstance = await inject(controller);
1119
+ const argument = await formatArguments(request);
1120
+ await controllerInstance[handlerMetadata.classMethod](argument, reply);
1121
+ };
1246
1122
  }
1247
- warn(message, ...optionalParams) {
1248
- if (!this.isLevelEnabled("warn")) {
1249
- return;
1123
+ provideSchema(handlerMetadata) {
1124
+ const schema = {};
1125
+ const { querySchema, requestSchema } = handlerMetadata.config;
1126
+ if (querySchema) {
1127
+ schema.querystring = querySchema;
1250
1128
  }
1251
- const { messages, context } = this.getContextAndMessagesToPrint([
1252
- message,
1253
- ...optionalParams
1254
- ]);
1255
- this.printMessages(messages, context, "warn");
1129
+ if (requestSchema) {
1130
+ schema.body = requestSchema;
1131
+ }
1132
+ return schema;
1256
1133
  }
1257
- debug(message, ...optionalParams) {
1258
- if (!this.isLevelEnabled("debug")) {
1259
- return;
1134
+ };
1135
+ _init = __decoratorStart(null);
1136
+ StreamAdapterService = __decorateElement(_init, 0, "StreamAdapterService", _StreamAdapterService_decorators, StreamAdapterService);
1137
+ __runInitializers(_init, 1, StreamAdapterService);
1138
+
1139
+ // packages/core/src/adapters/endpoint-adapter.service.mts
1140
+ var EndpointAdapterToken = InjectionToken.create(
1141
+ Symbol.for("EndpointAdapterService")
1142
+ );
1143
+ var _EndpointAdapterService_decorators, _init2, _a;
1144
+ _EndpointAdapterService_decorators = [Injectable({
1145
+ token: EndpointAdapterToken
1146
+ })];
1147
+ var EndpointAdapterService = class extends (_a = StreamAdapterService) {
1148
+ hasSchema(handlerMetadata) {
1149
+ const config = handlerMetadata.config;
1150
+ return super.hasSchema(handlerMetadata) || !!config.responseSchema;
1151
+ }
1152
+ provideSchema(handlerMetadata) {
1153
+ const config = handlerMetadata.config;
1154
+ const schema = super.provideSchema(handlerMetadata);
1155
+ if (config.responseSchema) {
1156
+ schema.response = {
1157
+ 200: config.responseSchema
1158
+ };
1260
1159
  }
1261
- const { messages, context } = this.getContextAndMessagesToPrint([
1262
- message,
1263
- ...optionalParams
1264
- ]);
1265
- this.printMessages(messages, context, "debug");
1160
+ return schema;
1266
1161
  }
1267
- verbose(message, ...optionalParams) {
1268
- if (!this.isLevelEnabled("verbose")) {
1269
- return;
1162
+ provideHandler(controller, executionContext, handlerMetadata) {
1163
+ const getters = this.prepareArguments(handlerMetadata);
1164
+ const formatArguments = async (request) => {
1165
+ const argument = {};
1166
+ const promises = [];
1167
+ for (const getter of getters) {
1168
+ const res = getter(argument, request);
1169
+ if (res instanceof Promise) {
1170
+ promises.push(res);
1171
+ }
1172
+ }
1173
+ await Promise.all(promises);
1174
+ return argument;
1175
+ };
1176
+ return async function(request, reply) {
1177
+ const controllerInstance = await inject(controller);
1178
+ const argument = await formatArguments(request);
1179
+ const result = await controllerInstance[handlerMetadata.classMethod](argument);
1180
+ reply.status(handlerMetadata.successStatusCode).headers(handlerMetadata.headers).send(result);
1181
+ };
1182
+ }
1183
+ };
1184
+ _init2 = __decoratorStart(_a);
1185
+ EndpointAdapterService = __decorateElement(_init2, 0, "EndpointAdapterService", _EndpointAdapterService_decorators, EndpointAdapterService);
1186
+ __runInitializers(_init2, 1, EndpointAdapterService);
1187
+
1188
+ // packages/core/src/adapters/multipart-adapter.service.mts
1189
+ var import_zod2 = require("zod");
1190
+ var MultipartAdapterToken = InjectionToken.create(
1191
+ Symbol.for("MultipartAdapterService")
1192
+ );
1193
+ var _MultipartAdapterService_decorators, _init3, _a2;
1194
+ _MultipartAdapterService_decorators = [Injectable({
1195
+ token: MultipartAdapterToken
1196
+ })];
1197
+ var MultipartAdapterService = class extends (_a2 = EndpointAdapterService) {
1198
+ prepareArguments(handlerMetadata) {
1199
+ const config = handlerMetadata.config;
1200
+ const getters = [];
1201
+ if (config.querySchema) {
1202
+ getters.push((target, request) => {
1203
+ target.params = request.query;
1204
+ });
1270
1205
  }
1271
- const { messages, context } = this.getContextAndMessagesToPrint([
1272
- message,
1273
- ...optionalParams
1274
- ]);
1275
- this.printMessages(messages, context, "verbose");
1206
+ if (config.url.includes("$")) {
1207
+ getters.push((target, request) => {
1208
+ target.urlParams = request.params;
1209
+ });
1210
+ }
1211
+ const requestSchema = config.requestSchema;
1212
+ const shape = requestSchema._def.shape();
1213
+ const structure = this.analyzeSchema(shape);
1214
+ getters.push(async (target, request) => {
1215
+ const req = {};
1216
+ for await (const part of request.parts()) {
1217
+ await this.populateRequest(structure, part, req);
1218
+ }
1219
+ target.data = requestSchema.parse(req);
1220
+ });
1221
+ return getters;
1276
1222
  }
1277
- fatal(message, ...optionalParams) {
1278
- if (!this.isLevelEnabled("fatal")) {
1279
- return;
1223
+ async populateRequest(structure, part, req) {
1224
+ const { isArray, isObject: isObject2 } = structure[part.fieldname] ?? {};
1225
+ if (isArray && !req[part.fieldname]) {
1226
+ req[part.fieldname] = [];
1227
+ }
1228
+ let value;
1229
+ if (part.type === "file") {
1230
+ value = new File([await part.toBuffer()], part.filename, {
1231
+ type: part.mimetype
1232
+ });
1233
+ } else {
1234
+ value = part.value;
1235
+ if (isObject2 && typeof value === "string") {
1236
+ value = JSON.parse(value);
1237
+ }
1238
+ }
1239
+ if (isArray) {
1240
+ req[part.fieldname].push(value);
1241
+ } else {
1242
+ req[part.fieldname] = value;
1280
1243
  }
1281
- const { messages, context } = this.getContextAndMessagesToPrint([
1282
- message,
1283
- ...optionalParams
1284
- ]);
1285
- this.printMessages(messages, context, "fatal");
1244
+ }
1245
+ analyzeSchema(shape) {
1246
+ return Object.keys(shape).reduce(
1247
+ (target, key) => {
1248
+ let schema = shape[key];
1249
+ const isOptional = schema instanceof import_zod2.ZodOptional;
1250
+ if (isOptional) {
1251
+ schema = schema.unwrap();
1252
+ }
1253
+ const isArray = schema instanceof import_zod2.ZodArray;
1254
+ if (isArray) {
1255
+ schema = schema.element;
1256
+ }
1257
+ const isObject2 = schema instanceof import_zod2.ZodObject;
1258
+ return {
1259
+ ...target,
1260
+ [key]: {
1261
+ isArray,
1262
+ isOptional,
1263
+ isObject: isObject2
1264
+ }
1265
+ };
1266
+ },
1267
+ {}
1268
+ );
1269
+ }
1270
+ provideSchema(handlerMetadata) {
1271
+ const schema = {};
1272
+ const { querySchema, responseSchema } = handlerMetadata.config;
1273
+ if (querySchema) {
1274
+ schema.querystring = querySchema;
1275
+ }
1276
+ if (responseSchema) {
1277
+ schema.response = {
1278
+ 200: responseSchema
1279
+ };
1280
+ }
1281
+ return schema;
1282
+ }
1283
+ };
1284
+ _init3 = __decoratorStart(_a2);
1285
+ MultipartAdapterService = __decorateElement(_init3, 0, "MultipartAdapterService", _MultipartAdapterService_decorators, MultipartAdapterService);
1286
+ __runInitializers(_init3, 1, MultipartAdapterService);
1287
+
1288
+ // packages/core/src/config/utils/helpers.mts
1289
+ var import_node_process = require("process");
1290
+ function envInt(key, defaultValue) {
1291
+ const envKey = import_node_process.env[key] || process.env[key];
1292
+ return envKey ? parseInt(envKey, 10) : defaultValue;
1293
+ }
1294
+ function envString(key, defaultValue) {
1295
+ return import_node_process.env[key] || process.env[key] || defaultValue || void 0;
1296
+ }
1297
+
1298
+ // packages/core/src/config/config.provider.mts
1299
+ var import_zod4 = require("zod");
1300
+
1301
+ // packages/core/src/logger/utils/cli-colors.util.mts
1302
+ var isColorAllowed = () => !process.env.NO_COLOR;
1303
+ var colorIfAllowed = (colorFn) => (text) => isColorAllowed() ? colorFn(text) : text;
1304
+ var clc = {
1305
+ bold: colorIfAllowed((text) => `\x1B[1m${text}\x1B[0m`),
1306
+ green: colorIfAllowed((text) => `\x1B[32m${text}\x1B[39m`),
1307
+ yellow: colorIfAllowed((text) => `\x1B[33m${text}\x1B[39m`),
1308
+ red: colorIfAllowed((text) => `\x1B[31m${text}\x1B[39m`),
1309
+ magentaBright: colorIfAllowed((text) => `\x1B[95m${text}\x1B[39m`),
1310
+ cyanBright: colorIfAllowed((text) => `\x1B[96m${text}\x1B[39m`)
1311
+ };
1312
+ var yellow = colorIfAllowed(
1313
+ (text) => `\x1B[38;5;3m${text}\x1B[39m`
1314
+ );
1315
+
1316
+ // packages/core/src/logger/log-levels.mts
1317
+ var LOG_LEVELS = [
1318
+ "verbose",
1319
+ "debug",
1320
+ "log",
1321
+ "warn",
1322
+ "error",
1323
+ "fatal"
1324
+ ];
1325
+
1326
+ // packages/core/src/logger/utils/is-log-level.util.mts
1327
+ function isLogLevel(maybeLogLevel) {
1328
+ return LOG_LEVELS.includes(maybeLogLevel);
1329
+ }
1330
+
1331
+ // packages/core/src/logger/utils/filter-log-levelts.util.mts
1332
+ function filterLogLevels(parseableString = "") {
1333
+ const sanitizedString = parseableString.replaceAll(" ", "").toLowerCase();
1334
+ if (sanitizedString[0] === ">") {
1335
+ const orEqual = sanitizedString[1] === "=";
1336
+ const logLevelIndex = LOG_LEVELS.indexOf(
1337
+ sanitizedString.substring(orEqual ? 2 : 1)
1338
+ );
1339
+ if (logLevelIndex === -1) {
1340
+ throw new Error(`parse error (unknown log level): ${sanitizedString}`);
1341
+ }
1342
+ return LOG_LEVELS.slice(orEqual ? logLevelIndex : logLevelIndex + 1);
1343
+ } else if (sanitizedString.includes(",")) {
1344
+ return sanitizedString.split(",").filter(isLogLevel);
1345
+ }
1346
+ return isLogLevel(sanitizedString) ? [sanitizedString] : LOG_LEVELS;
1347
+ }
1348
+
1349
+ // packages/core/src/logger/utils/is-log-level-enabled.mts
1350
+ var LOG_LEVEL_VALUES = {
1351
+ verbose: 0,
1352
+ debug: 1,
1353
+ log: 2,
1354
+ warn: 3,
1355
+ error: 4,
1356
+ fatal: 5
1357
+ };
1358
+ function isLogLevelEnabled(targetLevel, logLevels) {
1359
+ var _a3;
1360
+ if (!logLevels || Array.isArray(logLevels) && (logLevels == null ? void 0 : logLevels.length) === 0) {
1361
+ return false;
1362
+ }
1363
+ if (logLevels.includes(targetLevel)) {
1364
+ return true;
1365
+ }
1366
+ const highestLogLevelValue = (_a3 = logLevels.map((level) => LOG_LEVEL_VALUES[level]).sort((a, b) => b - a)) == null ? void 0 : _a3[0];
1367
+ const targetLevelValue = LOG_LEVEL_VALUES[targetLevel];
1368
+ return targetLevelValue >= highestLogLevelValue;
1369
+ }
1370
+
1371
+ // packages/core/src/logger/utils/shared.utils.mts
1372
+ var isUndefined = (obj) => typeof obj === "undefined";
1373
+ var isObject = (fn) => !isNil(fn) && typeof fn === "object";
1374
+ var isPlainObject = (fn) => {
1375
+ if (!isObject(fn)) {
1376
+ return false;
1377
+ }
1378
+ const proto = Object.getPrototypeOf(fn);
1379
+ if (proto === null) {
1380
+ return true;
1381
+ }
1382
+ const ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
1383
+ return typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
1384
+ };
1385
+ var addLeadingSlash = (path) => path && typeof path === "string" ? path.charAt(0) !== "/" && path.substring(0, 2) !== "{/" ? "/" + path : path : "";
1386
+ var normalizePath = (path) => path ? path.startsWith("/") ? ("/" + path.replace(/\/+$/, "")).replace(/\/+/g, "/") : "/" + path.replace(/\/+$/, "") : "/";
1387
+ var stripEndSlash = (path) => path[path.length - 1] === "/" ? path.slice(0, path.length - 1) : path;
1388
+ var isFunction = (val) => typeof val === "function";
1389
+ var isString = (val) => typeof val === "string";
1390
+ var isNumber = (val) => typeof val === "number";
1391
+ var isConstructor = (val) => val === "constructor";
1392
+ var isNil = (val) => isUndefined(val) || val === null;
1393
+ var isEmpty = (array) => !(array && array.length > 0);
1394
+ var isSymbol = (val) => typeof val === "symbol";
1395
+
1396
+ // packages/core/src/logger/console-logger.service.mts
1397
+ var import_util = require("util");
1398
+
1399
+ // packages/core/src/tokens/application.token.mts
1400
+ var ApplicationInjectionToken = "ApplicationInjectionToken";
1401
+ var Application = InjectionToken.create(
1402
+ ApplicationInjectionToken
1403
+ );
1404
+
1405
+ // packages/core/src/metadata/handler.metadata.mts
1406
+ var EndpointMetadataKey = Symbol("EndpointMetadataKey");
1407
+ function getAllEndpointMetadata(context) {
1408
+ if (context.metadata) {
1409
+ const metadata = context.metadata[EndpointMetadataKey];
1410
+ if (metadata) {
1411
+ return metadata;
1412
+ } else {
1413
+ context.metadata[EndpointMetadataKey] = /* @__PURE__ */ new Set();
1414
+ return context.metadata[EndpointMetadataKey];
1415
+ }
1416
+ }
1417
+ throw new Error("[Navios] Wrong environment.");
1418
+ }
1419
+ function getEndpointMetadata(target, context) {
1420
+ if (context.metadata) {
1421
+ const metadata = getAllEndpointMetadata(context);
1422
+ if (metadata) {
1423
+ const endpointMetadata = Array.from(metadata).find(
1424
+ (item) => item.classMethod === target.name
1425
+ );
1426
+ if (endpointMetadata) {
1427
+ return endpointMetadata;
1428
+ } else {
1429
+ const newMetadata = {
1430
+ classMethod: target.name,
1431
+ url: "",
1432
+ successStatusCode: 200,
1433
+ adapterToken: null,
1434
+ headers: {},
1435
+ httpMethod: "GET",
1436
+ // @ts-expect-error We are using a generic type here
1437
+ config: null,
1438
+ guards: /* @__PURE__ */ new Set(),
1439
+ customAttributes: /* @__PURE__ */ new Map()
1440
+ };
1441
+ metadata.add(newMetadata);
1442
+ return newMetadata;
1443
+ }
1444
+ }
1445
+ }
1446
+ throw new Error("[Navios] Wrong environment.");
1447
+ }
1448
+
1449
+ // packages/core/src/metadata/controller.metadata.mts
1450
+ var ControllerMetadataKey = Symbol("ControllerMetadataKey");
1451
+ function getControllerMetadata(target, context) {
1452
+ if (context.metadata) {
1453
+ const metadata = context.metadata[ControllerMetadataKey];
1454
+ if (metadata) {
1455
+ return metadata;
1456
+ } else {
1457
+ const endpointsMetadata = getAllEndpointMetadata(context);
1458
+ const newMetadata = {
1459
+ endpoints: endpointsMetadata,
1460
+ guards: /* @__PURE__ */ new Set(),
1461
+ customAttributes: /* @__PURE__ */ new Map()
1462
+ };
1463
+ context.metadata[ControllerMetadataKey] = newMetadata;
1464
+ target[ControllerMetadataKey] = newMetadata;
1465
+ return newMetadata;
1466
+ }
1467
+ }
1468
+ throw new Error("[Navios] Wrong environment.");
1469
+ }
1470
+ function extractControllerMetadata(target) {
1471
+ const metadata = target[ControllerMetadataKey];
1472
+ if (!metadata) {
1473
+ throw new Error(
1474
+ "[Navios] Controller metadata not found. Make sure to use @Controller decorator."
1475
+ );
1476
+ }
1477
+ return metadata;
1478
+ }
1479
+ function hasControllerMetadata(target) {
1480
+ const metadata = target[ControllerMetadataKey];
1481
+ return !!metadata;
1482
+ }
1483
+
1484
+ // packages/core/src/metadata/module.metadata.mts
1485
+ var ModuleMetadataKey = Symbol("ControllerMetadataKey");
1486
+ function getModuleMetadata(target, context) {
1487
+ if (context.metadata) {
1488
+ const metadata = context.metadata[ModuleMetadataKey];
1489
+ if (metadata) {
1490
+ return metadata;
1491
+ } else {
1492
+ const newMetadata = {
1493
+ controllers: /* @__PURE__ */ new Set(),
1494
+ imports: /* @__PURE__ */ new Set(),
1495
+ guards: /* @__PURE__ */ new Set(),
1496
+ customAttributes: /* @__PURE__ */ new Map()
1497
+ };
1498
+ context.metadata[ModuleMetadataKey] = newMetadata;
1499
+ target[ModuleMetadataKey] = newMetadata;
1500
+ return newMetadata;
1501
+ }
1502
+ }
1503
+ throw new Error("[Navios] Wrong environment.");
1504
+ }
1505
+ function extractModuleMetadata(target) {
1506
+ const metadata = target[ModuleMetadataKey];
1507
+ if (!metadata) {
1508
+ throw new Error(
1509
+ `[Navios] Module metadata not found for ${target.name}. Make sure to use @Module decorator.`
1510
+ );
1511
+ }
1512
+ return metadata;
1513
+ }
1514
+ function hasModuleMetadata(target) {
1515
+ return !!target[ModuleMetadataKey];
1516
+ }
1517
+
1518
+ // packages/core/src/services/execution-context.mts
1519
+ var ExecutionContext = class {
1520
+ constructor(module2, controller, handler) {
1521
+ this.module = module2;
1522
+ this.controller = controller;
1523
+ this.handler = handler;
1524
+ }
1525
+ request;
1526
+ reply;
1527
+ getModule() {
1528
+ return this.module;
1529
+ }
1530
+ getController() {
1531
+ return this.controller;
1532
+ }
1533
+ getHandler() {
1534
+ return this.handler;
1535
+ }
1536
+ getRequest() {
1537
+ if (!this.request) {
1538
+ throw new Error(
1539
+ "[Navios] Request is not set. Make sure to set it before using it."
1540
+ );
1541
+ }
1542
+ return this.request;
1543
+ }
1544
+ getReply() {
1545
+ if (!this.reply) {
1546
+ throw new Error(
1547
+ "[Navios] Reply is not set. Make sure to set it before using it."
1548
+ );
1549
+ }
1550
+ return this.reply;
1551
+ }
1552
+ provideRequest(request) {
1553
+ this.request = request;
1554
+ }
1555
+ provideReply(reply) {
1556
+ this.reply = reply;
1557
+ }
1558
+ };
1559
+
1560
+ // packages/core/src/exceptions/http.exception.mts
1561
+ var HttpException = class {
1562
+ constructor(statusCode, response, error) {
1563
+ this.statusCode = statusCode;
1564
+ this.response = response;
1565
+ this.error = error;
1566
+ }
1567
+ };
1568
+
1569
+ // packages/core/src/exceptions/bad-request.exception.mts
1570
+ var BadRequestException = class extends HttpException {
1571
+ constructor(message) {
1572
+ super(400, message);
1573
+ }
1574
+ };
1575
+
1576
+ // packages/core/src/exceptions/forbidden.exception.mts
1577
+ var ForbiddenException = class extends HttpException {
1578
+ constructor(message) {
1579
+ super(403, message);
1580
+ }
1581
+ };
1582
+
1583
+ // packages/core/src/exceptions/internal-server-error.exception.mts
1584
+ var InternalServerErrorException = class extends HttpException {
1585
+ constructor(message, error) {
1586
+ super(500, message, error);
1587
+ }
1588
+ };
1589
+
1590
+ // packages/core/src/exceptions/not-found.exception.mts
1591
+ var NotFoundException = class extends HttpException {
1592
+ constructor(response, error) {
1593
+ super(404, response, error);
1594
+ this.response = response;
1595
+ this.error = error;
1596
+ }
1597
+ };
1598
+
1599
+ // packages/core/src/exceptions/unauthorized.exception.mts
1600
+ var UnauthorizedException = class extends HttpException {
1601
+ constructor(message, error) {
1602
+ super(401, message, error);
1603
+ }
1604
+ };
1605
+
1606
+ // packages/core/src/exceptions/conflict.exception.mts
1607
+ var ConflictException = class extends HttpException {
1608
+ constructor(message, error) {
1609
+ super(409, message, error);
1610
+ }
1611
+ };
1612
+
1613
+ // packages/core/src/services/guard-runner.service.mts
1614
+ var _GuardRunnerService_decorators, _init4;
1615
+ _GuardRunnerService_decorators = [Injectable()];
1616
+ var GuardRunnerService = class {
1617
+ async runGuards(allGuards, executionContext) {
1618
+ let canActivate = true;
1619
+ for (const guard of Array.from(allGuards).reverse()) {
1620
+ const guardInstance = await inject(
1621
+ guard
1622
+ );
1623
+ if (!guardInstance.canActivate) {
1624
+ throw new Error(
1625
+ `[Navios] Guard ${guard.name} does not implement canActivate()`
1626
+ );
1627
+ }
1628
+ try {
1629
+ canActivate = await guardInstance.canActivate(executionContext);
1630
+ if (!canActivate) {
1631
+ break;
1632
+ }
1633
+ } catch (error) {
1634
+ if (error instanceof HttpException) {
1635
+ executionContext.getReply().status(error.statusCode).send(error.response);
1636
+ return false;
1637
+ } else {
1638
+ executionContext.getReply().status(500).send({
1639
+ message: "Internal server error",
1640
+ error: error.message
1641
+ });
1642
+ return false;
1643
+ }
1644
+ }
1645
+ }
1646
+ if (!canActivate) {
1647
+ executionContext.getReply().status(403).send({
1648
+ message: "Forbidden"
1649
+ });
1650
+ return false;
1651
+ }
1652
+ return canActivate;
1653
+ }
1654
+ makeContext(executionContext) {
1655
+ const guards = /* @__PURE__ */ new Set();
1656
+ const endpointGuards = executionContext.getHandler().guards;
1657
+ const controllerGuards = executionContext.getController().guards;
1658
+ const moduleGuards = executionContext.getModule().guards;
1659
+ if (endpointGuards.size > 0) {
1660
+ for (const guard of endpointGuards) {
1661
+ guards.add(guard);
1662
+ }
1663
+ }
1664
+ if (controllerGuards.size > 0) {
1665
+ for (const guard of controllerGuards) {
1666
+ guards.add(guard);
1667
+ }
1668
+ }
1669
+ if (moduleGuards.size > 0) {
1670
+ for (const guard of moduleGuards) {
1671
+ guards.add(guard);
1672
+ }
1673
+ }
1674
+ return guards;
1675
+ }
1676
+ };
1677
+ _init4 = __decoratorStart(null);
1678
+ GuardRunnerService = __decorateElement(_init4, 0, "GuardRunnerService", _GuardRunnerService_decorators, GuardRunnerService);
1679
+ __runInitializers(_init4, 1, GuardRunnerService);
1680
+
1681
+ // packages/core/src/services/controller-adapter.service.mts
1682
+ var _ControllerAdapterService_decorators, _init5;
1683
+ _ControllerAdapterService_decorators = [Injectable()];
1684
+ var _ControllerAdapterService = class _ControllerAdapterService {
1685
+ guardRunner = syncInject(GuardRunnerService);
1686
+ logger = syncInject(Logger, {
1687
+ context: _ControllerAdapterService.name
1688
+ });
1689
+ async setupController(controller, instance, moduleMetadata) {
1690
+ var _a3, _b;
1691
+ const controllerMetadata = extractControllerMetadata(controller);
1692
+ for (const endpoint of controllerMetadata.endpoints) {
1693
+ const { classMethod, url, httpMethod, adapterToken } = endpoint;
1694
+ if (!url || !adapterToken) {
1695
+ throw new Error(
1696
+ `[Navios] Malformed Endpoint ${controller.name}:${classMethod}`
1697
+ );
1698
+ }
1699
+ const adapter = await inject(
1700
+ adapterToken
1701
+ );
1702
+ const executionContext = new ExecutionContext(
1703
+ moduleMetadata,
1704
+ controllerMetadata,
1705
+ endpoint
1706
+ );
1707
+ const hasSchema = ((_a3 = adapter.hasSchema) == null ? void 0 : _a3.call(adapter, endpoint)) ?? false;
1708
+ if (hasSchema) {
1709
+ instance.withTypeProvider().route({
1710
+ method: httpMethod,
1711
+ url: url.replaceAll("$", ":"),
1712
+ schema: ((_b = adapter.provideSchema) == null ? void 0 : _b.call(adapter, endpoint)) ?? {},
1713
+ preHandler: this.providePreHandler(executionContext),
1714
+ handler: this.wrapHandler(
1715
+ executionContext,
1716
+ adapter.provideHandler(controller, executionContext, endpoint)
1717
+ )
1718
+ });
1719
+ } else {
1720
+ instance.route({
1721
+ method: httpMethod,
1722
+ url: url.replaceAll("$", ":"),
1723
+ preHandler: this.providePreHandler(executionContext),
1724
+ handler: this.wrapHandler(
1725
+ executionContext,
1726
+ adapter.provideHandler(controller, executionContext, endpoint)
1727
+ )
1728
+ });
1729
+ }
1730
+ this.logger.debug(
1731
+ `Registered ${httpMethod} ${url} for ${controller.name}:${classMethod}`
1732
+ );
1733
+ }
1734
+ }
1735
+ providePreHandler(executionContext) {
1736
+ const guards = this.guardRunner.makeContext(executionContext);
1737
+ return guards.size > 0 ? this.wrapHandler(
1738
+ executionContext,
1739
+ async (request, reply) => {
1740
+ let canActivate = true;
1741
+ canActivate = await this.guardRunner.runGuards(
1742
+ guards,
1743
+ executionContext
1744
+ );
1745
+ if (!canActivate) {
1746
+ return reply;
1747
+ }
1748
+ }
1749
+ ) : void 0;
1750
+ }
1751
+ wrapHandler(executionContext, handler) {
1752
+ const locator = getServiceLocator();
1753
+ return async (request, reply) => {
1754
+ locator.registerInstance(Request, request);
1755
+ locator.registerInstance(Reply, reply);
1756
+ locator.registerInstance(ExecutionContextToken, executionContext);
1757
+ executionContext.provideRequest(request);
1758
+ executionContext.provideReply(reply);
1759
+ try {
1760
+ return await handler(request, reply);
1761
+ } finally {
1762
+ Promise.all([
1763
+ locator.removeInstance(Request),
1764
+ locator.removeInstance(Reply),
1765
+ locator.removeInstance(ExecutionContextToken)
1766
+ ]).catch((err) => {
1767
+ this.logger.warn(`Error removing instances: ${err}`);
1768
+ });
1769
+ }
1770
+ };
1771
+ }
1772
+ };
1773
+ _init5 = __decoratorStart(null);
1774
+ _ControllerAdapterService = __decorateElement(_init5, 0, "ControllerAdapterService", _ControllerAdapterService_decorators, _ControllerAdapterService);
1775
+ __runInitializers(_init5, 1, _ControllerAdapterService);
1776
+ var ControllerAdapterService = _ControllerAdapterService;
1777
+
1778
+ // packages/core/src/services/module-loader.service.mts
1779
+ var _ModuleLoaderService_decorators, _init6;
1780
+ _ModuleLoaderService_decorators = [Injectable()];
1781
+ var _ModuleLoaderService = class _ModuleLoaderService {
1782
+ logger = syncInject(Logger, {
1783
+ context: _ModuleLoaderService.name
1784
+ });
1785
+ modulesMetadata = /* @__PURE__ */ new Map();
1786
+ loadedModules = /* @__PURE__ */ new Map();
1787
+ initialized = false;
1788
+ async loadModules(appModule) {
1789
+ if (this.initialized) {
1790
+ return;
1791
+ }
1792
+ await this.traverseModules(appModule);
1793
+ this.initialized = true;
1794
+ }
1795
+ async traverseModules(module2, parentMetadata) {
1796
+ const metadata = extractModuleMetadata(module2);
1797
+ if (parentMetadata) {
1798
+ this.mergeMetadata(metadata, parentMetadata);
1799
+ }
1800
+ const moduleName = module2.name;
1801
+ if (this.modulesMetadata.has(moduleName)) {
1802
+ return;
1803
+ }
1804
+ this.modulesMetadata.set(moduleName, metadata);
1805
+ const imports = metadata.imports ?? /* @__PURE__ */ new Set();
1806
+ const loadingPromises = Array.from(imports).map(
1807
+ async (importedModule) => this.traverseModules(importedModule, metadata)
1808
+ );
1809
+ await Promise.all(loadingPromises);
1810
+ const instance = await inject(module2);
1811
+ if (instance.onModuleInit) {
1812
+ await instance.onModuleInit();
1813
+ }
1814
+ this.logger.debug(`Module ${moduleName} loaded`);
1815
+ this.loadedModules.set(moduleName, instance);
1816
+ }
1817
+ mergeMetadata(metadata, parentMetadata) {
1818
+ if (parentMetadata.guards) {
1819
+ for (const guard of parentMetadata.guards) {
1820
+ metadata.guards.add(guard);
1821
+ }
1822
+ }
1823
+ if (parentMetadata.customAttributes) {
1824
+ for (const [key, value] of parentMetadata.customAttributes) {
1825
+ if (metadata.customAttributes.has(key)) {
1826
+ continue;
1827
+ }
1828
+ metadata.customAttributes.set(key, value);
1829
+ }
1830
+ }
1831
+ }
1832
+ getAllModules() {
1833
+ return this.modulesMetadata;
1834
+ }
1835
+ dispose() {
1836
+ this.modulesMetadata.clear();
1837
+ this.loadedModules.clear();
1838
+ this.initialized = false;
1839
+ }
1840
+ };
1841
+ _init6 = __decoratorStart(null);
1842
+ _ModuleLoaderService = __decorateElement(_init6, 0, "ModuleLoaderService", _ModuleLoaderService_decorators, _ModuleLoaderService);
1843
+ __runInitializers(_init6, 1, _ModuleLoaderService);
1844
+ var ModuleLoaderService = _ModuleLoaderService;
1845
+
1846
+ // packages/core/src/tokens/execution-context.token.mts
1847
+ var ExecutionContextInjectionToken = "ExecutionContextInjectionToken";
1848
+ var ExecutionContextToken = InjectionToken.create(
1849
+ ExecutionContextInjectionToken
1850
+ );
1851
+
1852
+ // packages/core/src/tokens/reply.token.mts
1853
+ var ReplyInjectionToken = "ReplyInjectionToken";
1854
+ var Reply = InjectionToken.create(ReplyInjectionToken);
1855
+
1856
+ // packages/core/src/tokens/request.token.mts
1857
+ var RequestInjectionToken = "RequestInjectionToken";
1858
+ var Request = InjectionToken.create(
1859
+ RequestInjectionToken
1860
+ );
1861
+
1862
+ // packages/core/src/logger/console-logger.service.mts
1863
+ var DEFAULT_DEPTH = 5;
1864
+ var DEFAULT_LOG_LEVELS = [
1865
+ "log",
1866
+ "error",
1867
+ "warn",
1868
+ "debug",
1869
+ "verbose",
1870
+ "fatal"
1871
+ ];
1872
+ var dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
1873
+ year: "numeric",
1874
+ hour: "numeric",
1875
+ minute: "numeric",
1876
+ second: "numeric",
1877
+ day: "2-digit",
1878
+ month: "2-digit"
1879
+ });
1880
+ var _ConsoleLogger_decorators, _init7;
1881
+ _ConsoleLogger_decorators = [Injectable()];
1882
+ var _ConsoleLogger = class _ConsoleLogger {
1883
+ /**
1884
+ * The options of the logger.
1885
+ */
1886
+ options;
1887
+ /**
1888
+ * The context of the logger (can be set manually or automatically inferred).
1889
+ */
1890
+ context;
1891
+ /**
1892
+ * Request ID (if enabled).
1893
+ */
1894
+ requestId = null;
1895
+ /**
1896
+ * The original context of the logger (set in the constructor).
1897
+ */
1898
+ originalContext;
1899
+ /**
1900
+ * The options used for the "inspect" method.
1901
+ */
1902
+ inspectOptions;
1903
+ /**
1904
+ * The last timestamp at which the log message was printed.
1905
+ */
1906
+ static lastTimestampAt;
1907
+ constructor(contextOrOptions, options) {
1908
+ let [context, opts] = isString(contextOrOptions) ? [contextOrOptions, options] : options ? [void 0, options] : [contextOrOptions == null ? void 0 : contextOrOptions.context, contextOrOptions];
1909
+ opts = opts ?? {};
1910
+ opts.logLevels ??= DEFAULT_LOG_LEVELS;
1911
+ opts.colors ??= opts.colors ?? (opts.json ? false : true);
1912
+ opts.prefix ??= "Navios";
1913
+ this.options = opts;
1914
+ this.inspectOptions = this.getInspectOptions();
1915
+ if (context) {
1916
+ this.context = context;
1917
+ this.originalContext = context;
1918
+ }
1919
+ if (opts == null ? void 0 : opts.requestId) {
1920
+ const locator = getServiceLocator();
1921
+ locator.getEventBus().on(locator.getInstanceIdentifier(Request, void 0), "create", () => {
1922
+ const request = locator.getSyncInstance(Request, void 0);
1923
+ this.requestId = (request == null ? void 0 : request.id) ?? null;
1924
+ });
1925
+ locator.getEventBus().on(
1926
+ locator.getInstanceIdentifier(Request, void 0),
1927
+ "destroy",
1928
+ () => {
1929
+ this.requestId = null;
1930
+ }
1931
+ );
1932
+ }
1933
+ }
1934
+ log(message, ...optionalParams) {
1935
+ if (!this.isLevelEnabled("log")) {
1936
+ return;
1937
+ }
1938
+ const { messages, context } = this.getContextAndMessagesToPrint([
1939
+ message,
1940
+ ...optionalParams
1941
+ ]);
1942
+ this.printMessages(messages, context, "log");
1943
+ }
1944
+ error(message, ...optionalParams) {
1945
+ if (!this.isLevelEnabled("error")) {
1946
+ return;
1947
+ }
1948
+ const { messages, context, stack } = this.getContextAndStackAndMessagesToPrint([message, ...optionalParams]);
1949
+ this.printMessages(messages, context, "error", "stderr", stack);
1950
+ this.printStackTrace(stack);
1951
+ }
1952
+ warn(message, ...optionalParams) {
1953
+ if (!this.isLevelEnabled("warn")) {
1954
+ return;
1955
+ }
1956
+ const { messages, context } = this.getContextAndMessagesToPrint([
1957
+ message,
1958
+ ...optionalParams
1959
+ ]);
1960
+ this.printMessages(messages, context, "warn");
1961
+ }
1962
+ debug(message, ...optionalParams) {
1963
+ if (!this.isLevelEnabled("debug")) {
1964
+ return;
1965
+ }
1966
+ const { messages, context } = this.getContextAndMessagesToPrint([
1967
+ message,
1968
+ ...optionalParams
1969
+ ]);
1970
+ this.printMessages(messages, context, "debug");
1971
+ }
1972
+ verbose(message, ...optionalParams) {
1973
+ if (!this.isLevelEnabled("verbose")) {
1974
+ return;
1975
+ }
1976
+ const { messages, context } = this.getContextAndMessagesToPrint([
1977
+ message,
1978
+ ...optionalParams
1979
+ ]);
1980
+ this.printMessages(messages, context, "verbose");
1981
+ }
1982
+ fatal(message, ...optionalParams) {
1983
+ if (!this.isLevelEnabled("fatal")) {
1984
+ return;
1985
+ }
1986
+ const { messages, context } = this.getContextAndMessagesToPrint([
1987
+ message,
1988
+ ...optionalParams
1989
+ ]);
1990
+ this.printMessages(messages, context, "fatal");
1286
1991
  }
1287
1992
  /**
1288
1993
  * Set log levels
@@ -1308,8 +2013,8 @@ var _ConsoleLogger = class _ConsoleLogger {
1308
2013
  this.context = this.originalContext;
1309
2014
  }
1310
2015
  isLevelEnabled(level) {
1311
- var _a;
1312
- const logLevels = (_a = this.options) == null ? void 0 : _a.logLevels;
2016
+ var _a3;
2017
+ const logLevels = (_a3 = this.options) == null ? void 0 : _a3.logLevels;
1313
2018
  return isLogLevelEnabled(level, logLevels);
1314
2019
  }
1315
2020
  getTimestamp() {
@@ -1354,12 +2059,15 @@ var _ConsoleLogger = class _ConsoleLogger {
1354
2059
  if (options.errorStack) {
1355
2060
  logObject.stack = options.errorStack;
1356
2061
  }
2062
+ if (this.options.requestId && this.requestId) {
2063
+ logObject.requestId = this.requestId;
2064
+ }
1357
2065
  const formattedMessage = !this.options.colors && this.inspectOptions.compact === true ? JSON.stringify(logObject, this.stringifyReplacer) : (0, import_util.inspect)(logObject, this.inspectOptions);
1358
2066
  process[options.writeStreamType ?? "stdout"].write(`${formattedMessage}
1359
2067
  `);
1360
2068
  }
1361
2069
  formatPid(pid) {
1362
- return `[${this.options.prefix}] ${pid} - `;
2070
+ return `[${this.options.prefix}] ${pid} - `;
1363
2071
  }
1364
2072
  formatContext(context) {
1365
2073
  if (!context) {
@@ -1372,9 +2080,15 @@ var _ConsoleLogger = class _ConsoleLogger {
1372
2080
  const output = this.stringifyMessage(message, logLevel);
1373
2081
  pidMessage = this.colorize(pidMessage, logLevel);
1374
2082
  formattedLogLevel = this.colorize(formattedLogLevel, logLevel);
1375
- return `${pidMessage}${this.getTimestamp()} ${formattedLogLevel} ${contextMessage}${output}${timestampDiff}
2083
+ return `${pidMessage}${this.getRequestId()}${this.getTimestamp()} ${formattedLogLevel} ${contextMessage}${output}${timestampDiff}
1376
2084
  `;
1377
2085
  }
2086
+ getRequestId() {
2087
+ if (this.options.requestId && this.requestId) {
2088
+ return `(${this.colorize(this.requestId, "log")}) `;
2089
+ }
2090
+ return "";
2091
+ }
1378
2092
  stringifyMessage(message, logLevel) {
1379
2093
  if (isFunction(message)) {
1380
2094
  const messageAsStr = Function.prototype.toString.call(message);
@@ -1411,8 +2125,8 @@ var _ConsoleLogger = class _ConsoleLogger {
1411
2125
  `);
1412
2126
  }
1413
2127
  updateAndGetTimestampDiff() {
1414
- var _a;
1415
- const includeTimestamp = _ConsoleLogger.lastTimestampAt && ((_a = this.options) == null ? void 0 : _a.timestamp);
2128
+ var _a3;
2129
+ const includeTimestamp = _ConsoleLogger.lastTimestampAt && ((_a3 = this.options) == null ? void 0 : _a3.timestamp);
1416
2130
  const result = includeTimestamp ? this.formatTimestampDiff(Date.now() - _ConsoleLogger.lastTimestampAt) : "";
1417
2131
  _ConsoleLogger.lastTimestampAt = Date.now();
1418
2132
  return result;
@@ -1517,13 +2231,13 @@ var _ConsoleLogger = class _ConsoleLogger {
1517
2231
  }
1518
2232
  }
1519
2233
  };
1520
- _init = __decoratorStart(null);
1521
- _ConsoleLogger = __decorateElement(_init, 0, "ConsoleLogger", _ConsoleLogger_decorators, _ConsoleLogger);
1522
- __runInitializers(_init, 1, _ConsoleLogger);
2234
+ _init7 = __decoratorStart(null);
2235
+ _ConsoleLogger = __decorateElement(_init7, 0, "ConsoleLogger", _ConsoleLogger_decorators, _ConsoleLogger);
2236
+ __runInitializers(_init7, 1, _ConsoleLogger);
1523
2237
  var ConsoleLogger = _ConsoleLogger;
1524
2238
 
1525
2239
  // packages/core/src/logger/logger.factory.mts
1526
- var import_zod2 = require("zod");
2240
+ var import_zod3 = require("zod");
1527
2241
 
1528
2242
  // packages/core/src/logger/logger.service.mts
1529
2243
  var DEFAULT_LOGGER = new ConsoleLogger();
@@ -1535,7 +2249,7 @@ var dateTimeFormatter2 = new Intl.DateTimeFormat(void 0, {
1535
2249
  day: "2-digit",
1536
2250
  month: "2-digit"
1537
2251
  });
1538
- var _LoggerInstance_decorators, _init2;
2252
+ var _LoggerInstance_decorators, _init8;
1539
2253
  _LoggerInstance_decorators = [Injectable()];
1540
2254
  var _LoggerInstance = class _LoggerInstance {
1541
2255
  constructor(context, options = {}) {
@@ -1557,69 +2271,69 @@ var _LoggerInstance = class _LoggerInstance {
1557
2271
  return _LoggerInstance.staticInstanceRef;
1558
2272
  }
1559
2273
  error(message, ...optionalParams) {
1560
- var _a;
2274
+ var _a3;
1561
2275
  optionalParams = this.context ? (optionalParams.length ? optionalParams : [void 0]).concat(
1562
2276
  this.context
1563
2277
  ) : optionalParams;
1564
- (_a = this.localInstance) == null ? void 0 : _a.error(message, ...optionalParams);
2278
+ (_a3 = this.localInstance) == null ? void 0 : _a3.error(message, ...optionalParams);
1565
2279
  }
1566
2280
  log(message, ...optionalParams) {
1567
- var _a;
2281
+ var _a3;
1568
2282
  optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
1569
- (_a = this.localInstance) == null ? void 0 : _a.log(message, ...optionalParams);
2283
+ (_a3 = this.localInstance) == null ? void 0 : _a3.log(message, ...optionalParams);
1570
2284
  }
1571
2285
  warn(message, ...optionalParams) {
1572
- var _a;
2286
+ var _a3;
1573
2287
  optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
1574
- (_a = this.localInstance) == null ? void 0 : _a.warn(message, ...optionalParams);
2288
+ (_a3 = this.localInstance) == null ? void 0 : _a3.warn(message, ...optionalParams);
1575
2289
  }
1576
2290
  debug(message, ...optionalParams) {
1577
- var _a, _b;
2291
+ var _a3, _b;
1578
2292
  optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
1579
- (_b = (_a = this.localInstance) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, message, ...optionalParams);
2293
+ (_b = (_a3 = this.localInstance) == null ? void 0 : _a3.debug) == null ? void 0 : _b.call(_a3, message, ...optionalParams);
1580
2294
  }
1581
2295
  verbose(message, ...optionalParams) {
1582
- var _a, _b;
2296
+ var _a3, _b;
1583
2297
  optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
1584
- (_b = (_a = this.localInstance) == null ? void 0 : _a.verbose) == null ? void 0 : _b.call(_a, message, ...optionalParams);
2298
+ (_b = (_a3 = this.localInstance) == null ? void 0 : _a3.verbose) == null ? void 0 : _b.call(_a3, message, ...optionalParams);
1585
2299
  }
1586
2300
  fatal(message, ...optionalParams) {
1587
- var _a, _b;
2301
+ var _a3, _b;
1588
2302
  optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
1589
- (_b = (_a = this.localInstance) == null ? void 0 : _a.fatal) == null ? void 0 : _b.call(_a, message, ...optionalParams);
2303
+ (_b = (_a3 = this.localInstance) == null ? void 0 : _a3.fatal) == null ? void 0 : _b.call(_a3, message, ...optionalParams);
1590
2304
  }
1591
2305
  static error(message, ...optionalParams) {
1592
- var _a;
1593
- (_a = this.staticInstanceRef) == null ? void 0 : _a.error(message, ...optionalParams);
2306
+ var _a3;
2307
+ (_a3 = this.staticInstanceRef) == null ? void 0 : _a3.error(message, ...optionalParams);
1594
2308
  }
1595
2309
  static log(message, ...optionalParams) {
1596
- var _a;
1597
- (_a = this.staticInstanceRef) == null ? void 0 : _a.log(message, ...optionalParams);
2310
+ var _a3;
2311
+ (_a3 = this.staticInstanceRef) == null ? void 0 : _a3.log(message, ...optionalParams);
1598
2312
  }
1599
2313
  static warn(message, ...optionalParams) {
1600
- var _a;
1601
- (_a = this.staticInstanceRef) == null ? void 0 : _a.warn(message, ...optionalParams);
2314
+ var _a3;
2315
+ (_a3 = this.staticInstanceRef) == null ? void 0 : _a3.warn(message, ...optionalParams);
1602
2316
  }
1603
2317
  static debug(message, ...optionalParams) {
1604
- var _a, _b;
1605
- (_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, message, ...optionalParams);
2318
+ var _a3, _b;
2319
+ (_b = (_a3 = this.staticInstanceRef) == null ? void 0 : _a3.debug) == null ? void 0 : _b.call(_a3, message, ...optionalParams);
1606
2320
  }
1607
2321
  static verbose(message, ...optionalParams) {
1608
- var _a, _b;
1609
- (_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.verbose) == null ? void 0 : _b.call(_a, message, ...optionalParams);
2322
+ var _a3, _b;
2323
+ (_b = (_a3 = this.staticInstanceRef) == null ? void 0 : _a3.verbose) == null ? void 0 : _b.call(_a3, message, ...optionalParams);
1610
2324
  }
1611
2325
  static fatal(message, ...optionalParams) {
1612
- var _a, _b;
1613
- (_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.fatal) == null ? void 0 : _b.call(_a, message, ...optionalParams);
2326
+ var _a3, _b;
2327
+ (_b = (_a3 = this.staticInstanceRef) == null ? void 0 : _a3.fatal) == null ? void 0 : _b.call(_a3, message, ...optionalParams);
1614
2328
  }
1615
2329
  static getTimestamp() {
1616
2330
  return dateTimeFormatter2.format(Date.now());
1617
2331
  }
1618
2332
  static overrideLogger(logger) {
1619
- var _a, _b;
2333
+ var _a3, _b;
1620
2334
  if (Array.isArray(logger)) {
1621
2335
  _LoggerInstance.logLevels = logger;
1622
- return (_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.setLogLevels) == null ? void 0 : _b.call(_a, logger);
2336
+ return (_b = (_a3 = this.staticInstanceRef) == null ? void 0 : _a3.setLogLevels) == null ? void 0 : _b.call(_a3, logger);
1623
2337
  }
1624
2338
  if (isObject(logger)) {
1625
2339
  this.staticInstanceRef = logger;
@@ -1632,32 +2346,32 @@ var _LoggerInstance = class _LoggerInstance {
1632
2346
  return isLogLevelEnabled(level, logLevels);
1633
2347
  }
1634
2348
  registerLocalInstanceRef() {
1635
- var _a;
2349
+ var _a3;
1636
2350
  if (this.localInstanceRef) {
1637
2351
  return this.localInstanceRef;
1638
2352
  }
1639
2353
  this.localInstanceRef = new ConsoleLogger(this.context, {
1640
- timestamp: (_a = this.options) == null ? void 0 : _a.timestamp,
2354
+ timestamp: (_a3 = this.options) == null ? void 0 : _a3.timestamp,
1641
2355
  logLevels: _LoggerInstance.logLevels
1642
2356
  });
1643
2357
  return this.localInstanceRef;
1644
2358
  }
1645
2359
  };
1646
- _init2 = __decoratorStart(null);
1647
- _LoggerInstance = __decorateElement(_init2, 0, "LoggerInstance", _LoggerInstance_decorators, _LoggerInstance);
1648
- __runInitializers(_init2, 1, _LoggerInstance);
2360
+ _init8 = __decoratorStart(null);
2361
+ _LoggerInstance = __decorateElement(_init8, 0, "LoggerInstance", _LoggerInstance_decorators, _LoggerInstance);
2362
+ __runInitializers(_init8, 1, _LoggerInstance);
1649
2363
  var LoggerInstance = _LoggerInstance;
1650
2364
 
1651
2365
  // packages/core/src/logger/logger.factory.mts
1652
2366
  var LoggerInjectionToken = "LoggerInjectionToken";
1653
- var LoggerOptions = import_zod2.z.object({
1654
- context: import_zod2.z.string().optional(),
1655
- options: import_zod2.z.object({
1656
- timestamp: import_zod2.z.boolean().optional()
2367
+ var LoggerOptions = import_zod3.z.object({
2368
+ context: import_zod3.z.string().optional(),
2369
+ options: import_zod3.z.object({
2370
+ timestamp: import_zod3.z.boolean().optional()
1657
2371
  }).optional()
1658
2372
  }).optional();
1659
2373
  var Logger = InjectionToken.create(LoggerInjectionToken, LoggerOptions);
1660
- var _LoggerFactory_decorators, _init3;
2374
+ var _LoggerFactory_decorators, _init9;
1661
2375
  _LoggerFactory_decorators = [Injectable({
1662
2376
  type: "Factory" /* Factory */,
1663
2377
  token: Logger
@@ -1667,9 +2381,9 @@ var LoggerFactory = class {
1667
2381
  return new LoggerInstance(args == null ? void 0 : args.context, args == null ? void 0 : args.options);
1668
2382
  }
1669
2383
  };
1670
- _init3 = __decoratorStart(null);
1671
- LoggerFactory = __decorateElement(_init3, 0, "LoggerFactory", _LoggerFactory_decorators, LoggerFactory);
1672
- __runInitializers(_init3, 1, LoggerFactory);
2384
+ _init9 = __decoratorStart(null);
2385
+ LoggerFactory = __decorateElement(_init9, 0, "LoggerFactory", _LoggerFactory_decorators, LoggerFactory);
2386
+ __runInitializers(_init9, 1, LoggerFactory);
1673
2387
 
1674
2388
  // packages/core/src/logger/pino-wrapper.mts
1675
2389
  var PinoWrapper = class _PinoWrapper {
@@ -1691,12 +2405,12 @@ var PinoWrapper = class _PinoWrapper {
1691
2405
  info() {
1692
2406
  }
1693
2407
  debug(message, ...optionalParams) {
1694
- var _a, _b;
1695
- (_b = (_a = this.logger).debug) == null ? void 0 : _b.call(_a, message, ...optionalParams);
2408
+ var _a3, _b;
2409
+ (_b = (_a3 = this.logger).debug) == null ? void 0 : _b.call(_a3, message, ...optionalParams);
1696
2410
  }
1697
2411
  trace(message, ...optionalParams) {
1698
- var _a, _b;
1699
- (_b = (_a = this.logger).verbose) == null ? void 0 : _b.call(_a, message, ...optionalParams);
2412
+ var _a3, _b;
2413
+ (_b = (_a3 = this.logger).verbose) == null ? void 0 : _b.call(_a3, message, ...optionalParams);
1700
2414
  }
1701
2415
  silent() {
1702
2416
  }
@@ -1734,7 +2448,7 @@ var ConfigServiceInstance = class {
1734
2448
  return this.config;
1735
2449
  }
1736
2450
  get(key) {
1737
- var _a, _b;
2451
+ var _a3, _b;
1738
2452
  try {
1739
2453
  const parts = String(key).split(".");
1740
2454
  let value = this.config;
@@ -1746,8 +2460,8 @@ var ConfigServiceInstance = class {
1746
2460
  }
1747
2461
  return value ?? null;
1748
2462
  } catch (error) {
1749
- (_b = (_a = this.logger).debug) == null ? void 0 : _b.call(
1750
- _a,
2463
+ (_b = (_a3 = this.logger).debug) == null ? void 0 : _b.call(
2464
+ _a3,
1751
2465
  `Failed to get config value for key ${String(key)}`,
1752
2466
  error
1753
2467
  );
@@ -1770,11 +2484,11 @@ var ConfigServiceInstance = class {
1770
2484
  };
1771
2485
 
1772
2486
  // packages/core/src/config/config.provider.mts
1773
- var ConfigProviderOptions = import_zod3.z.object({
1774
- load: import_zod3.z.function()
2487
+ var ConfigProviderOptions = import_zod4.z.object({
2488
+ load: import_zod4.z.function()
1775
2489
  });
1776
2490
  var ConfigProvider = InjectionToken.create(ConfigServiceInstance, ConfigProviderOptions);
1777
- var _ConfigProviderFactory_decorators, _init4;
2491
+ var _ConfigProviderFactory_decorators, _init10;
1778
2492
  _ConfigProviderFactory_decorators = [Injectable({
1779
2493
  token: ConfigProvider,
1780
2494
  type: "Factory" /* Factory */
@@ -1788,267 +2502,50 @@ var ConfigProviderFactory = class {
1788
2502
  const logger = this.logger;
1789
2503
  try {
1790
2504
  const config = await load();
1791
- return new ConfigServiceInstance(config, logger);
2505
+ return new ConfigServiceInstance(
2506
+ config,
2507
+ logger
2508
+ );
1792
2509
  } catch (error) {
1793
2510
  logger.error("Error loading config", error);
1794
- throw error;
1795
- }
1796
- }
1797
- };
1798
- _init4 = __decoratorStart(null);
1799
- ConfigProviderFactory = __decorateElement(_init4, 0, "ConfigProviderFactory", _ConfigProviderFactory_decorators, ConfigProviderFactory);
1800
- __runInitializers(_init4, 1, ConfigProviderFactory);
1801
- function provideConfig(options) {
1802
- return InjectionToken.bound(ConfigProvider, options);
1803
- }
1804
-
1805
- // packages/core/src/metadata/endpoint.metadata.mts
1806
- var EndpointMetadataKey = Symbol("EndpointMetadataKey");
1807
- var EndpointType = /* @__PURE__ */ ((EndpointType2) => {
1808
- EndpointType2["Unknown"] = "unknown";
1809
- EndpointType2["Endpoint"] = "endpoint";
1810
- EndpointType2["Stream"] = "stream";
1811
- EndpointType2["Multipart"] = "multipart";
1812
- EndpointType2["Handler"] = "handler";
1813
- return EndpointType2;
1814
- })(EndpointType || {});
1815
- function getAllEndpointMetadata(context) {
1816
- if (context.metadata) {
1817
- const metadata = context.metadata[EndpointMetadataKey];
1818
- if (metadata) {
1819
- return metadata;
1820
- } else {
1821
- context.metadata[EndpointMetadataKey] = /* @__PURE__ */ new Set();
1822
- return context.metadata[EndpointMetadataKey];
1823
- }
1824
- }
1825
- throw new Error("[Navios] Wrong environment.");
1826
- }
1827
- function getEndpointMetadata(target, context) {
1828
- if (context.metadata) {
1829
- const metadata = getAllEndpointMetadata(context);
1830
- if (metadata) {
1831
- const endpointMetadata = Array.from(metadata).find(
1832
- (item) => item.classMethod === target.name
1833
- );
1834
- if (endpointMetadata) {
1835
- return endpointMetadata;
1836
- } else {
1837
- const newMetadata = {
1838
- classMethod: target.name,
1839
- url: "",
1840
- successStatusCode: 200,
1841
- headers: {},
1842
- type: "unknown" /* Unknown */,
1843
- httpMethod: "GET",
1844
- config: null,
1845
- guards: /* @__PURE__ */ new Set(),
1846
- customAttributes: /* @__PURE__ */ new Map()
1847
- };
1848
- metadata.add(newMetadata);
1849
- return newMetadata;
1850
- }
1851
- }
1852
- }
1853
- throw new Error("[Navios] Wrong environment.");
1854
- }
1855
-
1856
- // packages/core/src/metadata/controller.metadata.mts
1857
- var ControllerMetadataKey = Symbol("ControllerMetadataKey");
1858
- function getControllerMetadata(target, context) {
1859
- if (context.metadata) {
1860
- const metadata = context.metadata[ControllerMetadataKey];
1861
- if (metadata) {
1862
- return metadata;
1863
- } else {
1864
- const endpointsMetadata = getAllEndpointMetadata(context);
1865
- const newMetadata = {
1866
- endpoints: endpointsMetadata,
1867
- guards: /* @__PURE__ */ new Set(),
1868
- customAttributes: /* @__PURE__ */ new Map()
1869
- };
1870
- context.metadata[ControllerMetadataKey] = newMetadata;
1871
- target[ControllerMetadataKey] = newMetadata;
1872
- return newMetadata;
1873
- }
1874
- }
1875
- throw new Error("[Navios] Wrong environment.");
1876
- }
1877
- function extractControllerMetadata(target) {
1878
- const metadata = target[ControllerMetadataKey];
1879
- if (!metadata) {
1880
- throw new Error(
1881
- "[Navios] Controller metadata not found. Make sure to use @Controller decorator."
1882
- );
1883
- }
1884
- return metadata;
1885
- }
1886
- function hasControllerMetadata(target) {
1887
- const metadata = target[ControllerMetadataKey];
1888
- return !!metadata;
1889
- }
1890
-
1891
- // packages/core/src/metadata/module.metadata.mts
1892
- var ModuleMetadataKey = Symbol("ControllerMetadataKey");
1893
- function getModuleMetadata(target, context) {
1894
- if (context.metadata) {
1895
- const metadata = context.metadata[ModuleMetadataKey];
1896
- if (metadata) {
1897
- return metadata;
1898
- } else {
1899
- const newMetadata = {
1900
- controllers: /* @__PURE__ */ new Set(),
1901
- imports: /* @__PURE__ */ new Set(),
1902
- guards: /* @__PURE__ */ new Set(),
1903
- customAttributes: /* @__PURE__ */ new Map()
1904
- };
1905
- context.metadata[ModuleMetadataKey] = newMetadata;
1906
- target[ModuleMetadataKey] = newMetadata;
1907
- return newMetadata;
1908
- }
1909
- }
1910
- throw new Error("[Navios] Wrong environment.");
1911
- }
1912
- function extractModuleMetadata(target) {
1913
- const metadata = target[ModuleMetadataKey];
1914
- if (!metadata) {
1915
- throw new Error(
1916
- `[Navios] Module metadata not found for ${target.name}. Make sure to use @Module decorator.`
1917
- );
1918
- }
1919
- return metadata;
1920
- }
1921
- function hasModuleMetadata(target) {
1922
- return !!target[ModuleMetadataKey];
1923
- }
1924
-
1925
- // packages/core/src/decorators/controller.decorator.mts
1926
- function Controller({ guards } = {}) {
1927
- return function(target, context) {
1928
- if (context.kind !== "class") {
1929
- throw new Error(
1930
- "[Navios] @Controller decorator can only be used on classes."
1931
- );
1932
- }
1933
- const token = InjectionToken.create(target);
1934
- if (context.metadata) {
1935
- const controllerMetadata = getControllerMetadata(target, context);
1936
- if (guards) {
1937
- for (const guard of Array.from(guards).reverse()) {
1938
- controllerMetadata.guards.add(guard);
1939
- }
1940
- }
1941
- }
1942
- return Injectable({
1943
- token,
1944
- type: "Class" /* Class */,
1945
- scope: "Instance" /* Instance */
1946
- })(target, context);
1947
- };
1948
- }
1949
-
1950
- // packages/core/src/decorators/endpoint.decorator.mts
1951
- var import_zod4 = require("zod");
1952
- function Endpoint(endpoint) {
1953
- return (target, context) => {
1954
- if (typeof target !== "function") {
1955
- throw new Error(
1956
- "[Navios] Endpoint decorator can only be used on functions."
1957
- );
1958
- }
1959
- if (context.kind !== "method") {
1960
- throw new Error(
1961
- "[Navios] Endpoint decorator can only be used on methods."
1962
- );
1963
- }
1964
- const config = endpoint.config;
1965
- if (context.metadata) {
1966
- let endpointMetadata = getEndpointMetadata(target, context);
1967
- if (endpointMetadata.config && endpointMetadata.config.url) {
1968
- throw new Error(
1969
- `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`
1970
- );
1971
- }
1972
- endpointMetadata.config = config;
1973
- endpointMetadata.type = "endpoint" /* Endpoint */;
1974
- endpointMetadata.classMethod = target.name;
1975
- endpointMetadata.httpMethod = config.method;
1976
- endpointMetadata.url = config.url;
1977
- }
1978
- return target;
1979
- };
1980
- }
1981
-
1982
- // packages/core/src/decorators/header.decorator.mts
1983
- function Header(name2, value) {
1984
- return (target, context) => {
1985
- if (context.kind !== "method") {
1986
- throw new Error("[Navios] Header decorator can only be used on methods.");
1987
- }
1988
- const metadata = getEndpointMetadata(target, context);
1989
- if (metadata.type === "stream" /* Stream */) {
1990
- throw new Error(
1991
- "[Navios] HttpCode decorator cannot be used on stream endpoints."
1992
- );
1993
- }
1994
- metadata.headers[name2] = value;
1995
- return target;
1996
- };
1997
- }
1998
-
1999
- // packages/core/src/decorators/http-code.decorator.mts
2000
- function HttpCode(code) {
2001
- return (target, context) => {
2002
- if (context.kind !== "method") {
2003
- throw new Error(
2004
- "[Navios] HttpCode decorator can only be used on methods."
2005
- );
2006
- }
2007
- const metadata = getEndpointMetadata(target, context);
2008
- if (metadata.type === "stream" /* Stream */) {
2009
- throw new Error(
2010
- "[Navios] HttpCode decorator cannot be used on stream endpoints."
2011
- );
2012
- }
2013
- metadata.successStatusCode = code;
2014
- return target;
2015
- };
2511
+ throw error;
2512
+ }
2513
+ }
2514
+ };
2515
+ _init10 = __decoratorStart(null);
2516
+ ConfigProviderFactory = __decorateElement(_init10, 0, "ConfigProviderFactory", _ConfigProviderFactory_decorators, ConfigProviderFactory);
2517
+ __runInitializers(_init10, 1, ConfigProviderFactory);
2518
+ function provideConfig(options) {
2519
+ return InjectionToken.bound(ConfigProvider, options);
2016
2520
  }
2017
2521
 
2018
- // packages/core/src/decorators/module.decorator.mts
2019
- function Module(metadata) {
2020
- return (target, context) => {
2522
+ // packages/core/src/decorators/controller.decorator.mts
2523
+ function Controller({ guards } = {}) {
2524
+ return function(target, context) {
2021
2525
  if (context.kind !== "class") {
2022
- throw new Error("[Navios] @Module decorator can only be used on classes.");
2526
+ throw new Error(
2527
+ "[Navios] @Controller decorator can only be used on classes."
2528
+ );
2023
2529
  }
2024
2530
  const token = InjectionToken.create(target);
2025
- const moduleMetadata = getModuleMetadata(target, context);
2026
- if (metadata.controllers) {
2027
- for (const controller of metadata.controllers) {
2028
- moduleMetadata.controllers.add(controller);
2029
- }
2030
- }
2031
- if (metadata.imports) {
2032
- for (const importedModule of metadata.imports) {
2033
- moduleMetadata.imports.add(importedModule);
2034
- }
2035
- }
2036
- if (metadata.guards) {
2037
- for (const guard of Array.from(metadata.guards).reverse()) {
2038
- moduleMetadata.guards.add(guard);
2531
+ if (context.metadata) {
2532
+ const controllerMetadata = getControllerMetadata(target, context);
2533
+ if (guards) {
2534
+ for (const guard of Array.from(guards).reverse()) {
2535
+ controllerMetadata.guards.add(guard);
2536
+ }
2039
2537
  }
2040
2538
  }
2041
2539
  return Injectable({
2042
2540
  token,
2043
- type: "Class" /* Class */,
2044
- scope: "Singleton" /* Singleton */
2541
+ scope: "Instance" /* Instance */
2045
2542
  })(target, context);
2046
2543
  };
2047
2544
  }
2048
2545
 
2049
- // packages/core/src/decorators/multipart.decorator.mts
2546
+ // packages/core/src/decorators/endpoint.decorator.mts
2050
2547
  var import_zod5 = require("zod");
2051
- function Multipart(endpoint) {
2548
+ function Endpoint(endpoint) {
2052
2549
  return (target, context) => {
2053
2550
  if (typeof target !== "function") {
2054
2551
  throw new Error(
@@ -2062,14 +2559,17 @@ function Multipart(endpoint) {
2062
2559
  }
2063
2560
  const config = endpoint.config;
2064
2561
  if (context.metadata) {
2065
- let endpointMetadata = getEndpointMetadata(target, context);
2562
+ let endpointMetadata = getEndpointMetadata(
2563
+ target,
2564
+ context
2565
+ );
2066
2566
  if (endpointMetadata.config && endpointMetadata.config.url) {
2067
2567
  throw new Error(
2068
2568
  `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`
2069
2569
  );
2070
2570
  }
2071
2571
  endpointMetadata.config = config;
2072
- endpointMetadata.type = "multipart" /* Multipart */;
2572
+ endpointMetadata.adapterToken = EndpointAdapterToken;
2073
2573
  endpointMetadata.classMethod = target.name;
2074
2574
  endpointMetadata.httpMethod = config.method;
2075
2575
  endpointMetadata.url = config.url;
@@ -2078,563 +2578,153 @@ function Multipart(endpoint) {
2078
2578
  };
2079
2579
  }
2080
2580
 
2081
- // packages/core/src/decorators/stream.decorator.mts
2082
- function Stream(endpoint) {
2581
+ // packages/core/src/decorators/header.decorator.mts
2582
+ function Header(name2, value) {
2083
2583
  return (target, context) => {
2084
- if (typeof target !== "function") {
2085
- throw new Error(
2086
- "[Navios] Endpoint decorator can only be used on functions."
2087
- );
2088
- }
2089
2584
  if (context.kind !== "method") {
2090
- throw new Error(
2091
- "[Navios] Endpoint decorator can only be used on methods."
2092
- );
2093
- }
2094
- const config = endpoint.config;
2095
- if (context.metadata) {
2096
- let endpointMetadata = getEndpointMetadata(target, context);
2097
- if (endpointMetadata.config && endpointMetadata.config.url) {
2098
- throw new Error(
2099
- `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`
2100
- );
2101
- }
2102
- endpointMetadata.config = config;
2103
- endpointMetadata.type = "stream" /* Stream */;
2104
- endpointMetadata.classMethod = target.name;
2105
- endpointMetadata.httpMethod = config.method;
2106
- endpointMetadata.url = config.url;
2585
+ throw new Error("[Navios] Header decorator can only be used on methods.");
2107
2586
  }
2587
+ const metadata = getEndpointMetadata(target, context);
2588
+ metadata.headers[name2] = value;
2108
2589
  return target;
2109
2590
  };
2110
2591
  }
2111
2592
 
2112
- // packages/core/src/decorators/use-guards.decorator.mts
2113
- function UseGuards(...guards) {
2114
- return function(target, context) {
2115
- if (context.kind === "class") {
2116
- const controllerMetadata = getControllerMetadata(
2117
- target,
2118
- context
2119
- );
2120
- for (const guard of guards.reverse()) {
2121
- controllerMetadata.guards.add(guard);
2122
- }
2123
- } else if (context.kind === "method") {
2124
- const endpointMetadata = getEndpointMetadata(target, context);
2125
- for (const guard of guards.reverse()) {
2126
- endpointMetadata.guards.add(guard);
2127
- }
2128
- } else {
2593
+ // packages/core/src/decorators/http-code.decorator.mts
2594
+ function HttpCode(code) {
2595
+ return (target, context) => {
2596
+ if (context.kind !== "method") {
2129
2597
  throw new Error(
2130
- "[Navios] @UseGuards decorator can only be used on classes or methods."
2598
+ "[Navios] HttpCode decorator can only be used on methods."
2131
2599
  );
2132
2600
  }
2601
+ const metadata = getEndpointMetadata(target, context);
2602
+ metadata.successStatusCode = code;
2133
2603
  return target;
2134
2604
  };
2135
2605
  }
2136
-
2137
- // packages/core/src/exceptions/http.exception.mts
2138
- var HttpException = class {
2139
- constructor(statusCode, response, error) {
2140
- this.statusCode = statusCode;
2141
- this.response = response;
2142
- this.error = error;
2143
- }
2144
- };
2145
-
2146
- // packages/core/src/exceptions/bad-request.exception.mts
2147
- var BadRequestException = class extends HttpException {
2148
- constructor(message) {
2149
- super(400, message);
2150
- }
2151
- };
2152
-
2153
- // packages/core/src/exceptions/forbidden.exception.mts
2154
- var ForbiddenException = class extends HttpException {
2155
- constructor(message) {
2156
- super(403, message);
2157
- }
2158
- };
2159
-
2160
- // packages/core/src/exceptions/internal-server-error.exception.mts
2161
- var InternalServerErrorException = class extends HttpException {
2162
- constructor(message, error) {
2163
- super(500, message, error);
2164
- }
2165
- };
2166
-
2167
- // packages/core/src/exceptions/not-found.exception.mts
2168
- var NotFoundException = class extends HttpException {
2169
- constructor(response, error) {
2170
- super(404, response, error);
2171
- this.response = response;
2172
- this.error = error;
2173
- }
2174
- };
2175
-
2176
- // packages/core/src/exceptions/unauthorized.exception.mts
2177
- var UnauthorizedException = class extends HttpException {
2178
- constructor(message, error) {
2179
- super(401, message, error);
2180
- }
2181
- };
2182
-
2183
- // packages/core/src/exceptions/conflict.exception.mts
2184
- var ConflictException = class extends HttpException {
2185
- constructor(message, error) {
2186
- super(409, message, error);
2187
- }
2188
- };
2189
-
2190
- // packages/core/src/services/controller-adapter.service.mts
2191
- var import_common4 = require("@navios/common");
2192
- var import_zod6 = require("zod");
2193
-
2194
- // packages/core/src/tokens/application.token.mts
2195
- var ApplicationInjectionToken = "ApplicationInjectionToken";
2196
- var Application = InjectionToken.create(
2197
- ApplicationInjectionToken
2198
- );
2199
-
2200
- // packages/core/src/tokens/execution-context.token.mts
2201
- var ExecutionContextInjectionToken = "ExecutionContextInjectionToken";
2202
- var ExecutionContextToken = InjectionToken.create(
2203
- ExecutionContextInjectionToken
2204
- );
2205
-
2206
- // packages/core/src/tokens/reply.token.mts
2207
- var ReplyInjectionToken = "ReplyInjectionToken";
2208
- var Reply = InjectionToken.create(ReplyInjectionToken);
2209
-
2210
- // packages/core/src/tokens/request.token.mts
2211
- var RequestInjectionToken = "RequestInjectionToken";
2212
- var Request = InjectionToken.create(
2213
- RequestInjectionToken
2214
- );
2215
-
2216
- // packages/core/src/services/execution-context.mts
2217
- var ExecutionContext2 = class {
2218
- constructor(module2, controller, handler) {
2219
- this.module = module2;
2220
- this.controller = controller;
2221
- this.handler = handler;
2222
- }
2223
- request;
2224
- reply;
2225
- getModule() {
2226
- return this.module;
2227
- }
2228
- getController() {
2229
- return this.controller;
2230
- }
2231
- getHandler() {
2232
- return this.handler;
2233
- }
2234
- getRequest() {
2235
- if (!this.request) {
2236
- throw new Error(
2237
- "[Navios] Request is not set. Make sure to set it before using it."
2238
- );
2239
- }
2240
- return this.request;
2241
- }
2242
- getReply() {
2243
- if (!this.reply) {
2244
- throw new Error(
2245
- "[Navios] Reply is not set. Make sure to set it before using it."
2246
- );
2247
- }
2248
- return this.reply;
2249
- }
2250
- provideRequest(request) {
2251
- this.request = request;
2252
- }
2253
- provideReply(reply) {
2254
- this.reply = reply;
2255
- }
2256
- };
2257
-
2258
- // packages/core/src/services/guard-runner.service.mts
2259
- var _GuardRunnerService_decorators, _init5;
2260
- _GuardRunnerService_decorators = [Injectable()];
2261
- var GuardRunnerService = class {
2262
- async runGuards(allGuards, executionContext) {
2263
- let canActivate = true;
2264
- for (const guard of Array.from(allGuards).reverse()) {
2265
- const guardInstance = await inject(
2266
- guard
2267
- );
2268
- if (!guardInstance.canActivate) {
2269
- throw new Error(
2270
- `[Navios] Guard ${guard.name} does not implement canActivate()`
2271
- );
2272
- }
2273
- try {
2274
- canActivate = await guardInstance.canActivate(executionContext);
2275
- if (!canActivate) {
2276
- break;
2277
- }
2278
- } catch (error) {
2279
- if (error instanceof HttpException) {
2280
- executionContext.getReply().status(error.statusCode).send(error.response);
2281
- return false;
2282
- } else {
2283
- executionContext.getReply().status(500).send({
2284
- message: "Internal server error",
2285
- error: error.message
2286
- });
2287
- return false;
2288
- }
2289
- }
2290
- }
2291
- if (!canActivate) {
2292
- executionContext.getReply().status(403).send({
2293
- message: "Forbidden"
2294
- });
2295
- return false;
2296
- }
2297
- return canActivate;
2298
- }
2299
- makeContext(executionContext) {
2300
- const guards = /* @__PURE__ */ new Set();
2301
- const endpointGuards = executionContext.getHandler().guards;
2302
- const controllerGuards = executionContext.getController().guards;
2303
- const moduleGuards = executionContext.getModule().guards;
2304
- if (endpointGuards.size > 0) {
2305
- for (const guard of endpointGuards) {
2306
- guards.add(guard);
2307
- }
2606
+
2607
+ // packages/core/src/decorators/module.decorator.mts
2608
+ function Module({ controllers = [], imports = [], guards = [] } = {
2609
+ controllers: [],
2610
+ imports: [],
2611
+ guards: []
2612
+ }) {
2613
+ return (target, context) => {
2614
+ if (context.kind !== "class") {
2615
+ throw new Error("[Navios] @Module decorator can only be used on classes.");
2308
2616
  }
2309
- if (controllerGuards.size > 0) {
2310
- for (const guard of controllerGuards) {
2311
- guards.add(guard);
2312
- }
2617
+ const token = InjectionToken.create(target);
2618
+ const moduleMetadata = getModuleMetadata(target, context);
2619
+ for (const controller of controllers) {
2620
+ moduleMetadata.controllers.add(controller);
2313
2621
  }
2314
- if (moduleGuards.size > 0) {
2315
- for (const guard of moduleGuards) {
2316
- guards.add(guard);
2317
- }
2622
+ for (const importedModule of imports) {
2623
+ moduleMetadata.imports.add(importedModule);
2318
2624
  }
2319
- return guards;
2320
- }
2321
- };
2322
- _init5 = __decoratorStart(null);
2323
- GuardRunnerService = __decorateElement(_init5, 0, "GuardRunnerService", _GuardRunnerService_decorators, GuardRunnerService);
2324
- __runInitializers(_init5, 1, GuardRunnerService);
2625
+ for (const guard of Array.from(guards).reverse()) {
2626
+ moduleMetadata.guards.add(guard);
2627
+ }
2628
+ return Injectable({
2629
+ token,
2630
+ scope: "Singleton" /* Singleton */
2631
+ })(target, context);
2632
+ };
2633
+ }
2325
2634
 
2326
- // packages/core/src/services/controller-adapter.service.mts
2327
- var _ControllerAdapterService_decorators, _init6;
2328
- _ControllerAdapterService_decorators = [Injectable()];
2329
- var _ControllerAdapterService = class _ControllerAdapterService {
2330
- guardRunner = syncInject(GuardRunnerService);
2331
- logger = syncInject(Logger, {
2332
- context: _ControllerAdapterService.name
2333
- });
2334
- setupController(controller, instance, moduleMetadata) {
2335
- const controllerMetadata = extractControllerMetadata(controller);
2336
- for (const endpoint of controllerMetadata.endpoints) {
2337
- const { classMethod, url, httpMethod } = endpoint;
2338
- if (!url) {
2339
- throw new Error(
2340
- `[Navios] Malformed Endpoint ${controller.name}:${classMethod}`
2341
- );
2342
- }
2343
- const executionContext = new ExecutionContext2(
2344
- moduleMetadata,
2345
- controllerMetadata,
2346
- endpoint
2635
+ // packages/core/src/decorators/multipart.decorator.mts
2636
+ var import_zod6 = require("zod");
2637
+ function Multipart(endpoint) {
2638
+ return (target, context) => {
2639
+ if (typeof target !== "function") {
2640
+ throw new Error(
2641
+ "[Navios] Endpoint decorator can only be used on functions."
2347
2642
  );
2348
- instance.withTypeProvider().route({
2349
- method: httpMethod,
2350
- url: url.replaceAll("$", ":"),
2351
- schema: this.provideSchemaForConfig(endpoint),
2352
- preHandler: this.providePreHandler(executionContext),
2353
- handler: this.provideHandler(controller, executionContext, endpoint)
2354
- });
2355
- this.logger.debug(
2356
- `Registered ${httpMethod} ${url} for ${controller.name}:${classMethod}`
2643
+ }
2644
+ if (context.kind !== "method") {
2645
+ throw new Error(
2646
+ "[Navios] Endpoint decorator can only be used on methods."
2357
2647
  );
2358
2648
  }
2359
- }
2360
- providePreHandler(executionContext) {
2361
- const guards = this.guardRunner.makeContext(executionContext);
2362
- return guards.size > 0 ? async (request, reply) => {
2363
- getServiceLocator().registerInstance(Request, request);
2364
- getServiceLocator().registerInstance(Reply, reply);
2365
- getServiceLocator().registerInstance(
2366
- ExecutionContextToken,
2367
- executionContext
2649
+ const config = endpoint.config;
2650
+ if (context.metadata) {
2651
+ let endpointMetadata = getEndpointMetadata(
2652
+ target,
2653
+ context
2368
2654
  );
2369
- executionContext.provideRequest(request);
2370
- executionContext.provideReply(reply);
2371
- let canActivate = true;
2372
- try {
2373
- canActivate = await this.guardRunner.runGuards(
2374
- guards,
2375
- executionContext
2655
+ if (endpointMetadata.config && endpointMetadata.config.url) {
2656
+ throw new Error(
2657
+ `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`
2376
2658
  );
2377
- } finally {
2378
- getServiceLocator().removeInstance(Request);
2379
- getServiceLocator().removeInstance(Reply);
2380
- getServiceLocator().removeInstance(ExecutionContextToken);
2381
- }
2382
- if (!canActivate) {
2383
- return reply;
2384
2659
  }
2385
- } : void 0;
2386
- }
2387
- provideSchemaForConfig(endpointMetadata) {
2388
- if (!endpointMetadata.config) {
2389
- this.logger.warn(`No config found for endpoint ${endpointMetadata.url}`);
2390
- return {};
2391
- }
2392
- const { querySchema, requestSchema, responseSchema } = endpointMetadata.config;
2393
- const schema = {};
2394
- if (querySchema) {
2395
- schema.querystring = querySchema;
2660
+ endpointMetadata.config = config;
2661
+ endpointMetadata.adapterToken = MultipartAdapterToken;
2662
+ endpointMetadata.classMethod = target.name;
2663
+ endpointMetadata.httpMethod = config.method;
2664
+ endpointMetadata.url = config.url;
2396
2665
  }
2397
- if (requestSchema && endpointMetadata.type !== "multipart" /* Multipart */) {
2398
- schema.body = requestSchema;
2666
+ return target;
2667
+ };
2668
+ }
2669
+
2670
+ // packages/core/src/decorators/stream.decorator.mts
2671
+ function Stream(endpoint) {
2672
+ return (target, context) => {
2673
+ if (typeof target !== "function") {
2674
+ throw new Error(
2675
+ "[Navios] Endpoint decorator can only be used on functions."
2676
+ );
2399
2677
  }
2400
- if (responseSchema) {
2401
- schema.response = {
2402
- 200: responseSchema
2403
- };
2678
+ if (context.kind !== "method") {
2679
+ throw new Error(
2680
+ "[Navios] Endpoint decorator can only be used on methods."
2681
+ );
2404
2682
  }
2405
- return schema;
2406
- }
2407
- provideHandler(controller, executionContext, endpointMetadata) {
2408
- switch (endpointMetadata.type) {
2409
- case "unknown" /* Unknown */:
2410
- this.logger.error(
2411
- `Unknown endpoint type ${endpointMetadata.type} for ${controller.name}:${endpointMetadata.classMethod}`
2412
- );
2413
- throw new import_common4.NaviosException("Unknown endpoint type");
2414
- case "endpoint" /* Endpoint */:
2415
- return this.provideHandlerForConfig(
2416
- controller,
2417
- executionContext,
2418
- endpointMetadata
2419
- );
2420
- case "stream" /* Stream */:
2421
- return this.provideHandlerForStream(
2422
- controller,
2423
- executionContext,
2424
- endpointMetadata
2425
- );
2426
- case "multipart" /* Multipart */:
2427
- return this.provideHandlerForMultipart(
2428
- controller,
2429
- executionContext,
2430
- endpointMetadata
2683
+ const config = endpoint.config;
2684
+ if (context.metadata) {
2685
+ let endpointMetadata = getEndpointMetadata(
2686
+ target,
2687
+ context
2688
+ );
2689
+ if (endpointMetadata.config && endpointMetadata.config.url) {
2690
+ throw new Error(
2691
+ `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`
2431
2692
  );
2432
- case "handler" /* Handler */:
2433
- this.logger.error("Not implemented yet");
2434
- throw new import_common4.NaviosException("Not implemented yet");
2693
+ }
2694
+ endpointMetadata.config = config;
2695
+ endpointMetadata.adapterToken = StreamAdapterToken;
2696
+ endpointMetadata.classMethod = target.name;
2697
+ endpointMetadata.httpMethod = config.method;
2698
+ endpointMetadata.url = config.url;
2435
2699
  }
2436
- }
2437
- provideHandlerForConfig(controller, executionContext, endpointMetadata) {
2438
- return async (request, reply) => {
2439
- getServiceLocator().registerInstance(Request, request);
2440
- getServiceLocator().registerInstance(Reply, reply);
2441
- getServiceLocator().registerInstance(
2442
- ExecutionContextToken,
2443
- executionContext
2700
+ return target;
2701
+ };
2702
+ }
2703
+
2704
+ // packages/core/src/decorators/use-guards.decorator.mts
2705
+ function UseGuards(...guards) {
2706
+ return function(target, context) {
2707
+ if (context.kind === "class") {
2708
+ const controllerMetadata = getControllerMetadata(
2709
+ target,
2710
+ context
2444
2711
  );
2445
- executionContext.provideRequest(request);
2446
- executionContext.provideReply(reply);
2447
- const controllerInstance = await inject(controller);
2448
- try {
2449
- const { query, params, body } = request;
2450
- const argument = {};
2451
- if (query && Object.keys(query).length > 0) {
2452
- argument.params = query;
2453
- }
2454
- if (params && Object.keys(params).length > 0) {
2455
- argument.urlParams = params;
2456
- }
2457
- if (body) {
2458
- argument.data = body;
2459
- }
2460
- const result = await controllerInstance[endpointMetadata.classMethod](argument);
2461
- reply.status(endpointMetadata.successStatusCode).headers(endpointMetadata.headers).send(result);
2462
- } finally {
2463
- getServiceLocator().removeInstance(Request);
2464
- getServiceLocator().removeInstance(Reply);
2465
- getServiceLocator().removeInstance(ExecutionContextToken);
2712
+ for (const guard of guards.reverse()) {
2713
+ controllerMetadata.guards.add(guard);
2466
2714
  }
2467
- };
2468
- }
2469
- provideHandlerForStream(controller, executionContext, endpointMetadata) {
2470
- return async (request, reply) => {
2471
- getServiceLocator().registerInstance(Request, request);
2472
- getServiceLocator().registerInstance(Reply, reply);
2473
- getServiceLocator().registerInstance(
2474
- ExecutionContextToken,
2475
- executionContext
2476
- );
2477
- executionContext.provideRequest(request);
2478
- executionContext.provideReply(reply);
2479
- const controllerInstance = await inject(controller);
2480
- try {
2481
- const { query, params, body } = request;
2482
- const argument = {};
2483
- if (query && Object.keys(query).length > 0) {
2484
- argument.params = query;
2485
- }
2486
- if (params && Object.keys(params).length > 0) {
2487
- argument.urlParams = params;
2488
- }
2489
- if (body) {
2490
- argument.data = body;
2491
- }
2492
- await controllerInstance[endpointMetadata.classMethod](argument, reply);
2493
- } finally {
2494
- getServiceLocator().removeInstance(Request);
2495
- getServiceLocator().removeInstance(Reply);
2496
- getServiceLocator().removeInstance(ExecutionContextToken);
2715
+ } else if (context.kind === "method") {
2716
+ const endpointMetadata = getEndpointMetadata(target, context);
2717
+ for (const guard of guards.reverse()) {
2718
+ endpointMetadata.guards.add(guard);
2497
2719
  }
2498
- };
2499
- }
2500
- provideHandlerForMultipart(controller, executionContext, endpointMetadata) {
2501
- const config = endpointMetadata.config;
2502
- const requestSchema = config.requestSchema;
2503
- const shape = requestSchema._def.shape();
2504
- return async (request, reply) => {
2505
- getServiceLocator().registerInstance(Request, request);
2506
- getServiceLocator().registerInstance(Reply, reply);
2507
- getServiceLocator().registerInstance(
2508
- ExecutionContextToken,
2509
- executionContext
2720
+ } else {
2721
+ throw new Error(
2722
+ "[Navios] @UseGuards decorator can only be used on classes or methods."
2510
2723
  );
2511
- executionContext.provideRequest(request);
2512
- executionContext.provideReply(reply);
2513
- const controllerInstance = await inject(controller);
2514
- try {
2515
- const parts = request.parts();
2516
- const { query, params } = request;
2517
- const argument = {};
2518
- if (query && Object.keys(query).length > 0) {
2519
- argument.params = query;
2520
- }
2521
- if (params && Object.keys(params).length > 0) {
2522
- argument.urlParams = params;
2523
- }
2524
- const req = {};
2525
- for await (const part of parts) {
2526
- if (!shape[part.fieldname]) {
2527
- throw new import_common4.NaviosException(
2528
- `Invalid field name ${part.fieldname} for multipart request`
2529
- );
2530
- }
2531
- const schema = shape[part.fieldname];
2532
- if (part.type === "file") {
2533
- const file = new File([await part.toBuffer()], part.filename, {
2534
- type: part.mimetype
2535
- });
2536
- if (schema instanceof import_zod6.ZodArray) {
2537
- if (!req[part.fieldname]) {
2538
- req[part.fieldname] = [];
2539
- }
2540
- req[part.fieldname].push(file);
2541
- } else {
2542
- req[part.fieldname] = file;
2543
- }
2544
- } else {
2545
- if (schema instanceof import_zod6.ZodArray) {
2546
- if (!req[part.fieldname]) {
2547
- req[part.fieldname] = [];
2548
- }
2549
- req[part.fieldname].push(part.value);
2550
- } else {
2551
- req[part.fieldname] = part.value;
2552
- }
2553
- }
2554
- }
2555
- argument.data = requestSchema.parse(req);
2556
- const result = await controllerInstance[endpointMetadata.classMethod](argument);
2557
- reply.status(endpointMetadata.successStatusCode).headers(endpointMetadata.headers).send(result);
2558
- } finally {
2559
- getServiceLocator().removeInstance(Request);
2560
- getServiceLocator().removeInstance(Reply);
2561
- getServiceLocator().removeInstance(ExecutionContextToken);
2562
- }
2563
- };
2564
- }
2565
- };
2566
- _init6 = __decoratorStart(null);
2567
- _ControllerAdapterService = __decorateElement(_init6, 0, "ControllerAdapterService", _ControllerAdapterService_decorators, _ControllerAdapterService);
2568
- __runInitializers(_init6, 1, _ControllerAdapterService);
2569
- var ControllerAdapterService = _ControllerAdapterService;
2570
-
2571
- // packages/core/src/services/module-loader.service.mts
2572
- var _ModuleLoaderService_decorators, _init7;
2573
- _ModuleLoaderService_decorators = [Injectable()];
2574
- var _ModuleLoaderService = class _ModuleLoaderService {
2575
- logger = syncInject(Logger, {
2576
- context: _ModuleLoaderService.name
2577
- });
2578
- modulesMetadata = /* @__PURE__ */ new Map();
2579
- loadedModules = /* @__PURE__ */ new Map();
2580
- initialized = false;
2581
- async loadModules(appModule) {
2582
- if (this.initialized) {
2583
- return;
2584
- }
2585
- await this.traverseModules(appModule);
2586
- this.initialized = true;
2587
- }
2588
- async traverseModules(module2, parentMetadata) {
2589
- const metadata = extractModuleMetadata(module2);
2590
- if (parentMetadata) {
2591
- this.mergeMetadata(metadata, parentMetadata);
2592
- }
2593
- const moduleName = module2.name;
2594
- if (this.modulesMetadata.has(moduleName)) {
2595
- return;
2596
- }
2597
- this.modulesMetadata.set(moduleName, metadata);
2598
- const imports = metadata.imports ?? /* @__PURE__ */ new Set();
2599
- const loadingPromises = Array.from(imports).map(
2600
- async (importedModule) => this.traverseModules(importedModule, metadata)
2601
- );
2602
- await Promise.all(loadingPromises);
2603
- const instance = await inject(module2);
2604
- if (instance.onModuleInit) {
2605
- await instance.onModuleInit();
2606
- }
2607
- this.logger.debug(`Module ${moduleName} loaded`);
2608
- this.loadedModules.set(moduleName, instance);
2609
- }
2610
- mergeMetadata(metadata, parentMetadata) {
2611
- if (parentMetadata.guards) {
2612
- for (const guard of parentMetadata.guards) {
2613
- metadata.guards.add(guard);
2614
- }
2615
- }
2616
- if (parentMetadata.customAttributes) {
2617
- for (const [key, value] of parentMetadata.customAttributes) {
2618
- if (metadata.customAttributes.has(key)) {
2619
- continue;
2620
- }
2621
- metadata.customAttributes.set(key, value);
2622
- }
2623
2724
  }
2624
- }
2625
- getAllModules() {
2626
- return this.modulesMetadata;
2627
- }
2628
- dispose() {
2629
- this.modulesMetadata.clear();
2630
- this.loadedModules.clear();
2631
- this.initialized = false;
2632
- }
2633
- };
2634
- _init7 = __decoratorStart(null);
2635
- _ModuleLoaderService = __decorateElement(_init7, 0, "ModuleLoaderService", _ModuleLoaderService_decorators, _ModuleLoaderService);
2636
- __runInitializers(_init7, 1, _ModuleLoaderService);
2637
- var ModuleLoaderService = _ModuleLoaderService;
2725
+ return target;
2726
+ };
2727
+ }
2638
2728
 
2639
2729
  // packages/core/src/attribute.factory.mts
2640
2730
  var AttributeFactory = class {
@@ -2698,7 +2788,7 @@ var import_cors = __toESM(require("@fastify/cors"), 1);
2698
2788
  var import_multipart = __toESM(require("@fastify/multipart"), 1);
2699
2789
  var import_fastify = require("fastify");
2700
2790
  var import_fastify_type_provider_zod = require("fastify-type-provider-zod");
2701
- var _NaviosApplication_decorators, _init8;
2791
+ var _NaviosApplication_decorators, _init11;
2702
2792
  _NaviosApplication_decorators = [Injectable()];
2703
2793
  var _NaviosApplication = class _NaviosApplication {
2704
2794
  moduleLoader = syncInject(ModuleLoaderService);
@@ -2790,7 +2880,7 @@ var _NaviosApplication = class _NaviosApplication {
2790
2880
  message: "Not Found",
2791
2881
  error: "NotFound"
2792
2882
  };
2793
- this.logger.error(`Route not found: ${req.url}`);
2883
+ this.logger.error(`Route not found: [${req.method}] ${req.url}`);
2794
2884
  return reply.status(404).send(response);
2795
2885
  });
2796
2886
  }
@@ -2811,15 +2901,14 @@ var _NaviosApplication = class _NaviosApplication {
2811
2901
  }
2812
2902
  promises.push(
2813
2903
  this.server.register(
2814
- (instance, opts, done) => {
2904
+ async (instance, opts) => {
2815
2905
  for (const controller of moduleMetadata.controllers) {
2816
- this.controllerAdapter.setupController(
2906
+ await this.controllerAdapter.setupController(
2817
2907
  controller,
2818
2908
  instance,
2819
2909
  moduleMetadata
2820
2910
  );
2821
2911
  }
2822
- done();
2823
2912
  },
2824
2913
  {
2825
2914
  prefix: this.globalPrefix ?? ""
@@ -2864,9 +2953,9 @@ var _NaviosApplication = class _NaviosApplication {
2864
2953
  await this.dispose();
2865
2954
  }
2866
2955
  };
2867
- _init8 = __decoratorStart(null);
2868
- _NaviosApplication = __decorateElement(_init8, 0, "NaviosApplication", _NaviosApplication_decorators, _NaviosApplication);
2869
- __runInitializers(_init8, 1, _NaviosApplication);
2956
+ _init11 = __decoratorStart(null);
2957
+ _NaviosApplication = __decorateElement(_init11, 0, "NaviosApplication", _NaviosApplication_decorators, _NaviosApplication);
2958
+ __runInitializers(_init11, 1, _NaviosApplication);
2870
2959
  var NaviosApplication = _NaviosApplication;
2871
2960
 
2872
2961
  // packages/core/src/navios.factory.mts
@@ -2903,8 +2992,9 @@ var NaviosFactory = class {
2903
2992
  ControllerAdapterService,
2904
2993
  ControllerMetadataKey,
2905
2994
  Endpoint,
2995
+ EndpointAdapterService,
2996
+ EndpointAdapterToken,
2906
2997
  EndpointMetadataKey,
2907
- EndpointType,
2908
2998
  ErrorsEnum,
2909
2999
  EventEmitter,
2910
3000
  ExecutionContext,
@@ -2937,6 +3027,8 @@ var NaviosFactory = class {
2937
3027
  ModuleLoaderService,
2938
3028
  ModuleMetadataKey,
2939
3029
  Multipart,
3030
+ MultipartAdapterService,
3031
+ MultipartAdapterToken,
2940
3032
  NaviosApplication,
2941
3033
  NaviosFactory,
2942
3034
  NotFoundException,
@@ -2949,6 +3041,8 @@ var NaviosFactory = class {
2949
3041
  ServiceLocatorInstanceHolderStatus,
2950
3042
  ServiceLocatorManager,
2951
3043
  Stream,
3044
+ StreamAdapterService,
3045
+ StreamAdapterToken,
2952
3046
  UnauthorizedException,
2953
3047
  UnknownError,
2954
3048
  UseGuards,