@navios/core 0.9.3 → 1.0.0-alpha.2
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.
- package/CHANGELOG.md +58 -0
- package/README.md +4 -2
- package/docs/README.md +3 -1
- package/docs/exceptions.md +37 -1
- package/lib/{index-B2ulzZIr.d.cts → index-BJjk2X1S.d.mts} +478 -33
- package/lib/index-BJjk2X1S.d.mts.map +1 -0
- package/lib/{index-C8lUQePd.d.mts → index-DZ6NU03y.d.cts} +478 -33
- package/lib/index-DZ6NU03y.d.cts.map +1 -0
- package/lib/index.cjs +37 -2
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +3 -3
- package/lib/legacy-compat/index.cjs +8 -6
- package/lib/legacy-compat/index.cjs.map +1 -1
- package/lib/legacy-compat/index.d.cts +11 -16
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +11 -16
- package/lib/legacy-compat/index.d.mts.map +1 -1
- package/lib/legacy-compat/index.mjs +7 -5
- package/lib/legacy-compat/index.mjs.map +1 -1
- package/lib/{src-Cu9OAnfp.cjs → src-C46ePe3d.cjs} +1970 -171
- package/lib/src-C46ePe3d.cjs.map +1 -0
- package/lib/{src-Baabu2R8.mjs → src-K2k0riYJ.mjs} +1941 -202
- package/lib/src-K2k0riYJ.mjs.map +1 -0
- package/lib/testing/index.cjs +2 -2
- package/lib/testing/index.d.cts +1 -1
- package/lib/testing/index.d.mts +1 -1
- package/lib/testing/index.mjs +2 -2
- package/lib/{use-guards.decorator-EvI2m2DK.cjs → use-guards.decorator-B6tghdxM.cjs} +7 -4
- package/lib/use-guards.decorator-B6tghdxM.cjs.map +1 -0
- package/lib/{use-guards.decorator-ChJVzYLW.mjs → use-guards.decorator-Be_QUx6b.mjs} +6 -3
- package/lib/use-guards.decorator-Be_QUx6b.mjs.map +1 -0
- package/package.json +3 -3
- package/src/__tests__/responders.spec.mts +339 -0
- package/src/decorators/endpoint.decorator.mts +49 -97
- package/src/decorators/module.decorator.mts +12 -0
- package/src/decorators/multipart.decorator.mts +62 -87
- package/src/decorators/stream.decorator.mts +66 -76
- package/src/index.mts +1 -0
- package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -2
- package/src/legacy-compat/decorators/endpoint.decorator.mts +21 -47
- package/src/legacy-compat/decorators/multipart.decorator.mts +20 -41
- package/src/legacy-compat/decorators/stream.decorator.mts +48 -42
- package/src/metadata/module.metadata.mts +2 -0
- package/src/responders/enums/framework-error.enum.mts +38 -0
- package/src/responders/enums/index.mts +1 -0
- package/src/responders/index.mts +4 -0
- package/src/responders/interfaces/error-responder.interface.mts +42 -0
- package/src/responders/interfaces/error-response.interface.mts +22 -0
- package/src/responders/interfaces/index.mts +3 -0
- package/src/responders/interfaces/problem-details.interface.mts +34 -0
- package/src/responders/services/error-response-producer.service.mts +143 -0
- package/src/responders/services/forbidden-responder.service.mts +77 -0
- package/src/responders/services/index.mts +5 -0
- package/src/responders/services/internal-server-error-responder.service.mts +57 -0
- package/src/responders/services/not-found-responder.service.mts +76 -0
- package/src/responders/services/validation-error-responder.service.mts +78 -0
- package/src/responders/tokens/index.mts +1 -0
- package/src/responders/tokens/responder.tokens.mts +84 -0
- package/src/services/guard-runner.service.mts +19 -6
- package/src/services/module-loader.service.mts +63 -0
- package/lib/index-B2ulzZIr.d.cts.map +0 -1
- package/lib/index-C8lUQePd.d.mts.map +0 -1
- package/lib/src-Baabu2R8.mjs.map +0 -1
- package/lib/src-Cu9OAnfp.cjs.map +0 -1
- package/lib/use-guards.decorator-ChJVzYLW.mjs.map +0 -1
- package/lib/use-guards.decorator-EvI2m2DK.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as extractModuleMetadata, M as getEndpointMetadata, O as getControllerMetadata, T as hasModuleMetadata, _ as EndpointAdapterToken, b as getManagedMetadata, c as XmlStreamAdapterToken, d as Reply, f as NaviosOptionsToken, k as hasControllerMetadata, l as StreamAdapterToken, m as HttpAdapterToken, p as MultipartAdapterToken, u as Request, w as getModuleMetadata, x as hasManagedMetadata } from "./use-guards.decorator-
|
|
1
|
+
import { C as extractModuleMetadata, M as getEndpointMetadata, O as getControllerMetadata, T as hasModuleMetadata, _ as EndpointAdapterToken, b as getManagedMetadata, c as XmlStreamAdapterToken, d as Reply, f as NaviosOptionsToken, k as hasControllerMetadata, l as StreamAdapterToken, m as HttpAdapterToken, p as MultipartAdapterToken, u as Request, w as getModuleMetadata, x as hasManagedMetadata } from "./use-guards.decorator-Be_QUx6b.mjs";
|
|
2
2
|
import { Container, Factory, Injectable, InjectableScope, InjectionToken, getInjectableToken, inject } from "@navios/di";
|
|
3
3
|
import { env } from "node:process";
|
|
4
|
-
import z, { z as z$1 } from "zod/v4";
|
|
4
|
+
import z, { ZodError, treeifyError, z as z$1 } from "zod/v4";
|
|
5
5
|
import { NaviosError } from "@navios/builder";
|
|
6
6
|
import { inspect } from "util";
|
|
7
7
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -201,7 +201,7 @@ function getRequestIdStore() {
|
|
|
201
201
|
|
|
202
202
|
//#endregion
|
|
203
203
|
//#region src/logger/console-logger.service.mts
|
|
204
|
-
function applyDecs2203RFactory$
|
|
204
|
+
function applyDecs2203RFactory$19() {
|
|
205
205
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
206
206
|
return function addInitializer(initializer) {
|
|
207
207
|
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
@@ -475,10 +475,10 @@ function applyDecs2203RFactory$14() {
|
|
|
475
475
|
};
|
|
476
476
|
};
|
|
477
477
|
}
|
|
478
|
-
function _apply_decs_2203_r$
|
|
479
|
-
return (_apply_decs_2203_r$
|
|
478
|
+
function _apply_decs_2203_r$19(targetClass, memberDecs, classDecs, parentClass) {
|
|
479
|
+
return (_apply_decs_2203_r$19 = applyDecs2203RFactory$19())(targetClass, memberDecs, classDecs, parentClass);
|
|
480
480
|
}
|
|
481
|
-
var _dec$
|
|
481
|
+
var _dec$19, _initClass$19;
|
|
482
482
|
const DEFAULT_DEPTH = 5;
|
|
483
483
|
const DEFAULT_LOG_LEVELS = [
|
|
484
484
|
"log",
|
|
@@ -497,10 +497,10 @@ const dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
|
|
|
497
497
|
month: "2-digit"
|
|
498
498
|
});
|
|
499
499
|
let _ConsoleLogger;
|
|
500
|
-
_dec$
|
|
500
|
+
_dec$19 = Injectable({ token: LoggerOutput });
|
|
501
501
|
var ConsoleLogger = class {
|
|
502
502
|
static {
|
|
503
|
-
({c: [_ConsoleLogger, _initClass$
|
|
503
|
+
({c: [_ConsoleLogger, _initClass$19]} = _apply_decs_2203_r$19(this, [], [_dec$19]));
|
|
504
504
|
}
|
|
505
505
|
/**
|
|
506
506
|
* The options of the logger.
|
|
@@ -749,13 +749,13 @@ var ConsoleLogger = class {
|
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
751
|
static {
|
|
752
|
-
_initClass$
|
|
752
|
+
_initClass$19();
|
|
753
753
|
}
|
|
754
754
|
};
|
|
755
755
|
|
|
756
756
|
//#endregion
|
|
757
757
|
//#region src/logger/logger.service.mts
|
|
758
|
-
function applyDecs2203RFactory$
|
|
758
|
+
function applyDecs2203RFactory$18() {
|
|
759
759
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
760
760
|
return function addInitializer(initializer) {
|
|
761
761
|
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
@@ -1029,15 +1029,15 @@ function applyDecs2203RFactory$13() {
|
|
|
1029
1029
|
};
|
|
1030
1030
|
};
|
|
1031
1031
|
}
|
|
1032
|
-
function _apply_decs_2203_r$
|
|
1033
|
-
return (_apply_decs_2203_r$
|
|
1032
|
+
function _apply_decs_2203_r$18(targetClass, memberDecs, classDecs, parentClass) {
|
|
1033
|
+
return (_apply_decs_2203_r$18 = applyDecs2203RFactory$18())(targetClass, memberDecs, classDecs, parentClass);
|
|
1034
1034
|
}
|
|
1035
|
-
var _dec$
|
|
1035
|
+
var _dec$18, _initClass$18;
|
|
1036
1036
|
let _LoggerInstance;
|
|
1037
|
-
_dec$
|
|
1037
|
+
_dec$18 = Injectable({ token: Logger });
|
|
1038
1038
|
var LoggerInstance = class {
|
|
1039
1039
|
static {
|
|
1040
|
-
({c: [_LoggerInstance, _initClass$
|
|
1040
|
+
({c: [_LoggerInstance, _initClass$18]} = _apply_decs_2203_r$18(this, [], [_dec$18]));
|
|
1041
1041
|
}
|
|
1042
1042
|
constructor(config = {}) {
|
|
1043
1043
|
this.context = config.context;
|
|
@@ -1069,13 +1069,13 @@ var LoggerInstance = class {
|
|
|
1069
1069
|
this.localInstance?.fatal?.(message, ...optionalParams);
|
|
1070
1070
|
}
|
|
1071
1071
|
static {
|
|
1072
|
-
_initClass$
|
|
1072
|
+
_initClass$18();
|
|
1073
1073
|
}
|
|
1074
1074
|
};
|
|
1075
1075
|
|
|
1076
1076
|
//#endregion
|
|
1077
1077
|
//#region src/config/config.service.mts
|
|
1078
|
-
function applyDecs2203RFactory$
|
|
1078
|
+
function applyDecs2203RFactory$17() {
|
|
1079
1079
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
1080
1080
|
return function addInitializer(initializer) {
|
|
1081
1081
|
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
@@ -1349,10 +1349,10 @@ function applyDecs2203RFactory$12() {
|
|
|
1349
1349
|
};
|
|
1350
1350
|
};
|
|
1351
1351
|
}
|
|
1352
|
-
function _apply_decs_2203_r$
|
|
1353
|
-
return (_apply_decs_2203_r$
|
|
1352
|
+
function _apply_decs_2203_r$17(targetClass, memberDecs, classDecs, parentClass) {
|
|
1353
|
+
return (_apply_decs_2203_r$17 = applyDecs2203RFactory$17())(targetClass, memberDecs, classDecs, parentClass);
|
|
1354
1354
|
}
|
|
1355
|
-
var _dec$
|
|
1355
|
+
var _dec$17, _initClass$17;
|
|
1356
1356
|
/**
|
|
1357
1357
|
* Schema for validating configuration service options.
|
|
1358
1358
|
*/ const ConfigServiceOptionsSchema = z$1.record(z$1.string(), z$1.unknown());
|
|
@@ -1360,11 +1360,11 @@ var _dec$12, _initClass$12;
|
|
|
1360
1360
|
* Injection token for ConfigService.
|
|
1361
1361
|
*/ const ConfigServiceToken = InjectionToken.create(Symbol.for("ConfigService"), ConfigServiceOptionsSchema);
|
|
1362
1362
|
let _ConfigService;
|
|
1363
|
-
_dec$
|
|
1363
|
+
_dec$17 = Injectable({ token: ConfigServiceToken });
|
|
1364
1364
|
var ConfigService = class {
|
|
1365
1365
|
config;
|
|
1366
1366
|
static {
|
|
1367
|
-
({c: [_ConfigService, _initClass$
|
|
1367
|
+
({c: [_ConfigService, _initClass$17]} = _apply_decs_2203_r$17(this, [], [_dec$17]));
|
|
1368
1368
|
}
|
|
1369
1369
|
/**
|
|
1370
1370
|
* Creates a new ConfigService instance.
|
|
@@ -1446,7 +1446,7 @@ var ConfigService = class {
|
|
|
1446
1446
|
return value;
|
|
1447
1447
|
}
|
|
1448
1448
|
static {
|
|
1449
|
-
_initClass$
|
|
1449
|
+
_initClass$17();
|
|
1450
1450
|
}
|
|
1451
1451
|
};
|
|
1452
1452
|
|
|
@@ -1707,8 +1707,114 @@ var ConfigService = class {
|
|
|
1707
1707
|
};
|
|
1708
1708
|
|
|
1709
1709
|
//#endregion
|
|
1710
|
-
//#region src/
|
|
1711
|
-
|
|
1710
|
+
//#region src/responders/enums/framework-error.enum.mts
|
|
1711
|
+
/**
|
|
1712
|
+
* Enumeration of framework-level error types.
|
|
1713
|
+
* Used to explicitly specify which error responder should handle an error.
|
|
1714
|
+
*
|
|
1715
|
+
* @example
|
|
1716
|
+
* ```typescript
|
|
1717
|
+
* // In adapter error handling
|
|
1718
|
+
* if (error instanceof ZodError) {
|
|
1719
|
+
* return errorProducer.respond(FrameworkError.ValidationError, error)
|
|
1720
|
+
* }
|
|
1721
|
+
* return errorProducer.handleUnknown(error)
|
|
1722
|
+
* ```
|
|
1723
|
+
*/ var FrameworkError = /* @__PURE__ */ function(FrameworkError$1) {
|
|
1724
|
+
/**
|
|
1725
|
+
* Resource not found (HTTP 404).
|
|
1726
|
+
* Use when a requested resource does not exist.
|
|
1727
|
+
*/ FrameworkError$1["NotFound"] = "NotFound";
|
|
1728
|
+
/**
|
|
1729
|
+
* Forbidden (HTTP 403).
|
|
1730
|
+
* Use when access to a resource is denied (e.g., guard rejection).
|
|
1731
|
+
*/ FrameworkError$1["Forbidden"] = "Forbidden";
|
|
1732
|
+
/**
|
|
1733
|
+
* Internal server error (HTTP 500).
|
|
1734
|
+
* Use for unexpected errors that don't fit other categories.
|
|
1735
|
+
*/ FrameworkError$1["InternalServerError"] = "InternalServerError";
|
|
1736
|
+
/**
|
|
1737
|
+
* Validation error (HTTP 400).
|
|
1738
|
+
* Use when request data fails validation (e.g., Zod errors).
|
|
1739
|
+
*/ FrameworkError$1["ValidationError"] = "ValidationError";
|
|
1740
|
+
return FrameworkError$1;
|
|
1741
|
+
}({});
|
|
1742
|
+
|
|
1743
|
+
//#endregion
|
|
1744
|
+
//#region src/responders/tokens/responder.tokens.mts
|
|
1745
|
+
/**
|
|
1746
|
+
* Injection token for the Internal Server Error responder.
|
|
1747
|
+
* Default implementation returns HTTP 500 with RFC 7807 Problem Details.
|
|
1748
|
+
*
|
|
1749
|
+
* @example Override with custom implementation:
|
|
1750
|
+
* ```typescript
|
|
1751
|
+
* @Injectable({
|
|
1752
|
+
* token: InternalServerErrorResponderToken,
|
|
1753
|
+
* priority: 0, // Higher than default -10
|
|
1754
|
+
* })
|
|
1755
|
+
* export class CustomInternalErrorResponder implements ErrorResponder {
|
|
1756
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
1757
|
+
* // Custom implementation
|
|
1758
|
+
* }
|
|
1759
|
+
* }
|
|
1760
|
+
* ```
|
|
1761
|
+
*/ const InternalServerErrorResponderToken = InjectionToken.create("InternalServerErrorResponder");
|
|
1762
|
+
/**
|
|
1763
|
+
* Injection token for the Not Found responder.
|
|
1764
|
+
* Default implementation returns HTTP 404 with RFC 7807 Problem Details.
|
|
1765
|
+
*
|
|
1766
|
+
* @example Override with custom implementation:
|
|
1767
|
+
* ```typescript
|
|
1768
|
+
* @Injectable({
|
|
1769
|
+
* token: NotFoundResponderToken,
|
|
1770
|
+
* priority: 0, // Higher than default -10
|
|
1771
|
+
* })
|
|
1772
|
+
* export class CustomNotFoundResponder implements ErrorResponder {
|
|
1773
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
1774
|
+
* // Custom implementation
|
|
1775
|
+
* }
|
|
1776
|
+
* }
|
|
1777
|
+
* ```
|
|
1778
|
+
*/ const NotFoundResponderToken = InjectionToken.create("NotFoundResponder");
|
|
1779
|
+
/**
|
|
1780
|
+
* Injection token for the Validation Error responder.
|
|
1781
|
+
* Default implementation returns HTTP 400 with RFC 7807 Problem Details
|
|
1782
|
+
* and includes validation errors from ZodError.
|
|
1783
|
+
*
|
|
1784
|
+
* @example Override with custom implementation:
|
|
1785
|
+
* ```typescript
|
|
1786
|
+
* @Injectable({
|
|
1787
|
+
* token: ValidationErrorResponderToken,
|
|
1788
|
+
* priority: 0, // Higher than default -10
|
|
1789
|
+
* })
|
|
1790
|
+
* export class CustomValidationResponder implements ErrorResponder {
|
|
1791
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
1792
|
+
* // Custom implementation
|
|
1793
|
+
* }
|
|
1794
|
+
* }
|
|
1795
|
+
* ```
|
|
1796
|
+
*/ const ValidationErrorResponderToken = InjectionToken.create("ValidationErrorResponder");
|
|
1797
|
+
/**
|
|
1798
|
+
* Injection token for the Forbidden responder.
|
|
1799
|
+
* Default implementation returns HTTP 403 with RFC 7807 Problem Details.
|
|
1800
|
+
*
|
|
1801
|
+
* @example Override with custom implementation:
|
|
1802
|
+
* ```typescript
|
|
1803
|
+
* @Injectable({
|
|
1804
|
+
* token: ForbiddenResponderToken,
|
|
1805
|
+
* priority: 0, // Higher than default -10
|
|
1806
|
+
* })
|
|
1807
|
+
* export class CustomForbiddenResponder implements ErrorResponder {
|
|
1808
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
1809
|
+
* // Custom implementation
|
|
1810
|
+
* }
|
|
1811
|
+
* }
|
|
1812
|
+
* ```
|
|
1813
|
+
*/ const ForbiddenResponderToken = InjectionToken.create("ForbiddenResponder");
|
|
1814
|
+
|
|
1815
|
+
//#endregion
|
|
1816
|
+
//#region src/responders/services/error-response-producer.service.mts
|
|
1817
|
+
function applyDecs2203RFactory$16() {
|
|
1712
1818
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
1713
1819
|
return function addInitializer(initializer) {
|
|
1714
1820
|
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
@@ -1982,87 +2088,91 @@ function applyDecs2203RFactory$11() {
|
|
|
1982
2088
|
};
|
|
1983
2089
|
};
|
|
1984
2090
|
}
|
|
1985
|
-
function _apply_decs_2203_r$
|
|
1986
|
-
return (_apply_decs_2203_r$
|
|
2091
|
+
function _apply_decs_2203_r$16(targetClass, memberDecs, classDecs, parentClass) {
|
|
2092
|
+
return (_apply_decs_2203_r$16 = applyDecs2203RFactory$16())(targetClass, memberDecs, classDecs, parentClass);
|
|
1987
2093
|
}
|
|
1988
|
-
var _dec$
|
|
1989
|
-
let
|
|
1990
|
-
_dec$
|
|
1991
|
-
var
|
|
2094
|
+
var _dec$16, _initClass$16;
|
|
2095
|
+
let _ErrorResponseProducerService;
|
|
2096
|
+
_dec$16 = Injectable();
|
|
2097
|
+
var ErrorResponseProducerService = class {
|
|
1992
2098
|
static {
|
|
1993
|
-
({c: [
|
|
2099
|
+
({c: [_ErrorResponseProducerService, _initClass$16]} = _apply_decs_2203_r$16(this, [], [_dec$16]));
|
|
1994
2100
|
}
|
|
1995
|
-
|
|
2101
|
+
forbiddenResponder = inject(ForbiddenResponderToken);
|
|
2102
|
+
internalServerErrorResponder = inject(InternalServerErrorResponderToken);
|
|
2103
|
+
notFoundResponder = inject(NotFoundResponderToken);
|
|
2104
|
+
validationErrorResponder = inject(ValidationErrorResponderToken);
|
|
1996
2105
|
/**
|
|
1997
|
-
*
|
|
1998
|
-
* request scope based on its dependencies.
|
|
2106
|
+
* Produces an error response for a specific framework error type.
|
|
1999
2107
|
*
|
|
2000
|
-
* @param
|
|
2001
|
-
* @
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
this.
|
|
2108
|
+
* @param type - The type of framework error (from FrameworkError enum)
|
|
2109
|
+
* @param error - The original error that was thrown
|
|
2110
|
+
* @param description - Optional custom description to include in the response
|
|
2111
|
+
* @returns ErrorResponse with status code, RFC 7807 payload, and headers
|
|
2112
|
+
*/ respond(type, error, description) {
|
|
2113
|
+
switch (type) {
|
|
2114
|
+
case FrameworkError.NotFound: return this.notFoundResponder.getResponse(error, description);
|
|
2115
|
+
case FrameworkError.Forbidden: return this.forbiddenResponder.getResponse(error, description);
|
|
2116
|
+
case FrameworkError.InternalServerError: return this.internalServerErrorResponder.getResponse(error, description);
|
|
2117
|
+
case FrameworkError.ValidationError: return this.validationErrorResponder.getResponse(error, description);
|
|
2009
2118
|
}
|
|
2010
|
-
return {
|
|
2011
|
-
cached: cachedInstance !== null,
|
|
2012
|
-
instance: cachedInstance,
|
|
2013
|
-
resolve: (scoped) => scoped.get(classType)
|
|
2014
|
-
};
|
|
2015
2119
|
}
|
|
2016
2120
|
/**
|
|
2017
|
-
*
|
|
2018
|
-
* request scope based on their dependencies.
|
|
2121
|
+
* Handles unknown errors by producing an Internal Server Error response.
|
|
2019
2122
|
*
|
|
2020
|
-
*
|
|
2021
|
-
*
|
|
2123
|
+
* Use this as a fallback when the error type is not known or doesn't
|
|
2124
|
+
* match any specific framework error type.
|
|
2022
2125
|
*
|
|
2023
|
-
* @param
|
|
2024
|
-
* @
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2126
|
+
* @param error - The original error that was thrown
|
|
2127
|
+
* @param description - Optional custom description to include in the response
|
|
2128
|
+
* @returns ErrorResponse with 500 status code
|
|
2129
|
+
*/ handleUnknown(error, description) {
|
|
2130
|
+
return this.internalServerErrorResponder.getResponse(error, description);
|
|
2131
|
+
}
|
|
2132
|
+
/**
|
|
2133
|
+
* Convenience method to produce a Not Found error response.
|
|
2134
|
+
*
|
|
2135
|
+
* @param error - The original error that was thrown
|
|
2136
|
+
* @param description - Optional custom description
|
|
2137
|
+
* @returns ErrorResponse with 404 status code
|
|
2138
|
+
*/ notFound(error, description) {
|
|
2139
|
+
return this.notFoundResponder.getResponse(error, description);
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* Convenience method to produce a Validation Error response.
|
|
2143
|
+
*
|
|
2144
|
+
* @param error - The original error (typically a ZodError)
|
|
2145
|
+
* @param description - Optional custom description
|
|
2146
|
+
* @returns ErrorResponse with 400 status code
|
|
2147
|
+
*/ validationError(error, description) {
|
|
2148
|
+
return this.validationErrorResponder.getResponse(error, description);
|
|
2149
|
+
}
|
|
2150
|
+
/**
|
|
2151
|
+
* Convenience method to produce an Internal Server Error response.
|
|
2152
|
+
*
|
|
2153
|
+
* @param error - The original error
|
|
2154
|
+
* @param description - Optional custom description
|
|
2155
|
+
* @returns ErrorResponse with 500 status code
|
|
2156
|
+
*/ internalServerError(error, description) {
|
|
2157
|
+
return this.internalServerErrorResponder.getResponse(error, description);
|
|
2158
|
+
}
|
|
2159
|
+
/**
|
|
2160
|
+
* Convenience method to produce a Forbidden error response.
|
|
2161
|
+
*
|
|
2162
|
+
* @param error - The original error
|
|
2163
|
+
* @param description - Optional custom description
|
|
2164
|
+
* @returns ErrorResponse with 403 status code
|
|
2165
|
+
*/ forbidden(error, description) {
|
|
2166
|
+
return this.forbiddenResponder.getResponse(error, description);
|
|
2054
2167
|
}
|
|
2055
2168
|
static {
|
|
2056
|
-
_initClass$
|
|
2169
|
+
_initClass$16();
|
|
2057
2170
|
}
|
|
2058
2171
|
};
|
|
2059
|
-
/**
|
|
2060
|
-
* @deprecated Use InstanceResolverService instead
|
|
2061
|
-
*/ const ControllerResolverService = _InstanceResolverService;
|
|
2062
2172
|
|
|
2063
2173
|
//#endregion
|
|
2064
|
-
//#region src/services/
|
|
2065
|
-
function applyDecs2203RFactory$
|
|
2174
|
+
//#region src/responders/services/forbidden-responder.service.mts
|
|
2175
|
+
function applyDecs2203RFactory$15() {
|
|
2066
2176
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
2067
2177
|
return function addInitializer(initializer) {
|
|
2068
2178
|
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
@@ -2336,77 +2446,46 @@ function applyDecs2203RFactory$10() {
|
|
|
2336
2446
|
};
|
|
2337
2447
|
};
|
|
2338
2448
|
}
|
|
2339
|
-
function _apply_decs_2203_r$
|
|
2340
|
-
return (_apply_decs_2203_r$
|
|
2449
|
+
function _apply_decs_2203_r$15(targetClass, memberDecs, classDecs, parentClass) {
|
|
2450
|
+
return (_apply_decs_2203_r$15 = applyDecs2203RFactory$15())(targetClass, memberDecs, classDecs, parentClass);
|
|
2341
2451
|
}
|
|
2342
|
-
var _dec$
|
|
2343
|
-
let
|
|
2344
|
-
_dec$
|
|
2345
|
-
|
|
2452
|
+
var _dec$15, _initClass$15;
|
|
2453
|
+
let _ForbiddenResponderService;
|
|
2454
|
+
_dec$15 = Injectable({
|
|
2455
|
+
token: ForbiddenResponderToken,
|
|
2456
|
+
priority: -10
|
|
2457
|
+
});
|
|
2458
|
+
var ForbiddenResponderService = class {
|
|
2346
2459
|
static {
|
|
2347
|
-
({c: [
|
|
2348
|
-
}
|
|
2349
|
-
logger = inject(Logger, { context: _GuardRunnerService.name });
|
|
2350
|
-
/**
|
|
2351
|
-
* Runs guards that need to be resolved from a scoped container.
|
|
2352
|
-
* Use this when guards have request-scoped dependencies.
|
|
2353
|
-
*/ async runGuards(allGuards, executionContext, context) {
|
|
2354
|
-
const guardsArray = Array.from(allGuards).reverse();
|
|
2355
|
-
const guardInstances = await Promise.all(guardsArray.map(async (guard) => {
|
|
2356
|
-
const guardInstance = await context.get(guard);
|
|
2357
|
-
if (!guardInstance.canActivate) throw new Error(`[Navios] Guard ${guard.name} does not implement canActivate()`);
|
|
2358
|
-
return guardInstance;
|
|
2359
|
-
}));
|
|
2360
|
-
return this.executeGuards(guardInstances, executionContext);
|
|
2361
|
-
}
|
|
2362
|
-
/**
|
|
2363
|
-
* Runs pre-resolved guard instances.
|
|
2364
|
-
* Use this when all guards are singletons and have been pre-resolved at startup.
|
|
2365
|
-
*/ async runGuardsStatic(guardInstances, executionContext) {
|
|
2366
|
-
return this.executeGuards(guardInstances, executionContext);
|
|
2460
|
+
({c: [_ForbiddenResponderService, _initClass$15]} = _apply_decs_2203_r$15(this, [], [_dec$15]));
|
|
2367
2461
|
}
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
let canActivate = true;
|
|
2373
|
-
for (const guardInstance of guardInstances) try {
|
|
2374
|
-
canActivate = await guardInstance.canActivate(executionContext);
|
|
2375
|
-
if (!canActivate) break;
|
|
2376
|
-
} catch (error) {
|
|
2377
|
-
if (error instanceof HttpException) {
|
|
2378
|
-
executionContext.getReply().status(error.statusCode).send(error.response);
|
|
2379
|
-
return false;
|
|
2380
|
-
} else {
|
|
2381
|
-
this.logger.error("Error running guard", error);
|
|
2382
|
-
executionContext.getReply().status(500).send({ message: "Internal server error" });
|
|
2383
|
-
return false;
|
|
2384
|
-
}
|
|
2385
|
-
}
|
|
2386
|
-
if (!canActivate) {
|
|
2387
|
-
executionContext.getReply().status(403).send({ message: "Forbidden" });
|
|
2388
|
-
return false;
|
|
2462
|
+
getResponse(error, description) {
|
|
2463
|
+
if (description) return this.createResponse(description);
|
|
2464
|
+
if (error && typeof error === "object" && "response" in error && error.response) {
|
|
2465
|
+
if (typeof error.response === "string") return this.createResponse(error.response);
|
|
2389
2466
|
}
|
|
2390
|
-
return
|
|
2467
|
+
return this.createResponse("Access to this resource is forbidden");
|
|
2391
2468
|
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2469
|
+
createResponse(detail) {
|
|
2470
|
+
return {
|
|
2471
|
+
statusCode: 403,
|
|
2472
|
+
payload: {
|
|
2473
|
+
type: "about:blank",
|
|
2474
|
+
title: "Forbidden",
|
|
2475
|
+
status: 403,
|
|
2476
|
+
detail
|
|
2477
|
+
},
|
|
2478
|
+
headers: { "Content-Type": "application/problem+json" }
|
|
2479
|
+
};
|
|
2401
2480
|
}
|
|
2402
2481
|
static {
|
|
2403
|
-
_initClass$
|
|
2482
|
+
_initClass$15();
|
|
2404
2483
|
}
|
|
2405
2484
|
};
|
|
2406
2485
|
|
|
2407
2486
|
//#endregion
|
|
2408
|
-
//#region src/services/
|
|
2409
|
-
function applyDecs2203RFactory$
|
|
2487
|
+
//#region src/responders/services/internal-server-error-responder.service.mts
|
|
2488
|
+
function applyDecs2203RFactory$14() {
|
|
2410
2489
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
2411
2490
|
return function addInitializer(initializer) {
|
|
2412
2491
|
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
@@ -2680,63 +2759,1702 @@ function applyDecs2203RFactory$9() {
|
|
|
2680
2759
|
};
|
|
2681
2760
|
};
|
|
2682
2761
|
}
|
|
2683
|
-
function _apply_decs_2203_r$
|
|
2684
|
-
return (_apply_decs_2203_r$
|
|
2762
|
+
function _apply_decs_2203_r$14(targetClass, memberDecs, classDecs, parentClass) {
|
|
2763
|
+
return (_apply_decs_2203_r$14 = applyDecs2203RFactory$14())(targetClass, memberDecs, classDecs, parentClass);
|
|
2685
2764
|
}
|
|
2686
|
-
var _dec$
|
|
2687
|
-
let
|
|
2688
|
-
_dec$
|
|
2689
|
-
|
|
2765
|
+
var _dec$14, _initClass$14;
|
|
2766
|
+
let _InternalServerErrorResponderService;
|
|
2767
|
+
_dec$14 = Injectable({
|
|
2768
|
+
token: InternalServerErrorResponderToken,
|
|
2769
|
+
priority: -10
|
|
2770
|
+
});
|
|
2771
|
+
var InternalServerErrorResponderService = class {
|
|
2690
2772
|
static {
|
|
2691
|
-
({c: [
|
|
2773
|
+
({c: [_InternalServerErrorResponderService, _initClass$14]} = _apply_decs_2203_r$14(this, [], [_dec$14]));
|
|
2692
2774
|
}
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2775
|
+
getResponse(error, description) {
|
|
2776
|
+
const message = error instanceof Error ? error.message : "Internal Server Error";
|
|
2777
|
+
return {
|
|
2778
|
+
statusCode: 500,
|
|
2779
|
+
payload: {
|
|
2780
|
+
type: "about:blank",
|
|
2781
|
+
title: "Internal Server Error",
|
|
2782
|
+
status: 500,
|
|
2783
|
+
detail: description ?? message
|
|
2784
|
+
},
|
|
2785
|
+
headers: { "Content-Type": "application/problem+json" }
|
|
2786
|
+
};
|
|
2702
2787
|
}
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
*
|
|
2706
|
-
* This method is designed to be called by plugins during registration,
|
|
2707
|
-
* which happens after initial module loading but before route registration.
|
|
2708
|
-
*
|
|
2709
|
-
* @param extensions - Array of module extensions to add
|
|
2710
|
-
* @throws Error if not initialized (loadModules must be called first)
|
|
2711
|
-
*
|
|
2712
|
-
* @example
|
|
2713
|
-
* ```typescript
|
|
2714
|
-
* // In plugin registration
|
|
2715
|
-
* const moduleLoader = await context.container.get(ModuleLoaderService)
|
|
2716
|
-
* await moduleLoader.extendModules([{
|
|
2717
|
-
* controllers: [OpenApiJsonController, OpenApiYamlController],
|
|
2718
|
-
* moduleName: 'OpenApiBunModule',
|
|
2719
|
-
* }])
|
|
2720
|
-
* ```
|
|
2721
|
-
*/ async extendModules(extensions) {
|
|
2722
|
-
if (!this.initialized) throw new Error("ModuleLoaderService must be initialized before extending. Call loadModules() first.");
|
|
2723
|
-
for (const extension of extensions) if (extension.module) await this.traverseModules(extension.module);
|
|
2724
|
-
else if (extension.controllers && extension.moduleName) await this.registerControllers(extension.controllers, extension.moduleName);
|
|
2725
|
-
else if (extension.controllers) throw new Error("moduleName is required when providing controllers without a module");
|
|
2788
|
+
static {
|
|
2789
|
+
_initClass$14();
|
|
2726
2790
|
}
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2791
|
+
};
|
|
2792
|
+
|
|
2793
|
+
//#endregion
|
|
2794
|
+
//#region src/responders/services/not-found-responder.service.mts
|
|
2795
|
+
function applyDecs2203RFactory$13() {
|
|
2796
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
2797
|
+
return function addInitializer(initializer) {
|
|
2798
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
2799
|
+
assertCallable(initializer, "An initializer");
|
|
2800
|
+
initializers.push(initializer);
|
|
2801
|
+
};
|
|
2802
|
+
}
|
|
2803
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
2804
|
+
var kindStr;
|
|
2805
|
+
switch (kind) {
|
|
2806
|
+
case 1:
|
|
2807
|
+
kindStr = "accessor";
|
|
2808
|
+
break;
|
|
2809
|
+
case 2:
|
|
2810
|
+
kindStr = "method";
|
|
2811
|
+
break;
|
|
2812
|
+
case 3:
|
|
2813
|
+
kindStr = "getter";
|
|
2814
|
+
break;
|
|
2815
|
+
case 4:
|
|
2816
|
+
kindStr = "setter";
|
|
2817
|
+
break;
|
|
2818
|
+
default: kindStr = "field";
|
|
2819
|
+
}
|
|
2820
|
+
var ctx = {
|
|
2821
|
+
kind: kindStr,
|
|
2822
|
+
name: isPrivate ? "#" + name : name,
|
|
2823
|
+
static: isStatic,
|
|
2824
|
+
private: isPrivate,
|
|
2825
|
+
metadata
|
|
2826
|
+
};
|
|
2827
|
+
var decoratorFinishedRef = { v: false };
|
|
2828
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
2829
|
+
var get, set;
|
|
2830
|
+
if (kind === 0) if (isPrivate) {
|
|
2831
|
+
get = desc.get;
|
|
2832
|
+
set = desc.set;
|
|
2833
|
+
} else {
|
|
2834
|
+
get = function() {
|
|
2835
|
+
return this[name];
|
|
2836
|
+
};
|
|
2837
|
+
set = function(v) {
|
|
2838
|
+
this[name] = v;
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
else if (kind === 2) get = function() {
|
|
2842
|
+
return desc.value;
|
|
2843
|
+
};
|
|
2844
|
+
else {
|
|
2845
|
+
if (kind === 1 || kind === 3) get = function() {
|
|
2846
|
+
return desc.get.call(this);
|
|
2847
|
+
};
|
|
2848
|
+
if (kind === 1 || kind === 4) set = function(v) {
|
|
2849
|
+
desc.set.call(this, v);
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
2852
|
+
ctx.access = get && set ? {
|
|
2853
|
+
get,
|
|
2854
|
+
set
|
|
2855
|
+
} : get ? { get } : { set };
|
|
2856
|
+
try {
|
|
2857
|
+
return dec(value, ctx);
|
|
2858
|
+
} finally {
|
|
2859
|
+
decoratorFinishedRef.v = true;
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
2863
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
2864
|
+
}
|
|
2865
|
+
function assertCallable(fn, hint) {
|
|
2866
|
+
if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
|
|
2867
|
+
}
|
|
2868
|
+
function assertValidReturnValue(kind, value) {
|
|
2869
|
+
var type = typeof value;
|
|
2870
|
+
if (kind === 1) {
|
|
2871
|
+
if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
2872
|
+
if (value.get !== void 0) assertCallable(value.get, "accessor.get");
|
|
2873
|
+
if (value.set !== void 0) assertCallable(value.set, "accessor.set");
|
|
2874
|
+
if (value.init !== void 0) assertCallable(value.init, "accessor.init");
|
|
2875
|
+
} else if (type !== "function") {
|
|
2876
|
+
var hint;
|
|
2877
|
+
if (kind === 0) hint = "field";
|
|
2878
|
+
else if (kind === 10) hint = "class";
|
|
2879
|
+
else hint = "method";
|
|
2880
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
2884
|
+
var decs = decInfo[0];
|
|
2885
|
+
var desc, init, value;
|
|
2886
|
+
if (isPrivate) if (kind === 0 || kind === 1) desc = {
|
|
2887
|
+
get: decInfo[3],
|
|
2888
|
+
set: decInfo[4]
|
|
2889
|
+
};
|
|
2890
|
+
else if (kind === 3) desc = { get: decInfo[3] };
|
|
2891
|
+
else if (kind === 4) desc = { set: decInfo[3] };
|
|
2892
|
+
else desc = { value: decInfo[3] };
|
|
2893
|
+
else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
2894
|
+
if (kind === 1) value = {
|
|
2895
|
+
get: desc.get,
|
|
2896
|
+
set: desc.set
|
|
2897
|
+
};
|
|
2898
|
+
else if (kind === 2) value = desc.value;
|
|
2899
|
+
else if (kind === 3) value = desc.get;
|
|
2900
|
+
else if (kind === 4) value = desc.set;
|
|
2901
|
+
var newValue, get, set;
|
|
2902
|
+
if (typeof decs === "function") {
|
|
2903
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
2904
|
+
if (newValue !== void 0) {
|
|
2905
|
+
assertValidReturnValue(kind, newValue);
|
|
2906
|
+
if (kind === 0) init = newValue;
|
|
2907
|
+
else if (kind === 1) {
|
|
2908
|
+
init = newValue.init;
|
|
2909
|
+
get = newValue.get || value.get;
|
|
2910
|
+
set = newValue.set || value.set;
|
|
2911
|
+
value = {
|
|
2912
|
+
get,
|
|
2913
|
+
set
|
|
2914
|
+
};
|
|
2915
|
+
} else value = newValue;
|
|
2916
|
+
}
|
|
2917
|
+
} else for (var i = decs.length - 1; i >= 0; i--) {
|
|
2918
|
+
var dec = decs[i];
|
|
2919
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
2920
|
+
if (newValue !== void 0) {
|
|
2921
|
+
assertValidReturnValue(kind, newValue);
|
|
2922
|
+
var newInit;
|
|
2923
|
+
if (kind === 0) newInit = newValue;
|
|
2924
|
+
else if (kind === 1) {
|
|
2925
|
+
newInit = newValue.init;
|
|
2926
|
+
get = newValue.get || value.get;
|
|
2927
|
+
set = newValue.set || value.set;
|
|
2928
|
+
value = {
|
|
2929
|
+
get,
|
|
2930
|
+
set
|
|
2931
|
+
};
|
|
2932
|
+
} else value = newValue;
|
|
2933
|
+
if (newInit !== void 0) if (init === void 0) init = newInit;
|
|
2934
|
+
else if (typeof init === "function") init = [init, newInit];
|
|
2935
|
+
else init.push(newInit);
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
if (kind === 0 || kind === 1) {
|
|
2939
|
+
if (init === void 0) init = function(instance, init$1) {
|
|
2940
|
+
return init$1;
|
|
2941
|
+
};
|
|
2942
|
+
else if (typeof init !== "function") {
|
|
2943
|
+
var ownInitializers = init;
|
|
2944
|
+
init = function(instance, init$1) {
|
|
2945
|
+
var value$1 = init$1;
|
|
2946
|
+
for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
|
|
2947
|
+
return value$1;
|
|
2948
|
+
};
|
|
2949
|
+
} else {
|
|
2950
|
+
var originalInitializer = init;
|
|
2951
|
+
init = function(instance, init$1) {
|
|
2952
|
+
return originalInitializer.call(instance, init$1);
|
|
2953
|
+
};
|
|
2954
|
+
}
|
|
2955
|
+
ret.push(init);
|
|
2956
|
+
}
|
|
2957
|
+
if (kind !== 0) {
|
|
2958
|
+
if (kind === 1) {
|
|
2959
|
+
desc.get = value.get;
|
|
2960
|
+
desc.set = value.set;
|
|
2961
|
+
} else if (kind === 2) desc.value = value;
|
|
2962
|
+
else if (kind === 3) desc.get = value;
|
|
2963
|
+
else if (kind === 4) desc.set = value;
|
|
2964
|
+
if (isPrivate) if (kind === 1) {
|
|
2965
|
+
ret.push(function(instance, args) {
|
|
2966
|
+
return value.get.call(instance, args);
|
|
2967
|
+
});
|
|
2968
|
+
ret.push(function(instance, args) {
|
|
2969
|
+
return value.set.call(instance, args);
|
|
2970
|
+
});
|
|
2971
|
+
} else if (kind === 2) ret.push(value);
|
|
2972
|
+
else ret.push(function(instance, args) {
|
|
2973
|
+
return value.call(instance, args);
|
|
2974
|
+
});
|
|
2975
|
+
else Object.defineProperty(base, name, desc);
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
2979
|
+
var ret = [];
|
|
2980
|
+
var protoInitializers;
|
|
2981
|
+
var staticInitializers;
|
|
2982
|
+
var existingProtoNonFields = /* @__PURE__ */ new Map();
|
|
2983
|
+
var existingStaticNonFields = /* @__PURE__ */ new Map();
|
|
2984
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
2985
|
+
var decInfo = decInfos[i];
|
|
2986
|
+
if (!Array.isArray(decInfo)) continue;
|
|
2987
|
+
var kind = decInfo[1];
|
|
2988
|
+
var name = decInfo[2];
|
|
2989
|
+
var isPrivate = decInfo.length > 3;
|
|
2990
|
+
var isStatic = kind >= 5;
|
|
2991
|
+
var base;
|
|
2992
|
+
var initializers;
|
|
2993
|
+
if (isStatic) {
|
|
2994
|
+
base = Class;
|
|
2995
|
+
kind = kind - 5;
|
|
2996
|
+
staticInitializers = staticInitializers || [];
|
|
2997
|
+
initializers = staticInitializers;
|
|
2998
|
+
} else {
|
|
2999
|
+
base = Class.prototype;
|
|
3000
|
+
protoInitializers = protoInitializers || [];
|
|
3001
|
+
initializers = protoInitializers;
|
|
3002
|
+
}
|
|
3003
|
+
if (kind !== 0 && !isPrivate) {
|
|
3004
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
3005
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
3006
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
3007
|
+
else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
3008
|
+
else existingNonFields.set(name, true);
|
|
3009
|
+
}
|
|
3010
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
3011
|
+
}
|
|
3012
|
+
pushInitializers(ret, protoInitializers);
|
|
3013
|
+
pushInitializers(ret, staticInitializers);
|
|
3014
|
+
return ret;
|
|
3015
|
+
}
|
|
3016
|
+
function pushInitializers(ret, initializers) {
|
|
3017
|
+
if (initializers) ret.push(function(instance) {
|
|
3018
|
+
for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
|
|
3019
|
+
return instance;
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
3022
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
3023
|
+
if (classDecs.length > 0) {
|
|
3024
|
+
var initializers = [];
|
|
3025
|
+
var newClass = targetClass;
|
|
3026
|
+
var name = targetClass.name;
|
|
3027
|
+
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
3028
|
+
var decoratorFinishedRef = { v: false };
|
|
3029
|
+
try {
|
|
3030
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
3031
|
+
kind: "class",
|
|
3032
|
+
name,
|
|
3033
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
3034
|
+
metadata
|
|
3035
|
+
});
|
|
3036
|
+
} finally {
|
|
3037
|
+
decoratorFinishedRef.v = true;
|
|
3038
|
+
}
|
|
3039
|
+
if (nextNewClass !== void 0) {
|
|
3040
|
+
assertValidReturnValue(10, nextNewClass);
|
|
3041
|
+
newClass = nextNewClass;
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
return [defineMetadata(newClass, metadata), function() {
|
|
3045
|
+
for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
|
|
3046
|
+
}];
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
function defineMetadata(Class, metadata) {
|
|
3050
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
3051
|
+
configurable: true,
|
|
3052
|
+
enumerable: true,
|
|
3053
|
+
value: metadata
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
3056
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
3057
|
+
if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
3058
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
3059
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
3060
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
3061
|
+
return {
|
|
3062
|
+
e,
|
|
3063
|
+
get c() {
|
|
3064
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
3065
|
+
}
|
|
3066
|
+
};
|
|
3067
|
+
};
|
|
3068
|
+
}
|
|
3069
|
+
function _apply_decs_2203_r$13(targetClass, memberDecs, classDecs, parentClass) {
|
|
3070
|
+
return (_apply_decs_2203_r$13 = applyDecs2203RFactory$13())(targetClass, memberDecs, classDecs, parentClass);
|
|
3071
|
+
}
|
|
3072
|
+
var _dec$13, _initClass$13;
|
|
3073
|
+
let _NotFoundResponderService;
|
|
3074
|
+
_dec$13 = Injectable({
|
|
3075
|
+
token: NotFoundResponderToken,
|
|
3076
|
+
priority: -10
|
|
3077
|
+
});
|
|
3078
|
+
var NotFoundResponderService = class {
|
|
3079
|
+
static {
|
|
3080
|
+
({c: [_NotFoundResponderService, _initClass$13]} = _apply_decs_2203_r$13(this, [], [_dec$13]));
|
|
3081
|
+
}
|
|
3082
|
+
getResponse(error, description) {
|
|
3083
|
+
if (description) return this.createResponse(description);
|
|
3084
|
+
if (error && typeof error === "object" && "response" in error && error.response) {
|
|
3085
|
+
if (typeof error.response === "string") return this.createResponse(error.response);
|
|
3086
|
+
}
|
|
3087
|
+
return this.createResponse("The requested resource was not found");
|
|
3088
|
+
}
|
|
3089
|
+
createResponse(detail) {
|
|
3090
|
+
return {
|
|
3091
|
+
statusCode: 404,
|
|
3092
|
+
payload: {
|
|
3093
|
+
type: "about:blank",
|
|
3094
|
+
title: "Not Found",
|
|
3095
|
+
status: 404,
|
|
3096
|
+
detail
|
|
3097
|
+
},
|
|
3098
|
+
headers: { "Content-Type": "application/problem+json" }
|
|
3099
|
+
};
|
|
3100
|
+
}
|
|
3101
|
+
static {
|
|
3102
|
+
_initClass$13();
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
|
|
3106
|
+
//#endregion
|
|
3107
|
+
//#region src/responders/services/validation-error-responder.service.mts
|
|
3108
|
+
function applyDecs2203RFactory$12() {
|
|
3109
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3110
|
+
return function addInitializer(initializer) {
|
|
3111
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
3112
|
+
assertCallable(initializer, "An initializer");
|
|
3113
|
+
initializers.push(initializer);
|
|
3114
|
+
};
|
|
3115
|
+
}
|
|
3116
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
3117
|
+
var kindStr;
|
|
3118
|
+
switch (kind) {
|
|
3119
|
+
case 1:
|
|
3120
|
+
kindStr = "accessor";
|
|
3121
|
+
break;
|
|
3122
|
+
case 2:
|
|
3123
|
+
kindStr = "method";
|
|
3124
|
+
break;
|
|
3125
|
+
case 3:
|
|
3126
|
+
kindStr = "getter";
|
|
3127
|
+
break;
|
|
3128
|
+
case 4:
|
|
3129
|
+
kindStr = "setter";
|
|
3130
|
+
break;
|
|
3131
|
+
default: kindStr = "field";
|
|
3132
|
+
}
|
|
3133
|
+
var ctx = {
|
|
3134
|
+
kind: kindStr,
|
|
3135
|
+
name: isPrivate ? "#" + name : name,
|
|
3136
|
+
static: isStatic,
|
|
3137
|
+
private: isPrivate,
|
|
3138
|
+
metadata
|
|
3139
|
+
};
|
|
3140
|
+
var decoratorFinishedRef = { v: false };
|
|
3141
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
3142
|
+
var get, set;
|
|
3143
|
+
if (kind === 0) if (isPrivate) {
|
|
3144
|
+
get = desc.get;
|
|
3145
|
+
set = desc.set;
|
|
3146
|
+
} else {
|
|
3147
|
+
get = function() {
|
|
3148
|
+
return this[name];
|
|
3149
|
+
};
|
|
3150
|
+
set = function(v) {
|
|
3151
|
+
this[name] = v;
|
|
3152
|
+
};
|
|
3153
|
+
}
|
|
3154
|
+
else if (kind === 2) get = function() {
|
|
3155
|
+
return desc.value;
|
|
3156
|
+
};
|
|
3157
|
+
else {
|
|
3158
|
+
if (kind === 1 || kind === 3) get = function() {
|
|
3159
|
+
return desc.get.call(this);
|
|
3160
|
+
};
|
|
3161
|
+
if (kind === 1 || kind === 4) set = function(v) {
|
|
3162
|
+
desc.set.call(this, v);
|
|
3163
|
+
};
|
|
3164
|
+
}
|
|
3165
|
+
ctx.access = get && set ? {
|
|
3166
|
+
get,
|
|
3167
|
+
set
|
|
3168
|
+
} : get ? { get } : { set };
|
|
3169
|
+
try {
|
|
3170
|
+
return dec(value, ctx);
|
|
3171
|
+
} finally {
|
|
3172
|
+
decoratorFinishedRef.v = true;
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
3176
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
3177
|
+
}
|
|
3178
|
+
function assertCallable(fn, hint) {
|
|
3179
|
+
if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
|
|
3180
|
+
}
|
|
3181
|
+
function assertValidReturnValue(kind, value) {
|
|
3182
|
+
var type = typeof value;
|
|
3183
|
+
if (kind === 1) {
|
|
3184
|
+
if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
3185
|
+
if (value.get !== void 0) assertCallable(value.get, "accessor.get");
|
|
3186
|
+
if (value.set !== void 0) assertCallable(value.set, "accessor.set");
|
|
3187
|
+
if (value.init !== void 0) assertCallable(value.init, "accessor.init");
|
|
3188
|
+
} else if (type !== "function") {
|
|
3189
|
+
var hint;
|
|
3190
|
+
if (kind === 0) hint = "field";
|
|
3191
|
+
else if (kind === 10) hint = "class";
|
|
3192
|
+
else hint = "method";
|
|
3193
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
3197
|
+
var decs = decInfo[0];
|
|
3198
|
+
var desc, init, value;
|
|
3199
|
+
if (isPrivate) if (kind === 0 || kind === 1) desc = {
|
|
3200
|
+
get: decInfo[3],
|
|
3201
|
+
set: decInfo[4]
|
|
3202
|
+
};
|
|
3203
|
+
else if (kind === 3) desc = { get: decInfo[3] };
|
|
3204
|
+
else if (kind === 4) desc = { set: decInfo[3] };
|
|
3205
|
+
else desc = { value: decInfo[3] };
|
|
3206
|
+
else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
3207
|
+
if (kind === 1) value = {
|
|
3208
|
+
get: desc.get,
|
|
3209
|
+
set: desc.set
|
|
3210
|
+
};
|
|
3211
|
+
else if (kind === 2) value = desc.value;
|
|
3212
|
+
else if (kind === 3) value = desc.get;
|
|
3213
|
+
else if (kind === 4) value = desc.set;
|
|
3214
|
+
var newValue, get, set;
|
|
3215
|
+
if (typeof decs === "function") {
|
|
3216
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
3217
|
+
if (newValue !== void 0) {
|
|
3218
|
+
assertValidReturnValue(kind, newValue);
|
|
3219
|
+
if (kind === 0) init = newValue;
|
|
3220
|
+
else if (kind === 1) {
|
|
3221
|
+
init = newValue.init;
|
|
3222
|
+
get = newValue.get || value.get;
|
|
3223
|
+
set = newValue.set || value.set;
|
|
3224
|
+
value = {
|
|
3225
|
+
get,
|
|
3226
|
+
set
|
|
3227
|
+
};
|
|
3228
|
+
} else value = newValue;
|
|
3229
|
+
}
|
|
3230
|
+
} else for (var i = decs.length - 1; i >= 0; i--) {
|
|
3231
|
+
var dec = decs[i];
|
|
3232
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
3233
|
+
if (newValue !== void 0) {
|
|
3234
|
+
assertValidReturnValue(kind, newValue);
|
|
3235
|
+
var newInit;
|
|
3236
|
+
if (kind === 0) newInit = newValue;
|
|
3237
|
+
else if (kind === 1) {
|
|
3238
|
+
newInit = newValue.init;
|
|
3239
|
+
get = newValue.get || value.get;
|
|
3240
|
+
set = newValue.set || value.set;
|
|
3241
|
+
value = {
|
|
3242
|
+
get,
|
|
3243
|
+
set
|
|
3244
|
+
};
|
|
3245
|
+
} else value = newValue;
|
|
3246
|
+
if (newInit !== void 0) if (init === void 0) init = newInit;
|
|
3247
|
+
else if (typeof init === "function") init = [init, newInit];
|
|
3248
|
+
else init.push(newInit);
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
if (kind === 0 || kind === 1) {
|
|
3252
|
+
if (init === void 0) init = function(instance, init$1) {
|
|
3253
|
+
return init$1;
|
|
3254
|
+
};
|
|
3255
|
+
else if (typeof init !== "function") {
|
|
3256
|
+
var ownInitializers = init;
|
|
3257
|
+
init = function(instance, init$1) {
|
|
3258
|
+
var value$1 = init$1;
|
|
3259
|
+
for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
|
|
3260
|
+
return value$1;
|
|
3261
|
+
};
|
|
3262
|
+
} else {
|
|
3263
|
+
var originalInitializer = init;
|
|
3264
|
+
init = function(instance, init$1) {
|
|
3265
|
+
return originalInitializer.call(instance, init$1);
|
|
3266
|
+
};
|
|
3267
|
+
}
|
|
3268
|
+
ret.push(init);
|
|
3269
|
+
}
|
|
3270
|
+
if (kind !== 0) {
|
|
3271
|
+
if (kind === 1) {
|
|
3272
|
+
desc.get = value.get;
|
|
3273
|
+
desc.set = value.set;
|
|
3274
|
+
} else if (kind === 2) desc.value = value;
|
|
3275
|
+
else if (kind === 3) desc.get = value;
|
|
3276
|
+
else if (kind === 4) desc.set = value;
|
|
3277
|
+
if (isPrivate) if (kind === 1) {
|
|
3278
|
+
ret.push(function(instance, args) {
|
|
3279
|
+
return value.get.call(instance, args);
|
|
3280
|
+
});
|
|
3281
|
+
ret.push(function(instance, args) {
|
|
3282
|
+
return value.set.call(instance, args);
|
|
3283
|
+
});
|
|
3284
|
+
} else if (kind === 2) ret.push(value);
|
|
3285
|
+
else ret.push(function(instance, args) {
|
|
3286
|
+
return value.call(instance, args);
|
|
3287
|
+
});
|
|
3288
|
+
else Object.defineProperty(base, name, desc);
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
3292
|
+
var ret = [];
|
|
3293
|
+
var protoInitializers;
|
|
3294
|
+
var staticInitializers;
|
|
3295
|
+
var existingProtoNonFields = /* @__PURE__ */ new Map();
|
|
3296
|
+
var existingStaticNonFields = /* @__PURE__ */ new Map();
|
|
3297
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
3298
|
+
var decInfo = decInfos[i];
|
|
3299
|
+
if (!Array.isArray(decInfo)) continue;
|
|
3300
|
+
var kind = decInfo[1];
|
|
3301
|
+
var name = decInfo[2];
|
|
3302
|
+
var isPrivate = decInfo.length > 3;
|
|
3303
|
+
var isStatic = kind >= 5;
|
|
3304
|
+
var base;
|
|
3305
|
+
var initializers;
|
|
3306
|
+
if (isStatic) {
|
|
3307
|
+
base = Class;
|
|
3308
|
+
kind = kind - 5;
|
|
3309
|
+
staticInitializers = staticInitializers || [];
|
|
3310
|
+
initializers = staticInitializers;
|
|
3311
|
+
} else {
|
|
3312
|
+
base = Class.prototype;
|
|
3313
|
+
protoInitializers = protoInitializers || [];
|
|
3314
|
+
initializers = protoInitializers;
|
|
3315
|
+
}
|
|
3316
|
+
if (kind !== 0 && !isPrivate) {
|
|
3317
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
3318
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
3319
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
3320
|
+
else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
3321
|
+
else existingNonFields.set(name, true);
|
|
3322
|
+
}
|
|
3323
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
3324
|
+
}
|
|
3325
|
+
pushInitializers(ret, protoInitializers);
|
|
3326
|
+
pushInitializers(ret, staticInitializers);
|
|
3327
|
+
return ret;
|
|
3328
|
+
}
|
|
3329
|
+
function pushInitializers(ret, initializers) {
|
|
3330
|
+
if (initializers) ret.push(function(instance) {
|
|
3331
|
+
for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
|
|
3332
|
+
return instance;
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
3336
|
+
if (classDecs.length > 0) {
|
|
3337
|
+
var initializers = [];
|
|
3338
|
+
var newClass = targetClass;
|
|
3339
|
+
var name = targetClass.name;
|
|
3340
|
+
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
3341
|
+
var decoratorFinishedRef = { v: false };
|
|
3342
|
+
try {
|
|
3343
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
3344
|
+
kind: "class",
|
|
3345
|
+
name,
|
|
3346
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
3347
|
+
metadata
|
|
3348
|
+
});
|
|
3349
|
+
} finally {
|
|
3350
|
+
decoratorFinishedRef.v = true;
|
|
3351
|
+
}
|
|
3352
|
+
if (nextNewClass !== void 0) {
|
|
3353
|
+
assertValidReturnValue(10, nextNewClass);
|
|
3354
|
+
newClass = nextNewClass;
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
return [defineMetadata(newClass, metadata), function() {
|
|
3358
|
+
for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
|
|
3359
|
+
}];
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
function defineMetadata(Class, metadata) {
|
|
3363
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
3364
|
+
configurable: true,
|
|
3365
|
+
enumerable: true,
|
|
3366
|
+
value: metadata
|
|
3367
|
+
});
|
|
3368
|
+
}
|
|
3369
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
3370
|
+
if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
3371
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
3372
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
3373
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
3374
|
+
return {
|
|
3375
|
+
e,
|
|
3376
|
+
get c() {
|
|
3377
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
3378
|
+
}
|
|
3379
|
+
};
|
|
3380
|
+
};
|
|
3381
|
+
}
|
|
3382
|
+
function _apply_decs_2203_r$12(targetClass, memberDecs, classDecs, parentClass) {
|
|
3383
|
+
return (_apply_decs_2203_r$12 = applyDecs2203RFactory$12())(targetClass, memberDecs, classDecs, parentClass);
|
|
3384
|
+
}
|
|
3385
|
+
var _dec$12, _initClass$12;
|
|
3386
|
+
let _ValidationErrorResponderService;
|
|
3387
|
+
_dec$12 = Injectable({
|
|
3388
|
+
token: ValidationErrorResponderToken,
|
|
3389
|
+
priority: -10
|
|
3390
|
+
});
|
|
3391
|
+
var ValidationErrorResponderService = class {
|
|
3392
|
+
static {
|
|
3393
|
+
({c: [_ValidationErrorResponderService, _initClass$12]} = _apply_decs_2203_r$12(this, [], [_dec$12]));
|
|
3394
|
+
}
|
|
3395
|
+
getResponse(error, description) {
|
|
3396
|
+
if (error instanceof ZodError) return {
|
|
3397
|
+
statusCode: 400,
|
|
3398
|
+
payload: {
|
|
3399
|
+
type: "about:blank",
|
|
3400
|
+
title: "Validation Error",
|
|
3401
|
+
status: 400,
|
|
3402
|
+
detail: description ?? "Request validation failed",
|
|
3403
|
+
errors: treeifyError(error)
|
|
3404
|
+
},
|
|
3405
|
+
headers: { "Content-Type": "application/problem+json" }
|
|
3406
|
+
};
|
|
3407
|
+
return {
|
|
3408
|
+
statusCode: 400,
|
|
3409
|
+
payload: {
|
|
3410
|
+
type: "about:blank",
|
|
3411
|
+
title: "Validation Error",
|
|
3412
|
+
status: 400,
|
|
3413
|
+
detail: description ?? (error instanceof Error ? error.message : "Validation failed")
|
|
3414
|
+
},
|
|
3415
|
+
headers: { "Content-Type": "application/problem+json" }
|
|
3416
|
+
};
|
|
3417
|
+
}
|
|
3418
|
+
static {
|
|
3419
|
+
_initClass$12();
|
|
3420
|
+
}
|
|
3421
|
+
};
|
|
3422
|
+
|
|
3423
|
+
//#endregion
|
|
3424
|
+
//#region src/services/instance-resolver.service.mts
|
|
3425
|
+
function applyDecs2203RFactory$11() {
|
|
3426
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3427
|
+
return function addInitializer(initializer) {
|
|
3428
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
3429
|
+
assertCallable(initializer, "An initializer");
|
|
3430
|
+
initializers.push(initializer);
|
|
3431
|
+
};
|
|
3432
|
+
}
|
|
3433
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
3434
|
+
var kindStr;
|
|
3435
|
+
switch (kind) {
|
|
3436
|
+
case 1:
|
|
3437
|
+
kindStr = "accessor";
|
|
3438
|
+
break;
|
|
3439
|
+
case 2:
|
|
3440
|
+
kindStr = "method";
|
|
3441
|
+
break;
|
|
3442
|
+
case 3:
|
|
3443
|
+
kindStr = "getter";
|
|
3444
|
+
break;
|
|
3445
|
+
case 4:
|
|
3446
|
+
kindStr = "setter";
|
|
3447
|
+
break;
|
|
3448
|
+
default: kindStr = "field";
|
|
3449
|
+
}
|
|
3450
|
+
var ctx = {
|
|
3451
|
+
kind: kindStr,
|
|
3452
|
+
name: isPrivate ? "#" + name : name,
|
|
3453
|
+
static: isStatic,
|
|
3454
|
+
private: isPrivate,
|
|
3455
|
+
metadata
|
|
3456
|
+
};
|
|
3457
|
+
var decoratorFinishedRef = { v: false };
|
|
3458
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
3459
|
+
var get, set;
|
|
3460
|
+
if (kind === 0) if (isPrivate) {
|
|
3461
|
+
get = desc.get;
|
|
3462
|
+
set = desc.set;
|
|
3463
|
+
} else {
|
|
3464
|
+
get = function() {
|
|
3465
|
+
return this[name];
|
|
3466
|
+
};
|
|
3467
|
+
set = function(v) {
|
|
3468
|
+
this[name] = v;
|
|
3469
|
+
};
|
|
3470
|
+
}
|
|
3471
|
+
else if (kind === 2) get = function() {
|
|
3472
|
+
return desc.value;
|
|
3473
|
+
};
|
|
3474
|
+
else {
|
|
3475
|
+
if (kind === 1 || kind === 3) get = function() {
|
|
3476
|
+
return desc.get.call(this);
|
|
3477
|
+
};
|
|
3478
|
+
if (kind === 1 || kind === 4) set = function(v) {
|
|
3479
|
+
desc.set.call(this, v);
|
|
3480
|
+
};
|
|
3481
|
+
}
|
|
3482
|
+
ctx.access = get && set ? {
|
|
3483
|
+
get,
|
|
3484
|
+
set
|
|
3485
|
+
} : get ? { get } : { set };
|
|
3486
|
+
try {
|
|
3487
|
+
return dec(value, ctx);
|
|
3488
|
+
} finally {
|
|
3489
|
+
decoratorFinishedRef.v = true;
|
|
3490
|
+
}
|
|
3491
|
+
}
|
|
3492
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
3493
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
3494
|
+
}
|
|
3495
|
+
function assertCallable(fn, hint) {
|
|
3496
|
+
if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
|
|
3497
|
+
}
|
|
3498
|
+
function assertValidReturnValue(kind, value) {
|
|
3499
|
+
var type = typeof value;
|
|
3500
|
+
if (kind === 1) {
|
|
3501
|
+
if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
3502
|
+
if (value.get !== void 0) assertCallable(value.get, "accessor.get");
|
|
3503
|
+
if (value.set !== void 0) assertCallable(value.set, "accessor.set");
|
|
3504
|
+
if (value.init !== void 0) assertCallable(value.init, "accessor.init");
|
|
3505
|
+
} else if (type !== "function") {
|
|
3506
|
+
var hint;
|
|
3507
|
+
if (kind === 0) hint = "field";
|
|
3508
|
+
else if (kind === 10) hint = "class";
|
|
3509
|
+
else hint = "method";
|
|
3510
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
3514
|
+
var decs = decInfo[0];
|
|
3515
|
+
var desc, init, value;
|
|
3516
|
+
if (isPrivate) if (kind === 0 || kind === 1) desc = {
|
|
3517
|
+
get: decInfo[3],
|
|
3518
|
+
set: decInfo[4]
|
|
3519
|
+
};
|
|
3520
|
+
else if (kind === 3) desc = { get: decInfo[3] };
|
|
3521
|
+
else if (kind === 4) desc = { set: decInfo[3] };
|
|
3522
|
+
else desc = { value: decInfo[3] };
|
|
3523
|
+
else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
3524
|
+
if (kind === 1) value = {
|
|
3525
|
+
get: desc.get,
|
|
3526
|
+
set: desc.set
|
|
3527
|
+
};
|
|
3528
|
+
else if (kind === 2) value = desc.value;
|
|
3529
|
+
else if (kind === 3) value = desc.get;
|
|
3530
|
+
else if (kind === 4) value = desc.set;
|
|
3531
|
+
var newValue, get, set;
|
|
3532
|
+
if (typeof decs === "function") {
|
|
3533
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
3534
|
+
if (newValue !== void 0) {
|
|
3535
|
+
assertValidReturnValue(kind, newValue);
|
|
3536
|
+
if (kind === 0) init = newValue;
|
|
3537
|
+
else if (kind === 1) {
|
|
3538
|
+
init = newValue.init;
|
|
3539
|
+
get = newValue.get || value.get;
|
|
3540
|
+
set = newValue.set || value.set;
|
|
3541
|
+
value = {
|
|
3542
|
+
get,
|
|
3543
|
+
set
|
|
3544
|
+
};
|
|
3545
|
+
} else value = newValue;
|
|
3546
|
+
}
|
|
3547
|
+
} else for (var i = decs.length - 1; i >= 0; i--) {
|
|
3548
|
+
var dec = decs[i];
|
|
3549
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
3550
|
+
if (newValue !== void 0) {
|
|
3551
|
+
assertValidReturnValue(kind, newValue);
|
|
3552
|
+
var newInit;
|
|
3553
|
+
if (kind === 0) newInit = newValue;
|
|
3554
|
+
else if (kind === 1) {
|
|
3555
|
+
newInit = newValue.init;
|
|
3556
|
+
get = newValue.get || value.get;
|
|
3557
|
+
set = newValue.set || value.set;
|
|
3558
|
+
value = {
|
|
3559
|
+
get,
|
|
3560
|
+
set
|
|
3561
|
+
};
|
|
3562
|
+
} else value = newValue;
|
|
3563
|
+
if (newInit !== void 0) if (init === void 0) init = newInit;
|
|
3564
|
+
else if (typeof init === "function") init = [init, newInit];
|
|
3565
|
+
else init.push(newInit);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
if (kind === 0 || kind === 1) {
|
|
3569
|
+
if (init === void 0) init = function(instance, init$1) {
|
|
3570
|
+
return init$1;
|
|
3571
|
+
};
|
|
3572
|
+
else if (typeof init !== "function") {
|
|
3573
|
+
var ownInitializers = init;
|
|
3574
|
+
init = function(instance, init$1) {
|
|
3575
|
+
var value$1 = init$1;
|
|
3576
|
+
for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
|
|
3577
|
+
return value$1;
|
|
3578
|
+
};
|
|
3579
|
+
} else {
|
|
3580
|
+
var originalInitializer = init;
|
|
3581
|
+
init = function(instance, init$1) {
|
|
3582
|
+
return originalInitializer.call(instance, init$1);
|
|
3583
|
+
};
|
|
3584
|
+
}
|
|
3585
|
+
ret.push(init);
|
|
3586
|
+
}
|
|
3587
|
+
if (kind !== 0) {
|
|
3588
|
+
if (kind === 1) {
|
|
3589
|
+
desc.get = value.get;
|
|
3590
|
+
desc.set = value.set;
|
|
3591
|
+
} else if (kind === 2) desc.value = value;
|
|
3592
|
+
else if (kind === 3) desc.get = value;
|
|
3593
|
+
else if (kind === 4) desc.set = value;
|
|
3594
|
+
if (isPrivate) if (kind === 1) {
|
|
3595
|
+
ret.push(function(instance, args) {
|
|
3596
|
+
return value.get.call(instance, args);
|
|
3597
|
+
});
|
|
3598
|
+
ret.push(function(instance, args) {
|
|
3599
|
+
return value.set.call(instance, args);
|
|
3600
|
+
});
|
|
3601
|
+
} else if (kind === 2) ret.push(value);
|
|
3602
|
+
else ret.push(function(instance, args) {
|
|
3603
|
+
return value.call(instance, args);
|
|
3604
|
+
});
|
|
3605
|
+
else Object.defineProperty(base, name, desc);
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
3609
|
+
var ret = [];
|
|
3610
|
+
var protoInitializers;
|
|
3611
|
+
var staticInitializers;
|
|
3612
|
+
var existingProtoNonFields = /* @__PURE__ */ new Map();
|
|
3613
|
+
var existingStaticNonFields = /* @__PURE__ */ new Map();
|
|
3614
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
3615
|
+
var decInfo = decInfos[i];
|
|
3616
|
+
if (!Array.isArray(decInfo)) continue;
|
|
3617
|
+
var kind = decInfo[1];
|
|
3618
|
+
var name = decInfo[2];
|
|
3619
|
+
var isPrivate = decInfo.length > 3;
|
|
3620
|
+
var isStatic = kind >= 5;
|
|
3621
|
+
var base;
|
|
3622
|
+
var initializers;
|
|
3623
|
+
if (isStatic) {
|
|
3624
|
+
base = Class;
|
|
3625
|
+
kind = kind - 5;
|
|
3626
|
+
staticInitializers = staticInitializers || [];
|
|
3627
|
+
initializers = staticInitializers;
|
|
3628
|
+
} else {
|
|
3629
|
+
base = Class.prototype;
|
|
3630
|
+
protoInitializers = protoInitializers || [];
|
|
3631
|
+
initializers = protoInitializers;
|
|
3632
|
+
}
|
|
3633
|
+
if (kind !== 0 && !isPrivate) {
|
|
3634
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
3635
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
3636
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
3637
|
+
else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
3638
|
+
else existingNonFields.set(name, true);
|
|
3639
|
+
}
|
|
3640
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
3641
|
+
}
|
|
3642
|
+
pushInitializers(ret, protoInitializers);
|
|
3643
|
+
pushInitializers(ret, staticInitializers);
|
|
3644
|
+
return ret;
|
|
3645
|
+
}
|
|
3646
|
+
function pushInitializers(ret, initializers) {
|
|
3647
|
+
if (initializers) ret.push(function(instance) {
|
|
3648
|
+
for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
|
|
3649
|
+
return instance;
|
|
3650
|
+
});
|
|
3651
|
+
}
|
|
3652
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
3653
|
+
if (classDecs.length > 0) {
|
|
3654
|
+
var initializers = [];
|
|
3655
|
+
var newClass = targetClass;
|
|
3656
|
+
var name = targetClass.name;
|
|
3657
|
+
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
3658
|
+
var decoratorFinishedRef = { v: false };
|
|
3659
|
+
try {
|
|
3660
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
3661
|
+
kind: "class",
|
|
3662
|
+
name,
|
|
3663
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
3664
|
+
metadata
|
|
3665
|
+
});
|
|
3666
|
+
} finally {
|
|
3667
|
+
decoratorFinishedRef.v = true;
|
|
3668
|
+
}
|
|
3669
|
+
if (nextNewClass !== void 0) {
|
|
3670
|
+
assertValidReturnValue(10, nextNewClass);
|
|
3671
|
+
newClass = nextNewClass;
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
return [defineMetadata(newClass, metadata), function() {
|
|
3675
|
+
for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
|
|
3676
|
+
}];
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
function defineMetadata(Class, metadata) {
|
|
3680
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
3681
|
+
configurable: true,
|
|
3682
|
+
enumerable: true,
|
|
3683
|
+
value: metadata
|
|
3684
|
+
});
|
|
3685
|
+
}
|
|
3686
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
3687
|
+
if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
3688
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
3689
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
3690
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
3691
|
+
return {
|
|
3692
|
+
e,
|
|
3693
|
+
get c() {
|
|
3694
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
3695
|
+
}
|
|
3696
|
+
};
|
|
3697
|
+
};
|
|
3698
|
+
}
|
|
3699
|
+
function _apply_decs_2203_r$11(targetClass, memberDecs, classDecs, parentClass) {
|
|
3700
|
+
return (_apply_decs_2203_r$11 = applyDecs2203RFactory$11())(targetClass, memberDecs, classDecs, parentClass);
|
|
3701
|
+
}
|
|
3702
|
+
var _dec$11, _initClass$11;
|
|
3703
|
+
let _InstanceResolverService;
|
|
3704
|
+
_dec$11 = Injectable();
|
|
3705
|
+
var InstanceResolverService = class {
|
|
3706
|
+
static {
|
|
3707
|
+
({c: [_InstanceResolverService, _initClass$11]} = _apply_decs_2203_r$11(this, [], [_dec$11]));
|
|
3708
|
+
}
|
|
3709
|
+
container = inject(Container);
|
|
3710
|
+
/**
|
|
3711
|
+
* Attempts to resolve a class instance, automatically detecting if it needs
|
|
3712
|
+
* request scope based on its dependencies.
|
|
3713
|
+
*
|
|
3714
|
+
* @param classType - The class to resolve
|
|
3715
|
+
* @returns A resolution result containing either a cached instance or resolver function
|
|
3716
|
+
*/ async resolve(classType) {
|
|
3717
|
+
let cachedInstance = null;
|
|
3718
|
+
try {
|
|
3719
|
+
cachedInstance = await this.container.get(classType);
|
|
3720
|
+
} catch {
|
|
3721
|
+
const token = getInjectableToken(classType);
|
|
3722
|
+
this.container.getRegistry().updateScope(token, InjectableScope.Request);
|
|
3723
|
+
}
|
|
3724
|
+
return {
|
|
3725
|
+
cached: cachedInstance !== null,
|
|
3726
|
+
instance: cachedInstance,
|
|
3727
|
+
resolve: (scoped) => scoped.get(classType)
|
|
3728
|
+
};
|
|
3729
|
+
}
|
|
3730
|
+
/**
|
|
3731
|
+
* Attempts to resolve multiple class instances, automatically detecting if any need
|
|
3732
|
+
* request scope based on their dependencies.
|
|
3733
|
+
*
|
|
3734
|
+
* Returns `cached: true` only if ALL classes can be resolved as singletons.
|
|
3735
|
+
* If any class has request-scoped dependencies, returns `cached: false`.
|
|
3736
|
+
*
|
|
3737
|
+
* @param classTypes - The classes to resolve
|
|
3738
|
+
* @returns A resolution result containing either all cached instances or resolver function
|
|
3739
|
+
*/ async resolveMany(classTypes) {
|
|
3740
|
+
if (classTypes.length === 0) return {
|
|
3741
|
+
cached: true,
|
|
3742
|
+
instances: [],
|
|
3743
|
+
classTypes: [],
|
|
3744
|
+
resolve: async () => []
|
|
3745
|
+
};
|
|
3746
|
+
const results = await Promise.all(classTypes.map(async (classType) => {
|
|
3747
|
+
try {
|
|
3748
|
+
return {
|
|
3749
|
+
success: true,
|
|
3750
|
+
instance: await this.container.get(classType)
|
|
3751
|
+
};
|
|
3752
|
+
} catch {
|
|
3753
|
+
const token = getInjectableToken(classType);
|
|
3754
|
+
this.container.getRegistry().updateScope(token, InjectableScope.Request);
|
|
3755
|
+
return {
|
|
3756
|
+
success: false,
|
|
3757
|
+
instance: null
|
|
3758
|
+
};
|
|
3759
|
+
}
|
|
3760
|
+
}));
|
|
3761
|
+
const allCached = results.every((r) => r.success);
|
|
3762
|
+
return {
|
|
3763
|
+
cached: allCached,
|
|
3764
|
+
instances: allCached ? results.map((r) => r.instance) : null,
|
|
3765
|
+
classTypes,
|
|
3766
|
+
resolve: (scoped) => Promise.all(classTypes.map((classType) => scoped.get(classType)))
|
|
3767
|
+
};
|
|
3768
|
+
}
|
|
3769
|
+
static {
|
|
3770
|
+
_initClass$11();
|
|
3771
|
+
}
|
|
3772
|
+
};
|
|
3773
|
+
/**
|
|
3774
|
+
* @deprecated Use InstanceResolverService instead
|
|
3775
|
+
*/ const ControllerResolverService = _InstanceResolverService;
|
|
3776
|
+
|
|
3777
|
+
//#endregion
|
|
3778
|
+
//#region src/services/guard-runner.service.mts
|
|
3779
|
+
function applyDecs2203RFactory$10() {
|
|
3780
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3781
|
+
return function addInitializer(initializer) {
|
|
3782
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
3783
|
+
assertCallable(initializer, "An initializer");
|
|
3784
|
+
initializers.push(initializer);
|
|
3785
|
+
};
|
|
3786
|
+
}
|
|
3787
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
3788
|
+
var kindStr;
|
|
3789
|
+
switch (kind) {
|
|
3790
|
+
case 1:
|
|
3791
|
+
kindStr = "accessor";
|
|
3792
|
+
break;
|
|
3793
|
+
case 2:
|
|
3794
|
+
kindStr = "method";
|
|
3795
|
+
break;
|
|
3796
|
+
case 3:
|
|
3797
|
+
kindStr = "getter";
|
|
3798
|
+
break;
|
|
3799
|
+
case 4:
|
|
3800
|
+
kindStr = "setter";
|
|
3801
|
+
break;
|
|
3802
|
+
default: kindStr = "field";
|
|
3803
|
+
}
|
|
3804
|
+
var ctx = {
|
|
3805
|
+
kind: kindStr,
|
|
3806
|
+
name: isPrivate ? "#" + name : name,
|
|
3807
|
+
static: isStatic,
|
|
3808
|
+
private: isPrivate,
|
|
3809
|
+
metadata
|
|
3810
|
+
};
|
|
3811
|
+
var decoratorFinishedRef = { v: false };
|
|
3812
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
3813
|
+
var get, set;
|
|
3814
|
+
if (kind === 0) if (isPrivate) {
|
|
3815
|
+
get = desc.get;
|
|
3816
|
+
set = desc.set;
|
|
3817
|
+
} else {
|
|
3818
|
+
get = function() {
|
|
3819
|
+
return this[name];
|
|
3820
|
+
};
|
|
3821
|
+
set = function(v) {
|
|
3822
|
+
this[name] = v;
|
|
3823
|
+
};
|
|
3824
|
+
}
|
|
3825
|
+
else if (kind === 2) get = function() {
|
|
3826
|
+
return desc.value;
|
|
3827
|
+
};
|
|
3828
|
+
else {
|
|
3829
|
+
if (kind === 1 || kind === 3) get = function() {
|
|
3830
|
+
return desc.get.call(this);
|
|
3831
|
+
};
|
|
3832
|
+
if (kind === 1 || kind === 4) set = function(v) {
|
|
3833
|
+
desc.set.call(this, v);
|
|
3834
|
+
};
|
|
3835
|
+
}
|
|
3836
|
+
ctx.access = get && set ? {
|
|
3837
|
+
get,
|
|
3838
|
+
set
|
|
3839
|
+
} : get ? { get } : { set };
|
|
3840
|
+
try {
|
|
3841
|
+
return dec(value, ctx);
|
|
3842
|
+
} finally {
|
|
3843
|
+
decoratorFinishedRef.v = true;
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
3847
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
3848
|
+
}
|
|
3849
|
+
function assertCallable(fn, hint) {
|
|
3850
|
+
if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
|
|
3851
|
+
}
|
|
3852
|
+
function assertValidReturnValue(kind, value) {
|
|
3853
|
+
var type = typeof value;
|
|
3854
|
+
if (kind === 1) {
|
|
3855
|
+
if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
3856
|
+
if (value.get !== void 0) assertCallable(value.get, "accessor.get");
|
|
3857
|
+
if (value.set !== void 0) assertCallable(value.set, "accessor.set");
|
|
3858
|
+
if (value.init !== void 0) assertCallable(value.init, "accessor.init");
|
|
3859
|
+
} else if (type !== "function") {
|
|
3860
|
+
var hint;
|
|
3861
|
+
if (kind === 0) hint = "field";
|
|
3862
|
+
else if (kind === 10) hint = "class";
|
|
3863
|
+
else hint = "method";
|
|
3864
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
3868
|
+
var decs = decInfo[0];
|
|
3869
|
+
var desc, init, value;
|
|
3870
|
+
if (isPrivate) if (kind === 0 || kind === 1) desc = {
|
|
3871
|
+
get: decInfo[3],
|
|
3872
|
+
set: decInfo[4]
|
|
3873
|
+
};
|
|
3874
|
+
else if (kind === 3) desc = { get: decInfo[3] };
|
|
3875
|
+
else if (kind === 4) desc = { set: decInfo[3] };
|
|
3876
|
+
else desc = { value: decInfo[3] };
|
|
3877
|
+
else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
3878
|
+
if (kind === 1) value = {
|
|
3879
|
+
get: desc.get,
|
|
3880
|
+
set: desc.set
|
|
3881
|
+
};
|
|
3882
|
+
else if (kind === 2) value = desc.value;
|
|
3883
|
+
else if (kind === 3) value = desc.get;
|
|
3884
|
+
else if (kind === 4) value = desc.set;
|
|
3885
|
+
var newValue, get, set;
|
|
3886
|
+
if (typeof decs === "function") {
|
|
3887
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
3888
|
+
if (newValue !== void 0) {
|
|
3889
|
+
assertValidReturnValue(kind, newValue);
|
|
3890
|
+
if (kind === 0) init = newValue;
|
|
3891
|
+
else if (kind === 1) {
|
|
3892
|
+
init = newValue.init;
|
|
3893
|
+
get = newValue.get || value.get;
|
|
3894
|
+
set = newValue.set || value.set;
|
|
3895
|
+
value = {
|
|
3896
|
+
get,
|
|
3897
|
+
set
|
|
3898
|
+
};
|
|
3899
|
+
} else value = newValue;
|
|
3900
|
+
}
|
|
3901
|
+
} else for (var i = decs.length - 1; i >= 0; i--) {
|
|
3902
|
+
var dec = decs[i];
|
|
3903
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
3904
|
+
if (newValue !== void 0) {
|
|
3905
|
+
assertValidReturnValue(kind, newValue);
|
|
3906
|
+
var newInit;
|
|
3907
|
+
if (kind === 0) newInit = newValue;
|
|
3908
|
+
else if (kind === 1) {
|
|
3909
|
+
newInit = newValue.init;
|
|
3910
|
+
get = newValue.get || value.get;
|
|
3911
|
+
set = newValue.set || value.set;
|
|
3912
|
+
value = {
|
|
3913
|
+
get,
|
|
3914
|
+
set
|
|
3915
|
+
};
|
|
3916
|
+
} else value = newValue;
|
|
3917
|
+
if (newInit !== void 0) if (init === void 0) init = newInit;
|
|
3918
|
+
else if (typeof init === "function") init = [init, newInit];
|
|
3919
|
+
else init.push(newInit);
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
if (kind === 0 || kind === 1) {
|
|
3923
|
+
if (init === void 0) init = function(instance, init$1) {
|
|
3924
|
+
return init$1;
|
|
3925
|
+
};
|
|
3926
|
+
else if (typeof init !== "function") {
|
|
3927
|
+
var ownInitializers = init;
|
|
3928
|
+
init = function(instance, init$1) {
|
|
3929
|
+
var value$1 = init$1;
|
|
3930
|
+
for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
|
|
3931
|
+
return value$1;
|
|
3932
|
+
};
|
|
3933
|
+
} else {
|
|
3934
|
+
var originalInitializer = init;
|
|
3935
|
+
init = function(instance, init$1) {
|
|
3936
|
+
return originalInitializer.call(instance, init$1);
|
|
3937
|
+
};
|
|
3938
|
+
}
|
|
3939
|
+
ret.push(init);
|
|
3940
|
+
}
|
|
3941
|
+
if (kind !== 0) {
|
|
3942
|
+
if (kind === 1) {
|
|
3943
|
+
desc.get = value.get;
|
|
3944
|
+
desc.set = value.set;
|
|
3945
|
+
} else if (kind === 2) desc.value = value;
|
|
3946
|
+
else if (kind === 3) desc.get = value;
|
|
3947
|
+
else if (kind === 4) desc.set = value;
|
|
3948
|
+
if (isPrivate) if (kind === 1) {
|
|
3949
|
+
ret.push(function(instance, args) {
|
|
3950
|
+
return value.get.call(instance, args);
|
|
3951
|
+
});
|
|
3952
|
+
ret.push(function(instance, args) {
|
|
3953
|
+
return value.set.call(instance, args);
|
|
3954
|
+
});
|
|
3955
|
+
} else if (kind === 2) ret.push(value);
|
|
3956
|
+
else ret.push(function(instance, args) {
|
|
3957
|
+
return value.call(instance, args);
|
|
3958
|
+
});
|
|
3959
|
+
else Object.defineProperty(base, name, desc);
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
3963
|
+
var ret = [];
|
|
3964
|
+
var protoInitializers;
|
|
3965
|
+
var staticInitializers;
|
|
3966
|
+
var existingProtoNonFields = /* @__PURE__ */ new Map();
|
|
3967
|
+
var existingStaticNonFields = /* @__PURE__ */ new Map();
|
|
3968
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
3969
|
+
var decInfo = decInfos[i];
|
|
3970
|
+
if (!Array.isArray(decInfo)) continue;
|
|
3971
|
+
var kind = decInfo[1];
|
|
3972
|
+
var name = decInfo[2];
|
|
3973
|
+
var isPrivate = decInfo.length > 3;
|
|
3974
|
+
var isStatic = kind >= 5;
|
|
3975
|
+
var base;
|
|
3976
|
+
var initializers;
|
|
3977
|
+
if (isStatic) {
|
|
3978
|
+
base = Class;
|
|
3979
|
+
kind = kind - 5;
|
|
3980
|
+
staticInitializers = staticInitializers || [];
|
|
3981
|
+
initializers = staticInitializers;
|
|
3982
|
+
} else {
|
|
3983
|
+
base = Class.prototype;
|
|
3984
|
+
protoInitializers = protoInitializers || [];
|
|
3985
|
+
initializers = protoInitializers;
|
|
3986
|
+
}
|
|
3987
|
+
if (kind !== 0 && !isPrivate) {
|
|
3988
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
3989
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
3990
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
3991
|
+
else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
3992
|
+
else existingNonFields.set(name, true);
|
|
3993
|
+
}
|
|
3994
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
3995
|
+
}
|
|
3996
|
+
pushInitializers(ret, protoInitializers);
|
|
3997
|
+
pushInitializers(ret, staticInitializers);
|
|
3998
|
+
return ret;
|
|
3999
|
+
}
|
|
4000
|
+
function pushInitializers(ret, initializers) {
|
|
4001
|
+
if (initializers) ret.push(function(instance) {
|
|
4002
|
+
for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
|
|
4003
|
+
return instance;
|
|
4004
|
+
});
|
|
4005
|
+
}
|
|
4006
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
4007
|
+
if (classDecs.length > 0) {
|
|
4008
|
+
var initializers = [];
|
|
4009
|
+
var newClass = targetClass;
|
|
4010
|
+
var name = targetClass.name;
|
|
4011
|
+
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
4012
|
+
var decoratorFinishedRef = { v: false };
|
|
4013
|
+
try {
|
|
4014
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
4015
|
+
kind: "class",
|
|
4016
|
+
name,
|
|
4017
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
4018
|
+
metadata
|
|
4019
|
+
});
|
|
4020
|
+
} finally {
|
|
4021
|
+
decoratorFinishedRef.v = true;
|
|
4022
|
+
}
|
|
4023
|
+
if (nextNewClass !== void 0) {
|
|
4024
|
+
assertValidReturnValue(10, nextNewClass);
|
|
4025
|
+
newClass = nextNewClass;
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
return [defineMetadata(newClass, metadata), function() {
|
|
4029
|
+
for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
|
|
4030
|
+
}];
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
function defineMetadata(Class, metadata) {
|
|
4034
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
4035
|
+
configurable: true,
|
|
4036
|
+
enumerable: true,
|
|
4037
|
+
value: metadata
|
|
4038
|
+
});
|
|
4039
|
+
}
|
|
4040
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
4041
|
+
if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
4042
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
4043
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
4044
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
4045
|
+
return {
|
|
4046
|
+
e,
|
|
4047
|
+
get c() {
|
|
4048
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
4049
|
+
}
|
|
4050
|
+
};
|
|
4051
|
+
};
|
|
4052
|
+
}
|
|
4053
|
+
function _apply_decs_2203_r$10(targetClass, memberDecs, classDecs, parentClass) {
|
|
4054
|
+
return (_apply_decs_2203_r$10 = applyDecs2203RFactory$10())(targetClass, memberDecs, classDecs, parentClass);
|
|
4055
|
+
}
|
|
4056
|
+
var _dec$10, _initClass$10;
|
|
4057
|
+
let _GuardRunnerService;
|
|
4058
|
+
_dec$10 = Injectable();
|
|
4059
|
+
var GuardRunnerService = class {
|
|
4060
|
+
static {
|
|
4061
|
+
({c: [_GuardRunnerService, _initClass$10]} = _apply_decs_2203_r$10(this, [], [_dec$10]));
|
|
4062
|
+
}
|
|
4063
|
+
errorProducer = inject(_ErrorResponseProducerService);
|
|
4064
|
+
logger = inject(Logger, { context: _GuardRunnerService.name });
|
|
4065
|
+
/**
|
|
4066
|
+
* Runs guards that need to be resolved from a scoped container.
|
|
4067
|
+
* Use this when guards have request-scoped dependencies.
|
|
4068
|
+
*/ async runGuards(allGuards, executionContext, context) {
|
|
4069
|
+
const guardsArray = Array.from(allGuards).reverse();
|
|
4070
|
+
const guardInstances = await Promise.all(guardsArray.map(async (guard) => {
|
|
4071
|
+
const guardInstance = await context.get(guard);
|
|
4072
|
+
if (!guardInstance.canActivate) throw new Error(`[Navios] Guard ${guard.name} does not implement canActivate()`);
|
|
4073
|
+
return guardInstance;
|
|
4074
|
+
}));
|
|
4075
|
+
return this.executeGuards(guardInstances, executionContext);
|
|
4076
|
+
}
|
|
4077
|
+
/**
|
|
4078
|
+
* Runs pre-resolved guard instances.
|
|
4079
|
+
* Use this when all guards are singletons and have been pre-resolved at startup.
|
|
4080
|
+
*/ async runGuardsStatic(guardInstances, executionContext) {
|
|
4081
|
+
return this.executeGuards(guardInstances, executionContext);
|
|
4082
|
+
}
|
|
4083
|
+
/**
|
|
4084
|
+
* Shared guard execution logic.
|
|
4085
|
+
* Iterates through guard instances and calls canActivate on each.
|
|
4086
|
+
*/ async executeGuards(guardInstances, executionContext) {
|
|
4087
|
+
let canActivate = true;
|
|
4088
|
+
for (const guardInstance of guardInstances) try {
|
|
4089
|
+
canActivate = await guardInstance.canActivate(executionContext);
|
|
4090
|
+
if (!canActivate) break;
|
|
4091
|
+
} catch (error) {
|
|
4092
|
+
if (error instanceof HttpException) {
|
|
4093
|
+
executionContext.getReply().status(error.statusCode).send(error.response);
|
|
4094
|
+
return false;
|
|
4095
|
+
} else {
|
|
4096
|
+
this.logger.error("Error running guard", error);
|
|
4097
|
+
const errorResponse = this.errorProducer.respond(FrameworkError.InternalServerError, error);
|
|
4098
|
+
executionContext.getReply().status(errorResponse.statusCode).send(errorResponse.payload);
|
|
4099
|
+
return false;
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
if (!canActivate) {
|
|
4103
|
+
const errorResponse = this.errorProducer.respond(FrameworkError.Forbidden, null);
|
|
4104
|
+
executionContext.getReply().status(errorResponse.statusCode).send(errorResponse.payload);
|
|
4105
|
+
return false;
|
|
4106
|
+
}
|
|
4107
|
+
return canActivate;
|
|
4108
|
+
}
|
|
4109
|
+
makeContext(moduleMetadata, controllerMetadata, endpoint) {
|
|
4110
|
+
const guards = /* @__PURE__ */ new Set();
|
|
4111
|
+
const endpointGuards = endpoint.guards;
|
|
4112
|
+
const controllerGuards = controllerMetadata.guards;
|
|
4113
|
+
const moduleGuards = moduleMetadata.guards;
|
|
4114
|
+
if (endpointGuards.size > 0) for (const guard of endpointGuards) guards.add(guard);
|
|
4115
|
+
if (controllerGuards.size > 0) for (const guard of controllerGuards) guards.add(guard);
|
|
4116
|
+
if (moduleGuards.size > 0) for (const guard of moduleGuards) guards.add(guard);
|
|
4117
|
+
return guards;
|
|
4118
|
+
}
|
|
4119
|
+
static {
|
|
4120
|
+
_initClass$10();
|
|
4121
|
+
}
|
|
4122
|
+
};
|
|
4123
|
+
|
|
4124
|
+
//#endregion
|
|
4125
|
+
//#region src/services/module-loader.service.mts
|
|
4126
|
+
function applyDecs2203RFactory$9() {
|
|
4127
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
4128
|
+
return function addInitializer(initializer) {
|
|
4129
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
4130
|
+
assertCallable(initializer, "An initializer");
|
|
4131
|
+
initializers.push(initializer);
|
|
4132
|
+
};
|
|
4133
|
+
}
|
|
4134
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
4135
|
+
var kindStr;
|
|
4136
|
+
switch (kind) {
|
|
4137
|
+
case 1:
|
|
4138
|
+
kindStr = "accessor";
|
|
4139
|
+
break;
|
|
4140
|
+
case 2:
|
|
4141
|
+
kindStr = "method";
|
|
4142
|
+
break;
|
|
4143
|
+
case 3:
|
|
4144
|
+
kindStr = "getter";
|
|
4145
|
+
break;
|
|
4146
|
+
case 4:
|
|
4147
|
+
kindStr = "setter";
|
|
4148
|
+
break;
|
|
4149
|
+
default: kindStr = "field";
|
|
4150
|
+
}
|
|
4151
|
+
var ctx = {
|
|
4152
|
+
kind: kindStr,
|
|
4153
|
+
name: isPrivate ? "#" + name : name,
|
|
4154
|
+
static: isStatic,
|
|
4155
|
+
private: isPrivate,
|
|
4156
|
+
metadata
|
|
4157
|
+
};
|
|
4158
|
+
var decoratorFinishedRef = { v: false };
|
|
4159
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
4160
|
+
var get, set;
|
|
4161
|
+
if (kind === 0) if (isPrivate) {
|
|
4162
|
+
get = desc.get;
|
|
4163
|
+
set = desc.set;
|
|
4164
|
+
} else {
|
|
4165
|
+
get = function() {
|
|
4166
|
+
return this[name];
|
|
4167
|
+
};
|
|
4168
|
+
set = function(v) {
|
|
4169
|
+
this[name] = v;
|
|
4170
|
+
};
|
|
4171
|
+
}
|
|
4172
|
+
else if (kind === 2) get = function() {
|
|
4173
|
+
return desc.value;
|
|
4174
|
+
};
|
|
4175
|
+
else {
|
|
4176
|
+
if (kind === 1 || kind === 3) get = function() {
|
|
4177
|
+
return desc.get.call(this);
|
|
4178
|
+
};
|
|
4179
|
+
if (kind === 1 || kind === 4) set = function(v) {
|
|
4180
|
+
desc.set.call(this, v);
|
|
4181
|
+
};
|
|
4182
|
+
}
|
|
4183
|
+
ctx.access = get && set ? {
|
|
4184
|
+
get,
|
|
4185
|
+
set
|
|
4186
|
+
} : get ? { get } : { set };
|
|
4187
|
+
try {
|
|
4188
|
+
return dec(value, ctx);
|
|
4189
|
+
} finally {
|
|
4190
|
+
decoratorFinishedRef.v = true;
|
|
4191
|
+
}
|
|
4192
|
+
}
|
|
4193
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
4194
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
4195
|
+
}
|
|
4196
|
+
function assertCallable(fn, hint) {
|
|
4197
|
+
if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
|
|
4198
|
+
}
|
|
4199
|
+
function assertValidReturnValue(kind, value) {
|
|
4200
|
+
var type = typeof value;
|
|
4201
|
+
if (kind === 1) {
|
|
4202
|
+
if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
4203
|
+
if (value.get !== void 0) assertCallable(value.get, "accessor.get");
|
|
4204
|
+
if (value.set !== void 0) assertCallable(value.set, "accessor.set");
|
|
4205
|
+
if (value.init !== void 0) assertCallable(value.init, "accessor.init");
|
|
4206
|
+
} else if (type !== "function") {
|
|
4207
|
+
var hint;
|
|
4208
|
+
if (kind === 0) hint = "field";
|
|
4209
|
+
else if (kind === 10) hint = "class";
|
|
4210
|
+
else hint = "method";
|
|
4211
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
4215
|
+
var decs = decInfo[0];
|
|
4216
|
+
var desc, init, value;
|
|
4217
|
+
if (isPrivate) if (kind === 0 || kind === 1) desc = {
|
|
4218
|
+
get: decInfo[3],
|
|
4219
|
+
set: decInfo[4]
|
|
4220
|
+
};
|
|
4221
|
+
else if (kind === 3) desc = { get: decInfo[3] };
|
|
4222
|
+
else if (kind === 4) desc = { set: decInfo[3] };
|
|
4223
|
+
else desc = { value: decInfo[3] };
|
|
4224
|
+
else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
4225
|
+
if (kind === 1) value = {
|
|
4226
|
+
get: desc.get,
|
|
4227
|
+
set: desc.set
|
|
4228
|
+
};
|
|
4229
|
+
else if (kind === 2) value = desc.value;
|
|
4230
|
+
else if (kind === 3) value = desc.get;
|
|
4231
|
+
else if (kind === 4) value = desc.set;
|
|
4232
|
+
var newValue, get, set;
|
|
4233
|
+
if (typeof decs === "function") {
|
|
4234
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
4235
|
+
if (newValue !== void 0) {
|
|
4236
|
+
assertValidReturnValue(kind, newValue);
|
|
4237
|
+
if (kind === 0) init = newValue;
|
|
4238
|
+
else if (kind === 1) {
|
|
4239
|
+
init = newValue.init;
|
|
4240
|
+
get = newValue.get || value.get;
|
|
4241
|
+
set = newValue.set || value.set;
|
|
4242
|
+
value = {
|
|
4243
|
+
get,
|
|
4244
|
+
set
|
|
4245
|
+
};
|
|
4246
|
+
} else value = newValue;
|
|
4247
|
+
}
|
|
4248
|
+
} else for (var i = decs.length - 1; i >= 0; i--) {
|
|
4249
|
+
var dec = decs[i];
|
|
4250
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
4251
|
+
if (newValue !== void 0) {
|
|
4252
|
+
assertValidReturnValue(kind, newValue);
|
|
4253
|
+
var newInit;
|
|
4254
|
+
if (kind === 0) newInit = newValue;
|
|
4255
|
+
else if (kind === 1) {
|
|
4256
|
+
newInit = newValue.init;
|
|
4257
|
+
get = newValue.get || value.get;
|
|
4258
|
+
set = newValue.set || value.set;
|
|
4259
|
+
value = {
|
|
4260
|
+
get,
|
|
4261
|
+
set
|
|
4262
|
+
};
|
|
4263
|
+
} else value = newValue;
|
|
4264
|
+
if (newInit !== void 0) if (init === void 0) init = newInit;
|
|
4265
|
+
else if (typeof init === "function") init = [init, newInit];
|
|
4266
|
+
else init.push(newInit);
|
|
4267
|
+
}
|
|
4268
|
+
}
|
|
4269
|
+
if (kind === 0 || kind === 1) {
|
|
4270
|
+
if (init === void 0) init = function(instance, init$1) {
|
|
4271
|
+
return init$1;
|
|
4272
|
+
};
|
|
4273
|
+
else if (typeof init !== "function") {
|
|
4274
|
+
var ownInitializers = init;
|
|
4275
|
+
init = function(instance, init$1) {
|
|
4276
|
+
var value$1 = init$1;
|
|
4277
|
+
for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
|
|
4278
|
+
return value$1;
|
|
4279
|
+
};
|
|
4280
|
+
} else {
|
|
4281
|
+
var originalInitializer = init;
|
|
4282
|
+
init = function(instance, init$1) {
|
|
4283
|
+
return originalInitializer.call(instance, init$1);
|
|
4284
|
+
};
|
|
4285
|
+
}
|
|
4286
|
+
ret.push(init);
|
|
4287
|
+
}
|
|
4288
|
+
if (kind !== 0) {
|
|
4289
|
+
if (kind === 1) {
|
|
4290
|
+
desc.get = value.get;
|
|
4291
|
+
desc.set = value.set;
|
|
4292
|
+
} else if (kind === 2) desc.value = value;
|
|
4293
|
+
else if (kind === 3) desc.get = value;
|
|
4294
|
+
else if (kind === 4) desc.set = value;
|
|
4295
|
+
if (isPrivate) if (kind === 1) {
|
|
4296
|
+
ret.push(function(instance, args) {
|
|
4297
|
+
return value.get.call(instance, args);
|
|
4298
|
+
});
|
|
4299
|
+
ret.push(function(instance, args) {
|
|
4300
|
+
return value.set.call(instance, args);
|
|
4301
|
+
});
|
|
4302
|
+
} else if (kind === 2) ret.push(value);
|
|
4303
|
+
else ret.push(function(instance, args) {
|
|
4304
|
+
return value.call(instance, args);
|
|
4305
|
+
});
|
|
4306
|
+
else Object.defineProperty(base, name, desc);
|
|
4307
|
+
}
|
|
4308
|
+
}
|
|
4309
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
4310
|
+
var ret = [];
|
|
4311
|
+
var protoInitializers;
|
|
4312
|
+
var staticInitializers;
|
|
4313
|
+
var existingProtoNonFields = /* @__PURE__ */ new Map();
|
|
4314
|
+
var existingStaticNonFields = /* @__PURE__ */ new Map();
|
|
4315
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
4316
|
+
var decInfo = decInfos[i];
|
|
4317
|
+
if (!Array.isArray(decInfo)) continue;
|
|
4318
|
+
var kind = decInfo[1];
|
|
4319
|
+
var name = decInfo[2];
|
|
4320
|
+
var isPrivate = decInfo.length > 3;
|
|
4321
|
+
var isStatic = kind >= 5;
|
|
4322
|
+
var base;
|
|
4323
|
+
var initializers;
|
|
4324
|
+
if (isStatic) {
|
|
4325
|
+
base = Class;
|
|
4326
|
+
kind = kind - 5;
|
|
4327
|
+
staticInitializers = staticInitializers || [];
|
|
4328
|
+
initializers = staticInitializers;
|
|
4329
|
+
} else {
|
|
4330
|
+
base = Class.prototype;
|
|
4331
|
+
protoInitializers = protoInitializers || [];
|
|
4332
|
+
initializers = protoInitializers;
|
|
4333
|
+
}
|
|
4334
|
+
if (kind !== 0 && !isPrivate) {
|
|
4335
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
4336
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
4337
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
4338
|
+
else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
4339
|
+
else existingNonFields.set(name, true);
|
|
4340
|
+
}
|
|
4341
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
4342
|
+
}
|
|
4343
|
+
pushInitializers(ret, protoInitializers);
|
|
4344
|
+
pushInitializers(ret, staticInitializers);
|
|
4345
|
+
return ret;
|
|
4346
|
+
}
|
|
4347
|
+
function pushInitializers(ret, initializers) {
|
|
4348
|
+
if (initializers) ret.push(function(instance) {
|
|
4349
|
+
for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
|
|
4350
|
+
return instance;
|
|
4351
|
+
});
|
|
4352
|
+
}
|
|
4353
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
4354
|
+
if (classDecs.length > 0) {
|
|
4355
|
+
var initializers = [];
|
|
4356
|
+
var newClass = targetClass;
|
|
4357
|
+
var name = targetClass.name;
|
|
4358
|
+
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
4359
|
+
var decoratorFinishedRef = { v: false };
|
|
4360
|
+
try {
|
|
4361
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
4362
|
+
kind: "class",
|
|
4363
|
+
name,
|
|
4364
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
4365
|
+
metadata
|
|
4366
|
+
});
|
|
4367
|
+
} finally {
|
|
4368
|
+
decoratorFinishedRef.v = true;
|
|
4369
|
+
}
|
|
4370
|
+
if (nextNewClass !== void 0) {
|
|
4371
|
+
assertValidReturnValue(10, nextNewClass);
|
|
4372
|
+
newClass = nextNewClass;
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4375
|
+
return [defineMetadata(newClass, metadata), function() {
|
|
4376
|
+
for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
|
|
4377
|
+
}];
|
|
4378
|
+
}
|
|
4379
|
+
}
|
|
4380
|
+
function defineMetadata(Class, metadata) {
|
|
4381
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
4382
|
+
configurable: true,
|
|
4383
|
+
enumerable: true,
|
|
4384
|
+
value: metadata
|
|
4385
|
+
});
|
|
4386
|
+
}
|
|
4387
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
4388
|
+
if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
4389
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
4390
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
4391
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
4392
|
+
return {
|
|
4393
|
+
e,
|
|
4394
|
+
get c() {
|
|
4395
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
4396
|
+
}
|
|
4397
|
+
};
|
|
4398
|
+
};
|
|
4399
|
+
}
|
|
4400
|
+
function _apply_decs_2203_r$9(targetClass, memberDecs, classDecs, parentClass) {
|
|
4401
|
+
return (_apply_decs_2203_r$9 = applyDecs2203RFactory$9())(targetClass, memberDecs, classDecs, parentClass);
|
|
4402
|
+
}
|
|
4403
|
+
var _dec$9, _initClass$9;
|
|
4404
|
+
let _ModuleLoaderService;
|
|
4405
|
+
_dec$9 = Injectable();
|
|
4406
|
+
var ModuleLoaderService = class {
|
|
4407
|
+
static {
|
|
4408
|
+
({c: [_ModuleLoaderService, _initClass$9]} = _apply_decs_2203_r$9(this, [], [_dec$9]));
|
|
4409
|
+
}
|
|
4410
|
+
logger = inject(Logger, { context: _ModuleLoaderService.name });
|
|
4411
|
+
container = inject(Container);
|
|
4412
|
+
modulesMetadata = /* @__PURE__ */ new Map();
|
|
4413
|
+
loadedModules = /* @__PURE__ */ new Map();
|
|
4414
|
+
initialized = false;
|
|
4415
|
+
async loadModules(appModule) {
|
|
4416
|
+
if (this.initialized) return;
|
|
4417
|
+
await this.traverseModules(appModule);
|
|
4418
|
+
this.initialized = true;
|
|
4419
|
+
}
|
|
4420
|
+
/**
|
|
4421
|
+
* Extends the module tree with additional modules or controllers.
|
|
4422
|
+
*
|
|
4423
|
+
* This method is designed to be called by plugins during registration,
|
|
4424
|
+
* which happens after initial module loading but before route registration.
|
|
4425
|
+
*
|
|
4426
|
+
* @param extensions - Array of module extensions to add
|
|
4427
|
+
* @throws Error if not initialized (loadModules must be called first)
|
|
4428
|
+
*
|
|
4429
|
+
* @example
|
|
4430
|
+
* ```typescript
|
|
4431
|
+
* // In plugin registration
|
|
4432
|
+
* const moduleLoader = await context.container.get(ModuleLoaderService)
|
|
4433
|
+
* await moduleLoader.extendModules([{
|
|
4434
|
+
* controllers: [OpenApiJsonController, OpenApiYamlController],
|
|
4435
|
+
* moduleName: 'OpenApiBunModule',
|
|
4436
|
+
* }])
|
|
4437
|
+
* ```
|
|
4438
|
+
*/ async extendModules(extensions) {
|
|
4439
|
+
if (!this.initialized) throw new Error("ModuleLoaderService must be initialized before extending. Call loadModules() first.");
|
|
4440
|
+
for (const extension of extensions) if (extension.module) await this.traverseModules(extension.module);
|
|
4441
|
+
else if (extension.controllers && extension.moduleName) await this.registerControllers(extension.controllers, extension.moduleName);
|
|
4442
|
+
else if (extension.controllers) throw new Error("moduleName is required when providing controllers without a module");
|
|
4443
|
+
}
|
|
4444
|
+
/**
|
|
4445
|
+
* Registers controllers under a synthetic module.
|
|
4446
|
+
* Used when plugins want to add controllers without a full module class.
|
|
4447
|
+
*/ async registerControllers(controllers, moduleName) {
|
|
4448
|
+
if (this.modulesMetadata.has(moduleName)) {
|
|
4449
|
+
const existing = this.modulesMetadata.get(moduleName);
|
|
4450
|
+
for (const controller of controllers) existing.controllers.add(controller);
|
|
4451
|
+
this.logger.debug(`Extended module ${moduleName} with ${controllers.length} controllers`);
|
|
4452
|
+
} else {
|
|
4453
|
+
const metadata = {
|
|
4454
|
+
controllers: new Set(controllers),
|
|
2738
4455
|
imports: /* @__PURE__ */ new Set(),
|
|
2739
4456
|
guards: /* @__PURE__ */ new Set(),
|
|
4457
|
+
overrides: /* @__PURE__ */ new Set(),
|
|
2740
4458
|
customAttributes: /* @__PURE__ */ new Map()
|
|
2741
4459
|
};
|
|
2742
4460
|
this.modulesMetadata.set(moduleName, metadata);
|
|
@@ -2753,6 +4471,7 @@ var ModuleLoaderService = class {
|
|
|
2753
4471
|
const imports = metadata.imports ?? /* @__PURE__ */ new Set();
|
|
2754
4472
|
const loadingPromises = Array.from(imports).map(async (importedModule) => this.traverseModules(importedModule, metadata));
|
|
2755
4473
|
await Promise.all(loadingPromises);
|
|
4474
|
+
this.validateOverrides(metadata, moduleName);
|
|
2756
4475
|
const instance = await this.container.get(module);
|
|
2757
4476
|
if (instance.onModuleInit) await instance.onModuleInit();
|
|
2758
4477
|
this.logger.debug(`Module ${moduleName} loaded`);
|
|
@@ -2762,6 +4481,26 @@ var ModuleLoaderService = class {
|
|
|
2762
4481
|
throw error;
|
|
2763
4482
|
}
|
|
2764
4483
|
}
|
|
4484
|
+
validateOverrides(metadata, moduleName) {
|
|
4485
|
+
if (!metadata.overrides || metadata.overrides.size === 0) return;
|
|
4486
|
+
const registry = this.container.getRegistry();
|
|
4487
|
+
for (const overrideClass of metadata.overrides) try {
|
|
4488
|
+
const overrideToken = getInjectableToken(overrideClass);
|
|
4489
|
+
const allRegistrations = registry.getAll(overrideToken);
|
|
4490
|
+
if (allRegistrations.length === 0) {
|
|
4491
|
+
this.logger.warn(`[Navios] Override ${overrideClass.name} in module ${moduleName} is not registered. Make sure it has @Injectable decorator.`);
|
|
4492
|
+
continue;
|
|
4493
|
+
}
|
|
4494
|
+
const highestPriorityRegistration = allRegistrations[0];
|
|
4495
|
+
if (highestPriorityRegistration.target !== overrideClass) {
|
|
4496
|
+
const overrideRegistration = allRegistrations.find((r) => r.target === overrideClass);
|
|
4497
|
+
if (!overrideRegistration) this.logger.warn(`[Navios] Override ${overrideClass.name} in module ${moduleName} is registered but not found in registry for token ${overrideToken.toString()}.`);
|
|
4498
|
+
else this.logger.warn(`[Navios] Override ${overrideClass.name} in module ${moduleName} is not active. Current active service: ${highestPriorityRegistration.target.name} (priority: ${highestPriorityRegistration.priority}). Override priority: ${overrideRegistration.priority}. Override needs higher priority to take effect.`);
|
|
4499
|
+
} else this.logger.debug(`[Navios] Override ${overrideClass.name} in module ${moduleName} is active (priority: ${highestPriorityRegistration.priority})`);
|
|
4500
|
+
} catch (error) {
|
|
4501
|
+
this.logger.warn(`[Navios] Failed to validate override ${overrideClass.name} in module ${moduleName}: ${error}`);
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
2765
4504
|
mergeMetadata(metadata, parentMetadata) {
|
|
2766
4505
|
if (parentMetadata.guards) for (const guard of parentMetadata.guards) metadata.guards.add(guard);
|
|
2767
4506
|
if (parentMetadata.customAttributes) for (const [key, value] of parentMetadata.customAttributes) {
|
|
@@ -5844,5 +7583,5 @@ var NaviosApplication = class {
|
|
|
5844
7583
|
};
|
|
5845
7584
|
|
|
5846
7585
|
//#endregion
|
|
5847
|
-
export {
|
|
5848
|
-
//# sourceMappingURL=src-
|
|
7586
|
+
export { isObject as $, BadRequestException as A, Logger as B, ValidationErrorResponderToken as C, NotFoundException as D, UnauthorizedException as E, ConfigServiceOptionsSchema as F, runWithRequestId as G, loggerOptionsSchema as H, ConfigServiceToken as I, isConstructor as J, setRequestIdEnabled as K, _ConfigService as L, ConfigProviderOptions as M, EnvConfigProvider as N, InternalServerErrorException as O, provideConfig as P, isNumber as Q, _LoggerInstance as R, NotFoundResponderToken as S, ConflictException as T, generateRequestId as U, LoggerOutput as V, getRequestId as W, isFunction as X, isEmpty as Y, isNil as Z, _InternalServerErrorResponderService as _, _ReplyFactory as a, stripEndSlash as at, ForbiddenResponderToken as b, _HttpAdapterFactory as c, isLogLevel as ct, _ModuleLoaderService as d, yellow as dt, isPlainObject as et, _GuardRunnerService as f, envInt as ft, _NotFoundResponderService as g, _ValidationErrorResponderService as h, _StreamAdapterFactory as i, normalizePath as it, HttpException as j, ForbiddenException as k, _EndpointAdapterFactory as l, LOG_LEVELS as lt, _InstanceResolverService as m, _NaviosApplication as n, isSymbol as nt, _RequestFactory as o, isLogLevelEnabled as ot, ControllerResolverService as p, envString as pt, addLeadingSlash as q, _XmlStreamAdapterFactory as r, isUndefined as rt, _MultipartAdapterFactory as s, filterLogLevels as st, NaviosFactory as t, isString as tt, AttributeFactory as u, clc as ut, _ForbiddenResponderService as v, FrameworkError as w, InternalServerErrorResponderToken as x, _ErrorResponseProducerService as y, _ConsoleLogger as z };
|
|
7587
|
+
//# sourceMappingURL=src-K2k0riYJ.mjs.map
|