@xeno-js/shared 0.1.5 → 0.1.7
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/README.md +8 -14
- package/dist/index.cjs +77 -182
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +176 -213
- package/dist/index.d.ts +176 -213
- package/dist/index.js +76 -182
- package/dist/index.js.map +1 -1
- package/package.json +110 -109
package/README.md
CHANGED
|
@@ -197,20 +197,14 @@ flows from feature branches ➡️ `develop` ➡️ `main`._
|
|
|
197
197
|
|
|
198
198
|
### Scripts
|
|
199
199
|
|
|
200
|
-
| Command
|
|
201
|
-
|
|
|
202
|
-
| `npm run build`
|
|
203
|
-
| `npm run typecheck`
|
|
204
|
-
|
|
205
|
-
|
|
|
206
|
-
|
|
207
|
-
|
|
|
208
|
-
|
|
209
|
-
| | `npm run test` | Runs the Vitest test suite
|
|
210
|
-
|
|
211
|
-
| | `npm run test:coverage` | Runs tests and generates a coverage report
|
|
212
|
-
|
|
213
|
-
|
|
|
200
|
+
| Command | Description |
|
|
201
|
+
| ----------------------- | -------------------------------------------------- |
|
|
202
|
+
| `npm run build` | Builds the TypeScript source code into `dist/`<br> |
|
|
203
|
+
| `npm run typecheck` | Checks types without emitting files |
|
|
204
|
+
| `npm run lint` | Runs ESLint |
|
|
205
|
+
| `npm run format` | Formats code with Prettier |
|
|
206
|
+
| `npm run test` | Runs the Vitest test suite |
|
|
207
|
+
| `npm run test:coverage` | Runs tests and generates a coverage report |
|
|
214
208
|
|
|
215
209
|
### Code Quality (Husky & Git Hooks)
|
|
216
210
|
|
package/dist/index.cjs
CHANGED
|
@@ -51,6 +51,7 @@ __export(index_exports, {
|
|
|
51
51
|
InMemoryCache: () => InMemoryCache,
|
|
52
52
|
LOG_LEVEL: () => LOG_LEVEL,
|
|
53
53
|
LOG_LEVEL_NAMES: () => LOG_LEVEL_NAMES,
|
|
54
|
+
LoggerUtils: () => LoggerUtils,
|
|
54
55
|
MathHelper: () => MathHelper,
|
|
55
56
|
PAGINATION_DEFAULTS: () => PAGINATION_DEFAULTS,
|
|
56
57
|
PERMISSIONS: () => PERMISSIONS,
|
|
@@ -735,17 +736,7 @@ var RESILIENCE_DEFAULTS = Object.freeze({
|
|
|
735
736
|
|
|
736
737
|
// src/shared/constants/tokens.constants.ts
|
|
737
738
|
var TOKENS = Object.freeze({
|
|
738
|
-
|
|
739
|
-
ALLOW_METHOD: "ALLOW_METHOD",
|
|
740
|
-
/** @description Token used to register and resolve the AuthorizationPipeline instance in the dependency injection container.
|
|
741
|
-
*
|
|
742
|
-
* @author Xeno
|
|
743
|
-
* @version 1.0.0
|
|
744
|
-
* @since 2025-09-30
|
|
745
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
746
|
-
*/
|
|
747
|
-
AUTHORIZATION_PIPELINE: "AUTHORIZATION_PIPELINE",
|
|
748
|
-
/** @description Token used to register and resolve the AuthService instance in the dependency injection container.
|
|
739
|
+
/** @description Token used to register and resolve the Extendend AuthService instance in the dependency injection container.
|
|
749
740
|
*
|
|
750
741
|
* @author Xeno
|
|
751
742
|
* @version 1.0.0
|
|
@@ -753,15 +744,14 @@ var TOKENS = Object.freeze({
|
|
|
753
744
|
* @link https://github.com/xeno-js/xeno-js
|
|
754
745
|
*/
|
|
755
746
|
AUTH_SERVICE: "AUTH_SERVICE",
|
|
756
|
-
|
|
757
|
-
/** @description Token used to register and resolve the BearerTokenExtractor instance in the dependency injection container.
|
|
747
|
+
/** @description Token used to register and resolve the BaseAuthService instance in the dependency injection container.
|
|
758
748
|
*
|
|
759
749
|
* @author Xeno
|
|
760
750
|
* @version 1.0.0
|
|
761
751
|
* @since 2025-09-30
|
|
762
752
|
* @link https://github.com/xeno-js/xeno-js
|
|
763
753
|
*/
|
|
764
|
-
|
|
754
|
+
BASE_AUTH_SERVICE: "BASE_AUTH_SERVICE",
|
|
765
755
|
/** @description Token used to register and resolve the InMemoryCache instance in the dependency injection container.
|
|
766
756
|
*
|
|
767
757
|
* @author Xeno
|
|
@@ -778,14 +768,6 @@ var TOKENS = Object.freeze({
|
|
|
778
768
|
* @link https://github.com/xeno-js/xeno-js
|
|
779
769
|
*/
|
|
780
770
|
CACHE_KEY_BUILDER: "CACHE_KEY_BUILDER",
|
|
781
|
-
/** @description Token used to register and resolve the ClaimsIdentityMapper instance in the dependency injection container.
|
|
782
|
-
*
|
|
783
|
-
* @author Xeno
|
|
784
|
-
* @version 1.0.0
|
|
785
|
-
* @since 2025-09-30
|
|
786
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
787
|
-
*/
|
|
788
|
-
CLAIMS_IDENTITY_MAPPER: "CLAIMS_IDENTITY_MAPPER",
|
|
789
771
|
/** @description Token used to register and resolve command pipeline behaviors in the dependency injection container.
|
|
790
772
|
*
|
|
791
773
|
* @author Xeno
|
|
@@ -794,22 +776,6 @@ var TOKENS = Object.freeze({
|
|
|
794
776
|
* @link https://github.com/xeno-js/xeno-js
|
|
795
777
|
*/
|
|
796
778
|
COMMAND_PIPELINES_BEHAVIOR: "COMMAND_PIPELINES_BEHAVIOR",
|
|
797
|
-
/** @description Token used to register and resolve the CompositePipeline instance in the dependency injection container.
|
|
798
|
-
*
|
|
799
|
-
* @author Xeno
|
|
800
|
-
* @version 1.0.0
|
|
801
|
-
* @since 2025-09-30
|
|
802
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
803
|
-
*/
|
|
804
|
-
COMPOSITE_PIPELINE: "COMPOSITE_PIPELINE",
|
|
805
|
-
/** @description Token used to register and resolve the ConcurrencyRetryPipeline instance in the dependency injection container.
|
|
806
|
-
*
|
|
807
|
-
* @author Xeno
|
|
808
|
-
* @version 1.0.0
|
|
809
|
-
* @since 2025-09-30
|
|
810
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
811
|
-
*/
|
|
812
|
-
CONCURRENCY_RETRY_PIPELINE: "CONCURRENCY_RETRY_PIPELINE",
|
|
813
779
|
/** @description Token used to register and resolve the ConcurrencyService instance in the dependency injection container.
|
|
814
780
|
*
|
|
815
781
|
* @author Xeno
|
|
@@ -826,14 +792,6 @@ var TOKENS = Object.freeze({
|
|
|
826
792
|
* @link https://github.com/xeno-js/xeno-js
|
|
827
793
|
*/
|
|
828
794
|
CONFIGURATION_SERVICE: "CONFIGURATION_SERVICE",
|
|
829
|
-
/** @description Token used to register and resolve the ConsoleLogger instance in the dependency injection container.
|
|
830
|
-
*
|
|
831
|
-
* @author Xeno
|
|
832
|
-
* @version 1.0.0
|
|
833
|
-
* @since 2025-09-30
|
|
834
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
835
|
-
*/
|
|
836
|
-
CONSOLE_LOGGER: "CONSOLE_LOGGER",
|
|
837
795
|
/** @description Token used to register and resolve the ContextAccessor instance in the dependency injection container.
|
|
838
796
|
*
|
|
839
797
|
* @author Xeno
|
|
@@ -842,46 +800,30 @@ var TOKENS = Object.freeze({
|
|
|
842
800
|
* @link https://github.com/xeno-js/xeno-js
|
|
843
801
|
*/
|
|
844
802
|
CONTEXT_ACCESSOR: "CONTEXT_ACCESSOR",
|
|
845
|
-
/** @description Token used to register and resolve the
|
|
846
|
-
*
|
|
847
|
-
* @author Xeno
|
|
848
|
-
* @version 1.0.0
|
|
849
|
-
* @since 2025-09-30
|
|
850
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
851
|
-
*/
|
|
852
|
-
DB_CONTEXT: "DB_CONTEXT",
|
|
853
|
-
/** @description Token used to register and resolve the ExceptionPipeline instance in the dependency injection container.
|
|
854
|
-
*
|
|
855
|
-
* @author Xeno
|
|
856
|
-
* @version 1.0.0
|
|
857
|
-
* @since 2025-09-30
|
|
858
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
859
|
-
*/
|
|
860
|
-
EXCEPTION_PIPELINE: "EXCEPTION_PIPELINE",
|
|
861
|
-
/** @description Token used to register and resolve the GateKeeper instance in the dependency injection container.
|
|
803
|
+
/** @description Token used to register and resolve the CryptoService instance in the dependency injection container.
|
|
862
804
|
*
|
|
863
805
|
* @author Xeno
|
|
864
806
|
* @version 1.0.0
|
|
865
807
|
* @since 2025-09-30
|
|
866
808
|
* @link https://github.com/xeno-js/xeno-js
|
|
867
809
|
*/
|
|
868
|
-
|
|
869
|
-
/** @description Token used to register and resolve the
|
|
810
|
+
CRYPTO_SERVICE: "CRYPTO_SERVICE",
|
|
811
|
+
/** @description Token used to register and resolve the CsrfTokenService instance in the dependency injection container.
|
|
870
812
|
*
|
|
871
813
|
* @author Xeno
|
|
872
814
|
* @version 1.0.0
|
|
873
815
|
* @since 2025-09-30
|
|
874
816
|
* @link https://github.com/xeno-js/xeno-js
|
|
875
817
|
*/
|
|
876
|
-
|
|
877
|
-
/** @description Token used to register and resolve the
|
|
818
|
+
CSRF_TOKEN_SERVICE: "CSRF_TOKEN_SERVICE",
|
|
819
|
+
/** @description Token used to register and resolve the DbContext instance in the dependency injection container.
|
|
878
820
|
*
|
|
879
821
|
* @author Xeno
|
|
880
822
|
* @version 1.0.0
|
|
881
823
|
* @since 2025-09-30
|
|
882
824
|
* @link https://github.com/xeno-js/xeno-js
|
|
883
825
|
*/
|
|
884
|
-
|
|
826
|
+
DB_CONTEXT: "DB_CONTEXT",
|
|
885
827
|
/** @description Token used to register and resolve the IdentityAccessor instance in the dependency injection container.
|
|
886
828
|
*
|
|
887
829
|
* @author Xeno
|
|
@@ -898,22 +840,6 @@ var TOKENS = Object.freeze({
|
|
|
898
840
|
* @link https://github.com/xeno-js/xeno-js
|
|
899
841
|
*/
|
|
900
842
|
LOGGER: "LOGGER",
|
|
901
|
-
/** @description Token used to register and resolve the LoggerConfig instance in the dependency injection container.
|
|
902
|
-
*
|
|
903
|
-
* @author Xeno
|
|
904
|
-
* @version 1.0.0
|
|
905
|
-
* @since 2025-09-30
|
|
906
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
907
|
-
*/
|
|
908
|
-
LOGGER_CONFIG: "LOGGER_CONFIG",
|
|
909
|
-
/** @description Token used to register and resolve the LoggingPipeline instance in the dependency injection container.
|
|
910
|
-
*
|
|
911
|
-
* @author Xeno
|
|
912
|
-
* @version 1.0.0
|
|
913
|
-
* @since 2025-09-30
|
|
914
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
915
|
-
*/
|
|
916
|
-
LOGGING_PIPELINE: "LOGGING_PIPELINE",
|
|
917
843
|
/** @description Token used to register and resolve the Mediator instance in the dependency injection container.
|
|
918
844
|
*
|
|
919
845
|
* @author Xeno
|
|
@@ -922,46 +848,14 @@ var TOKENS = Object.freeze({
|
|
|
922
848
|
* @link https://github.com/xeno-js/xeno-js
|
|
923
849
|
*/
|
|
924
850
|
MEDIATOR: "MEDIATOR",
|
|
925
|
-
/** @description Token used to register and resolve the
|
|
926
|
-
*
|
|
927
|
-
* @author Xeno
|
|
928
|
-
* @version 1.0.0
|
|
929
|
-
* @since 2025-09-30
|
|
930
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
931
|
-
*/
|
|
932
|
-
PERFORMANCE_PIPELINE: "PERFORMANCE_PIPELINE",
|
|
933
|
-
/** @description Token used to register and resolve the PermissionAuthorizationPipeline instance in the dependency injection container.
|
|
934
|
-
*
|
|
935
|
-
* @author Xeno
|
|
936
|
-
* @version 1.0.0
|
|
937
|
-
* @since 2025-09-30
|
|
938
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
939
|
-
*/
|
|
940
|
-
PERMISSION_AUTHORIZATION_PIPELINE: "PERMISSION_AUTHORIZATION_PIPELINE",
|
|
941
|
-
/** @description Token used to register and resolve the PinoLogger instance in the dependency injection container.
|
|
851
|
+
/** @description Token used to register and resolve the NetworkContextFactory in the dependency injection container.
|
|
942
852
|
*
|
|
943
853
|
* @author Xeno
|
|
944
854
|
* @version 1.0.0
|
|
945
855
|
* @since 2025-09-30
|
|
946
856
|
* @link https://github.com/xeno-js/xeno-js
|
|
947
857
|
*/
|
|
948
|
-
|
|
949
|
-
/** @description Token used to register and resolve the PolicyRegistry instance in the dependency injection container.
|
|
950
|
-
*
|
|
951
|
-
* @author Xeno
|
|
952
|
-
* @version 1.0.0
|
|
953
|
-
* @since 2025-09-30
|
|
954
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
955
|
-
*/
|
|
956
|
-
POLICY_REGISTRY: "POLICY_REGISTRY",
|
|
957
|
-
/** @description Token used to register and resolve the QueryCachingPipeline instance in the dependency injection container.
|
|
958
|
-
*
|
|
959
|
-
* @author Xeno
|
|
960
|
-
* @version 1.0.0
|
|
961
|
-
* @since 2025-09-30
|
|
962
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
963
|
-
*/
|
|
964
|
-
QUERY_CACHING_PIPELINE: "QUERY_CACHING_PIPELINE",
|
|
858
|
+
NETWORK_CONTEXT_ACCESSOR: "NETWORK_CONTEXT_ACCESSOR",
|
|
965
859
|
/** @description Token used to register and resolve query pipeline behaviors in the dependency injection container.
|
|
966
860
|
*
|
|
967
861
|
* @author Xeno
|
|
@@ -978,7 +872,7 @@ var TOKENS = Object.freeze({
|
|
|
978
872
|
* @link https://github.com/xeno-js/xeno-js
|
|
979
873
|
*/
|
|
980
874
|
REQUEST_CONTEXT: "REQUEST_CONTEXT",
|
|
981
|
-
/** @description Token used to register and resolve the
|
|
875
|
+
/** @description Token used to register and resolve the CompositeMiddleware in the dependency injection container.
|
|
982
876
|
*
|
|
983
877
|
* @author Xeno
|
|
984
878
|
* @version 1.0.0
|
|
@@ -986,14 +880,6 @@ var TOKENS = Object.freeze({
|
|
|
986
880
|
* @link https://github.com/xeno-js/xeno-js
|
|
987
881
|
*/
|
|
988
882
|
MIDDLEWARE: "MIDDLEWARE",
|
|
989
|
-
AUTH_MIDDLEWARE: "AUTH_MIDDLEWARE",
|
|
990
|
-
CSRF_MIDDLEWARE: "CSRF_MIDDLEWARE",
|
|
991
|
-
ALLOW_ORIGIN_MIDDLEWARE: "ALLOW_ORIGIN_MIDDLEWARE",
|
|
992
|
-
CORS_MIDDLEWARE: "CORS_MIDDLEWARE",
|
|
993
|
-
METHOD_CHECK_MIDDLEWARE: "METHOD_CHECK_MIDDLEWARE",
|
|
994
|
-
OPTIONS_MIDDLEWARE: "OPTIONS_MIDDLEWARE",
|
|
995
|
-
REQUEST_CONTEXT_MIDDLEWARE: "REQUEST_CONTEXT_MIDDLEWARE",
|
|
996
|
-
RATE_LIMITER_MIDDLEWARE: "RATE_LIMITER_MIDDLEWARE",
|
|
997
883
|
/** @description Token used to register and resolve the IServiceResilience instance in the dependency injection container.
|
|
998
884
|
*
|
|
999
885
|
* @author Xeno
|
|
@@ -1002,14 +888,6 @@ var TOKENS = Object.freeze({
|
|
|
1002
888
|
* @link https://github.com/xeno-js/xeno-js
|
|
1003
889
|
*/
|
|
1004
890
|
RESILIENCE_CLIENT: "RESILIENCE_CLIENT",
|
|
1005
|
-
/** @description Token used to register and resolve the RoleAuthorizationPipeline instance in the dependency injection container.
|
|
1006
|
-
*
|
|
1007
|
-
* @author Xeno
|
|
1008
|
-
* @version 1.0.0
|
|
1009
|
-
* @since 2025-09-30
|
|
1010
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1011
|
-
*/
|
|
1012
|
-
ROLE_AUTHORIZATION_PIPELINE: "ROLE_AUTHORIZATION_PIPELINE",
|
|
1013
891
|
/** @description Token used to register and resolve the SchemaValidationStrategy instance in the dependency injection container.
|
|
1014
892
|
*
|
|
1015
893
|
* @author Xeno
|
|
@@ -1018,14 +896,6 @@ var TOKENS = Object.freeze({
|
|
|
1018
896
|
* @link https://github.com/xeno-js/xeno-js
|
|
1019
897
|
*/
|
|
1020
898
|
SCHEMA_VALIDATION_STRATEGY: "SCHEMA_VALIDATION_STRATEGY",
|
|
1021
|
-
/** @description Token used to register and resolve the SentryLogger instance in the dependency injection container.
|
|
1022
|
-
*
|
|
1023
|
-
* @author Xeno
|
|
1024
|
-
* @version 1.0.0
|
|
1025
|
-
* @since 2025-09-30
|
|
1026
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1027
|
-
*/
|
|
1028
|
-
SENTRY_LOGGER: "SENTRY_LOGGER",
|
|
1029
899
|
/** @description Token used to register and resolve the ServiceContainer instance in the dependency injection container.
|
|
1030
900
|
*
|
|
1031
901
|
* @author Xeno
|
|
@@ -1042,22 +912,14 @@ var TOKENS = Object.freeze({
|
|
|
1042
912
|
* @link https://github.com/xeno-js/xeno-js
|
|
1043
913
|
*/
|
|
1044
914
|
SERVICE_EXTRACTOR: "SERVICE_EXTRACTOR",
|
|
1045
|
-
/** @description Token used to register and resolve the
|
|
1046
|
-
*
|
|
1047
|
-
* @author Xeno
|
|
1048
|
-
* @version 1.0.0
|
|
1049
|
-
* @since 2025-09-30
|
|
1050
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1051
|
-
*/
|
|
1052
|
-
SERVICE_SCOPE_FACTORY: "SERVICE_SCOPE_FACTORY",
|
|
1053
|
-
/** @description Token used to register and resolve the TenantAuthorizationPipeline instance in the dependency injection container.
|
|
915
|
+
/** @description Token used to register and resolve the ServiceScopeAccessor in the dependency injection container.
|
|
1054
916
|
*
|
|
1055
917
|
* @author Xeno
|
|
1056
918
|
* @version 1.0.0
|
|
1057
919
|
* @since 2025-09-30
|
|
1058
920
|
* @link https://github.com/xeno-js/xeno-js
|
|
1059
921
|
*/
|
|
1060
|
-
|
|
922
|
+
SERVICE_SCOPE_ACCESSOR: "SERVICE_SCOPE_ACCESSOR",
|
|
1061
923
|
/** @description Token used to register and resolve the UnitOfWork instance in the dependency injection container.
|
|
1062
924
|
*
|
|
1063
925
|
* @author Xeno
|
|
@@ -1066,34 +928,14 @@ var TOKENS = Object.freeze({
|
|
|
1066
928
|
* @link https://github.com/xeno-js/xeno-js
|
|
1067
929
|
*/
|
|
1068
930
|
UNIT_OF_WORK: "UNIT_OF_WORK",
|
|
1069
|
-
/** @description Token used to register and resolve the
|
|
1070
|
-
*
|
|
1071
|
-
* @author Xeno
|
|
1072
|
-
* @version 1.0.0
|
|
1073
|
-
* @since 2025-09-30
|
|
1074
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1075
|
-
*/
|
|
1076
|
-
USER_AUTHORIZATION_PIPELINE: "USER_AUTHORIZATION_PIPELINE",
|
|
1077
|
-
/** @description Token used to register and resolve the ValidationPipeline instance in the dependency injection container.
|
|
931
|
+
/** @description Token used to register and resolve the ValidatorService instance in the dependency injection container.
|
|
1078
932
|
*
|
|
1079
933
|
* @author Xeno
|
|
1080
934
|
* @version 1.0.0
|
|
1081
935
|
* @since 2025-09-30
|
|
1082
936
|
* @link https://github.com/xeno-js/xeno-js
|
|
1083
937
|
*/
|
|
1084
|
-
|
|
1085
|
-
/** @description Token used to register and resolve the ZodValidator instance in the dependency injection container.
|
|
1086
|
-
*
|
|
1087
|
-
* @author Xeno
|
|
1088
|
-
* @version 1.0.0
|
|
1089
|
-
* @since 2025-09-30
|
|
1090
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1091
|
-
*/
|
|
1092
|
-
ZOD_VALIDATOR: "ZOD_VALIDATOR",
|
|
1093
|
-
SERVICE_SCOPE_ACCESSOR: "SERVICE_SCOPE_ACCESSOR",
|
|
1094
|
-
NETWORK_CONTEXT_ACCESSOR: "NETWORK_CONTEXT_ACCESSOR",
|
|
1095
|
-
USER_CONTEXT_FACTORY: "USER_CONTEXT_FACTORY",
|
|
1096
|
-
TRANSACTION_STATE: "TRANSACTION_STATE"
|
|
938
|
+
VALIDATOR_SERVICE: "VALIDATOR_SERVICE"
|
|
1097
939
|
});
|
|
1098
940
|
|
|
1099
941
|
// src/shared/utils/guards.utils.ts
|
|
@@ -1626,6 +1468,29 @@ var GuidHelper = Object.freeze({
|
|
|
1626
1468
|
|
|
1627
1469
|
// src/shared/utils/http.utils.ts
|
|
1628
1470
|
var HttpHelper = Object.freeze({
|
|
1471
|
+
/**
|
|
1472
|
+
* @description A function that masks the IP address in the given headers object.
|
|
1473
|
+
* @param ip The IP address to mask.
|
|
1474
|
+
* @returns The masked IP address.
|
|
1475
|
+
*/
|
|
1476
|
+
maskIp(ip) {
|
|
1477
|
+
if (!Guards.isDefined(ip)) return void 0;
|
|
1478
|
+
if (ip.includes(".")) {
|
|
1479
|
+
const parts = ip.split(".");
|
|
1480
|
+
if (parts.length === 4) {
|
|
1481
|
+
parts[3] = "x";
|
|
1482
|
+
return parts.join(".");
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
if (ip.includes(":")) {
|
|
1486
|
+
const parts = ip.split(":");
|
|
1487
|
+
if (parts.length > 0) {
|
|
1488
|
+
parts[parts.length - 1] = "x";
|
|
1489
|
+
return parts.join(":");
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
return ip;
|
|
1493
|
+
},
|
|
1629
1494
|
/**
|
|
1630
1495
|
* @description Normalizes HTTP headers by converting all header values to strings. If a header value is an array, it joins the array elements into a single string separated by commas. This method ensures that the headers are in a consistent format, which can be particularly useful when working with different HTTP client libraries that may represent headers in various ways. If the input headers are not defined or not an object, it returns an empty object.
|
|
1631
1496
|
* @param headers The input headers to be normalized, which can be of any type. The method checks if the headers are defined and are an object before processing them.
|
|
@@ -2076,6 +1941,36 @@ var Query = class {
|
|
|
2076
1941
|
type = REQUEST_TYPE.QUERY;
|
|
2077
1942
|
};
|
|
2078
1943
|
|
|
1944
|
+
// src/application/loggers/utils/logger-context.utils.ts
|
|
1945
|
+
var LoggerUtils = Object.freeze({
|
|
1946
|
+
/**
|
|
1947
|
+
* @description toSafeContext converts a RequestContext object to a LoggerContext object, ensuring that only the necessary fields are included.
|
|
1948
|
+
* @param ctx The RequestContext object to convert.
|
|
1949
|
+
* @returns The converted LoggerContext object.
|
|
1950
|
+
*/
|
|
1951
|
+
toSafeContext(ctx) {
|
|
1952
|
+
return {
|
|
1953
|
+
identity: {
|
|
1954
|
+
userId: ctx?.identity?.userId,
|
|
1955
|
+
tenantId: ctx?.identity?.tenantId
|
|
1956
|
+
},
|
|
1957
|
+
network: {
|
|
1958
|
+
requestId: ctx?.network?.requestId,
|
|
1959
|
+
path: ctx?.network?.path,
|
|
1960
|
+
origin: ctx?.network?.origin,
|
|
1961
|
+
clientIp: HttpHelper.maskIp(ctx?.network?.clientIp)
|
|
1962
|
+
},
|
|
1963
|
+
tracing: {
|
|
1964
|
+
correlationId: ctx?.tracing?.correlationId,
|
|
1965
|
+
spanId: ctx?.tracing?.spanId,
|
|
1966
|
+
startTime: ctx?.tracing?.startTime,
|
|
1967
|
+
parentSpanId: ctx?.tracing.parentSpanId
|
|
1968
|
+
},
|
|
1969
|
+
messaging: ctx?.messaging
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1972
|
+
});
|
|
1973
|
+
|
|
2079
1974
|
// src/application/loggers/base.logger.ts
|
|
2080
1975
|
var BaseLogger = class {
|
|
2081
1976
|
/**
|
|
@@ -2083,12 +1978,11 @@ var BaseLogger = class {
|
|
|
2083
1978
|
* @param _requestContext The request context that provides contextual information for log messages, such as request-specific data or metadata.
|
|
2084
1979
|
* @param config The minimum log level for this logger instance. Only messages with a log level equal to or higher than this level will be processed and forwarded to the logging clients.
|
|
2085
1980
|
* @param loggers An array of ILoggerClient instances that will receive log messages from this logger. Each ILoggerClient represents a different logging provider or destination (e.g., console, file, external service).
|
|
2086
|
-
|
|
2087
|
-
*
|
|
1981
|
+
*
|
|
2088
1982
|
* @author Xeno
|
|
2089
1983
|
* @version 1.0.0
|
|
2090
1984
|
* @since 2025-09-30
|
|
2091
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1985
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
2092
1986
|
*/
|
|
2093
1987
|
constructor(_requestContext, config, loggers) {
|
|
2094
1988
|
this._requestContext = _requestContext;
|
|
@@ -2117,19 +2011,19 @@ var BaseLogger = class {
|
|
|
2117
2011
|
* @param message The log message.
|
|
2118
2012
|
* @param context Optional context information to include with the log message.
|
|
2119
2013
|
* @param error Optional error object to include with the log message.
|
|
2120
|
-
|
|
2121
|
-
*
|
|
2014
|
+
*
|
|
2122
2015
|
* @author Xeno
|
|
2123
2016
|
* @version 1.0.0
|
|
2124
2017
|
* @since 2025-09-30
|
|
2125
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
2018
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
2126
2019
|
*/
|
|
2127
2020
|
broadcast(level, message, error = void 0) {
|
|
2128
2021
|
if (level < this._minLevel) return;
|
|
2129
2022
|
const logMessage = `[${LOG_LEVEL_NAMES[level]}] ${message}`;
|
|
2130
2023
|
const context = this._requestContext.getContext();
|
|
2024
|
+
const safeContext = LoggerUtils.toSafeContext(context);
|
|
2131
2025
|
for (const logger of this._loggers) {
|
|
2132
|
-
logger.track(level, logMessage,
|
|
2026
|
+
logger.track(level, logMessage, safeContext, error);
|
|
2133
2027
|
}
|
|
2134
2028
|
}
|
|
2135
2029
|
};
|
|
@@ -3154,6 +3048,7 @@ var ZodValidatorService = class _ZodValidatorService {
|
|
|
3154
3048
|
InMemoryCache,
|
|
3155
3049
|
LOG_LEVEL,
|
|
3156
3050
|
LOG_LEVEL_NAMES,
|
|
3051
|
+
LoggerUtils,
|
|
3157
3052
|
MathHelper,
|
|
3158
3053
|
PAGINATION_DEFAULTS,
|
|
3159
3054
|
PERMISSIONS,
|