@xeno-js/core 1.2.5 → 1.2.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/dist/index.cjs +281 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -1
- package/dist/index.d.ts +52 -1
- package/dist/index.js +165 -93
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2699,8 +2699,8 @@ var init_auth_utils = __esm({
|
|
|
2699
2699
|
async addAuthZ(container, opts) {
|
|
2700
2700
|
const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2701
2701
|
const strategies = [];
|
|
2702
|
-
const { Guards:
|
|
2703
|
-
if (
|
|
2702
|
+
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
2703
|
+
if (Guards51.isDefined(opts.policies)) {
|
|
2704
2704
|
const { PolicyRegistry: PolicyRegistry2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2705
2705
|
const policyRegistry = opts.policies;
|
|
2706
2706
|
const registryInstance = new PolicyRegistry2();
|
|
@@ -2709,16 +2709,16 @@ var init_auth_utils = __esm({
|
|
|
2709
2709
|
for (const [intent, policy] of Object.entries(policyRegistry)) {
|
|
2710
2710
|
const intentLower = intent.toLowerCase();
|
|
2711
2711
|
registryInstance.addPolicy(intentLower, policy);
|
|
2712
|
-
if (!
|
|
2712
|
+
if (!Guards51.isNullOrEmpty(policy.roles)) {
|
|
2713
2713
|
Policies.add("roles");
|
|
2714
2714
|
}
|
|
2715
|
-
if (!
|
|
2715
|
+
if (!Guards51.isNullOrEmpty(policy.permissions)) {
|
|
2716
2716
|
Policies.add("permissions");
|
|
2717
2717
|
}
|
|
2718
|
-
if (!
|
|
2718
|
+
if (!Guards51.isNullOrEmpty(policy.userId)) {
|
|
2719
2719
|
Policies.add("userId");
|
|
2720
2720
|
}
|
|
2721
|
-
if (!
|
|
2721
|
+
if (!Guards51.isNullOrEmpty(policy.tenantId)) {
|
|
2722
2722
|
Policies.add("tenantId");
|
|
2723
2723
|
}
|
|
2724
2724
|
}
|
|
@@ -2739,10 +2739,10 @@ var init_auth_utils = __esm({
|
|
|
2739
2739
|
strategies.push(new TenantAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2740
2740
|
}
|
|
2741
2741
|
}
|
|
2742
|
-
if (!
|
|
2742
|
+
if (!Guards51.isNullOrEmpty(opts.customAuthorizationStrategy)) {
|
|
2743
2743
|
const customStrategies = opts.customAuthorizationStrategy;
|
|
2744
2744
|
customStrategies.forEach((strategyToken) => {
|
|
2745
|
-
if (
|
|
2745
|
+
if (Guards51.isDefined(strategyToken)) {
|
|
2746
2746
|
strategies.push(strategyToken(container));
|
|
2747
2747
|
}
|
|
2748
2748
|
});
|
|
@@ -2762,8 +2762,8 @@ var init_auth_utils = __esm({
|
|
|
2762
2762
|
* @link https://github.com/xeno-js/xeno-js
|
|
2763
2763
|
*/
|
|
2764
2764
|
async addAuthN(container, opts) {
|
|
2765
|
-
const { Guards:
|
|
2766
|
-
if (
|
|
2765
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2766
|
+
if (Guards51.isDefined(opts.customAuth)) {
|
|
2767
2767
|
const authService = opts.customAuth.authExtendedService();
|
|
2768
2768
|
container.addScoped(TOKENS5.AUTH_SERVICE, () => {
|
|
2769
2769
|
return authService;
|
|
@@ -2808,12 +2808,12 @@ var init_validation_utils = __esm({
|
|
|
2808
2808
|
* @link https://github.com/xeno-js/xeno-js
|
|
2809
2809
|
*/
|
|
2810
2810
|
async addValidation(container, opts, logger) {
|
|
2811
|
-
const { Guards:
|
|
2812
|
-
if (!
|
|
2811
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2812
|
+
if (!Guards51.isDefined(opts.zod) && Guards51.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
2813
2813
|
return;
|
|
2814
2814
|
}
|
|
2815
2815
|
const validationStrategies = [];
|
|
2816
|
-
if (
|
|
2816
|
+
if (Guards51.isDefined(opts.zod)) {
|
|
2817
2817
|
const config = opts.zod;
|
|
2818
2818
|
const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
2819
2819
|
const { SchemaValidationStrategy: SchemaValidationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
@@ -2821,9 +2821,9 @@ var init_validation_utils = __esm({
|
|
|
2821
2821
|
container.addSingleton(TOKENS5.VALIDATOR_SERVICE, () => validatorService);
|
|
2822
2822
|
validationStrategies.push(new SchemaValidationStrategy2(validatorService));
|
|
2823
2823
|
}
|
|
2824
|
-
if (!
|
|
2824
|
+
if (!Guards51.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
2825
2825
|
for (const strategyToken of opts.customValidationStrategy) {
|
|
2826
|
-
if (
|
|
2826
|
+
if (Guards51.isDefined(strategyToken)) validationStrategies.push(strategyToken(container));
|
|
2827
2827
|
}
|
|
2828
2828
|
}
|
|
2829
2829
|
const { ValidationPipeline: ValidationPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
@@ -2923,9 +2923,9 @@ var init_pipeline_utils = __esm({
|
|
|
2923
2923
|
* @link https://github.com/xeno-js/xeno-js
|
|
2924
2924
|
*/
|
|
2925
2925
|
async addCommand(container, opts) {
|
|
2926
|
-
const { Guards:
|
|
2926
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2927
2927
|
const pipelines = [];
|
|
2928
|
-
if (
|
|
2928
|
+
if (Guards51.isDefined(opts.idempotency)) {
|
|
2929
2929
|
const { IdempotencyStore: IdempotencyStore2 } = await Promise.resolve().then(() => (init_idempotency(), idempotency_exports));
|
|
2930
2930
|
const imdStore = new IdempotencyStore2(
|
|
2931
2931
|
container.resolve(TOKENS5.CACHE),
|
|
@@ -2943,7 +2943,7 @@ var init_pipeline_utils = __esm({
|
|
|
2943
2943
|
)
|
|
2944
2944
|
);
|
|
2945
2945
|
}
|
|
2946
|
-
if (
|
|
2946
|
+
if (Guards51.isDefined(opts.concurrency)) {
|
|
2947
2947
|
const { ConcurrencyRetryPipeline: ConcurrencyRetryPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2948
2948
|
const config = opts.concurrency;
|
|
2949
2949
|
pipelines.push(new ConcurrencyRetryPipeline2(config?.maxRetries, config?.delayConfig));
|
|
@@ -3000,24 +3000,24 @@ var init_cqrs_module = __esm({
|
|
|
3000
3000
|
new LoggingPipeline2(logger),
|
|
3001
3001
|
new PerformancePipeline2(logger, thresholdMs)
|
|
3002
3002
|
];
|
|
3003
|
-
const { Guards:
|
|
3004
|
-
if (
|
|
3003
|
+
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
3004
|
+
if (Guards51.isDefined(opts.authorization.policies) || Guards51.isDefined(opts.authorization.customAuthorizationStrategy)) {
|
|
3005
3005
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
3006
3006
|
const authPipelines = await AuthUtils2.addAuthZ(container, opts.authorization);
|
|
3007
3007
|
pipelines.push(authPipelines);
|
|
3008
3008
|
}
|
|
3009
|
-
if (
|
|
3009
|
+
if (Guards51.isDefined(opts.validation.zod) || Guards51.isDefined(opts.validation.customValidationStrategy)) {
|
|
3010
3010
|
const { ValidationUtils: ValidationUtils2 } = await Promise.resolve().then(() => (init_validation_utils(), validation_utils_exports));
|
|
3011
3011
|
const validationPipelines = await ValidationUtils2.addValidation(
|
|
3012
3012
|
container,
|
|
3013
3013
|
opts.validation,
|
|
3014
3014
|
logger
|
|
3015
3015
|
);
|
|
3016
|
-
if (
|
|
3016
|
+
if (Guards51.isDefined(validationPipelines)) pipelines.push(validationPipelines);
|
|
3017
3017
|
}
|
|
3018
3018
|
const commandPipelines = [...pipelines];
|
|
3019
3019
|
const queryPipelines = [...pipelines];
|
|
3020
|
-
if (
|
|
3020
|
+
if (Guards51.isDefined(opts.commandBus.idempotency) || Guards51.isDefined(opts.commandBus.concurrency)) {
|
|
3021
3021
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3022
3022
|
const newCommandPipelines = await PipelineUtils2.addCommand(container, opts.commandBus);
|
|
3023
3023
|
commandPipelines.push(...newCommandPipelines);
|
|
@@ -3186,7 +3186,7 @@ var init_db_module = __esm({
|
|
|
3186
3186
|
"use strict";
|
|
3187
3187
|
DbModule = class {
|
|
3188
3188
|
async configure(container, opts) {
|
|
3189
|
-
const { Guards:
|
|
3189
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
3190
3190
|
const { DbUtils: DbUtils2 } = await Promise.resolve().then(() => (init_db_utils(), db_utils_exports));
|
|
3191
3191
|
const db = opts.enableSqlLite ? await DbUtils2.addSqlLite(opts) : await DbUtils2.addDbClient(opts);
|
|
3192
3192
|
const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
|
|
@@ -3203,7 +3203,7 @@ var init_db_module = __esm({
|
|
|
3203
3203
|
return new Proxy(db, {
|
|
3204
3204
|
get(_target, prop, receiver) {
|
|
3205
3205
|
const activeState = ttx.state;
|
|
3206
|
-
if (
|
|
3206
|
+
if (Guards51.isDefined(activeState)) {
|
|
3207
3207
|
if (prop === "transaction") {
|
|
3208
3208
|
return activeState.transaction.bind(activeState);
|
|
3209
3209
|
}
|
|
@@ -3288,7 +3288,7 @@ var init_base_http_adapter = __esm({
|
|
|
3288
3288
|
* @param body The body.
|
|
3289
3289
|
* @returns The XenoWebTransport.
|
|
3290
3290
|
*/
|
|
3291
|
-
createXenoWebTransport(url, method = "GET", headers, body = void 0) {
|
|
3291
|
+
createXenoWebTransport(url, method = "GET", headers, body = void 0, res = void 0) {
|
|
3292
3292
|
const init2 = {
|
|
3293
3293
|
method: method.toUpperCase(),
|
|
3294
3294
|
headers
|
|
@@ -3300,9 +3300,27 @@ var init_base_http_adapter = __esm({
|
|
|
3300
3300
|
}
|
|
3301
3301
|
const extendedRequest = new Request(url, init2);
|
|
3302
3302
|
extendedRequest.path = url.pathname;
|
|
3303
|
+
const webResponse = new Response();
|
|
3304
|
+
if (Guards35.isDefined(res)) {
|
|
3305
|
+
const originalAppend = webResponse.headers.append.bind(webResponse.headers);
|
|
3306
|
+
const originalSet = webResponse.headers.set.bind(webResponse.headers);
|
|
3307
|
+
const originalDelete = webResponse.headers.delete.bind(webResponse.headers);
|
|
3308
|
+
webResponse.headers.append = (name, value) => {
|
|
3309
|
+
originalAppend(name, value);
|
|
3310
|
+
this.handleHeaderChange(res, name, value, "append");
|
|
3311
|
+
};
|
|
3312
|
+
webResponse.headers.set = (name, value) => {
|
|
3313
|
+
originalSet(name, value);
|
|
3314
|
+
this.handleHeaderChange(res, name, value, "set");
|
|
3315
|
+
};
|
|
3316
|
+
webResponse.headers.delete = (name) => {
|
|
3317
|
+
originalDelete(name);
|
|
3318
|
+
this.handleHeaderChange(res, name, "", "delete");
|
|
3319
|
+
};
|
|
3320
|
+
}
|
|
3303
3321
|
return {
|
|
3304
3322
|
request: extendedRequest,
|
|
3305
|
-
response:
|
|
3323
|
+
response: webResponse
|
|
3306
3324
|
};
|
|
3307
3325
|
}
|
|
3308
3326
|
};
|
|
@@ -3310,17 +3328,41 @@ var init_base_http_adapter = __esm({
|
|
|
3310
3328
|
});
|
|
3311
3329
|
|
|
3312
3330
|
// src/infrastructure/http/fastify.http-adapter.ts
|
|
3331
|
+
import { Guards as Guards36 } from "@xeno-js/shared";
|
|
3313
3332
|
var FastifyHttpAdapter;
|
|
3314
3333
|
var init_fastify_http_adapter = __esm({
|
|
3315
3334
|
"src/infrastructure/http/fastify.http-adapter.ts"() {
|
|
3316
3335
|
"use strict";
|
|
3317
3336
|
init_base_http_adapter();
|
|
3318
3337
|
FastifyHttpAdapter = class extends BaseHttpAdapter {
|
|
3319
|
-
adapt(req,
|
|
3338
|
+
adapt(req, res) {
|
|
3320
3339
|
const headers = this.parseHeaders(req.headers);
|
|
3321
3340
|
const url = this.parseUrl(req.url, req.headers, req.query);
|
|
3322
3341
|
const body = req.body;
|
|
3323
|
-
return this.createXenoWebTransport(url, req.method, headers, body);
|
|
3342
|
+
return this.createXenoWebTransport(url, req.method, headers, body, res);
|
|
3343
|
+
}
|
|
3344
|
+
handleHeaderChange(res, name, value, action) {
|
|
3345
|
+
if (action === "delete") {
|
|
3346
|
+
res.removeHeader(name);
|
|
3347
|
+
return;
|
|
3348
|
+
}
|
|
3349
|
+
if (name.toLowerCase() === "set-cookie") {
|
|
3350
|
+
const existing = res.getHeader("set-cookie");
|
|
3351
|
+
let cookies = [];
|
|
3352
|
+
if (Guards36.isArray(existing)) {
|
|
3353
|
+
cookies = existing;
|
|
3354
|
+
} else if (Guards36.isString(existing)) {
|
|
3355
|
+
cookies = [existing];
|
|
3356
|
+
}
|
|
3357
|
+
if (action === "append") {
|
|
3358
|
+
cookies.push(value);
|
|
3359
|
+
} else {
|
|
3360
|
+
cookies = [value];
|
|
3361
|
+
}
|
|
3362
|
+
res.header("set-cookie", cookies);
|
|
3363
|
+
} else {
|
|
3364
|
+
res.header(name, value);
|
|
3365
|
+
}
|
|
3324
3366
|
}
|
|
3325
3367
|
};
|
|
3326
3368
|
}
|
|
@@ -3341,21 +3383,48 @@ var init_native_http_adapter = __esm({
|
|
|
3341
3383
|
response: res
|
|
3342
3384
|
};
|
|
3343
3385
|
}
|
|
3386
|
+
handleHeaderChange(_res, _name, _value, _action) {
|
|
3387
|
+
return;
|
|
3388
|
+
}
|
|
3344
3389
|
};
|
|
3345
3390
|
}
|
|
3346
3391
|
});
|
|
3347
3392
|
|
|
3348
3393
|
// src/infrastructure/http/vercel.http-adapter.ts
|
|
3394
|
+
import { Guards as Guards37 } from "@xeno-js/shared";
|
|
3349
3395
|
var VercelHttpAdapter;
|
|
3350
3396
|
var init_vercel_http_adapter = __esm({
|
|
3351
3397
|
"src/infrastructure/http/vercel.http-adapter.ts"() {
|
|
3352
3398
|
"use strict";
|
|
3353
3399
|
init_base_http_adapter();
|
|
3354
3400
|
VercelHttpAdapter = class extends BaseHttpAdapter {
|
|
3355
|
-
adapt(req,
|
|
3401
|
+
adapt(req, res) {
|
|
3356
3402
|
const headers = this.parseHeaders(req.headers);
|
|
3357
3403
|
const url = this.parseUrl(req.url, req.headers, req.query);
|
|
3358
|
-
return this.createXenoWebTransport(url, req.method, headers, req.body);
|
|
3404
|
+
return this.createXenoWebTransport(url, req.method, headers, req.body, res);
|
|
3405
|
+
}
|
|
3406
|
+
handleHeaderChange(res, name, value, action) {
|
|
3407
|
+
if (action === "delete") {
|
|
3408
|
+
res.removeHeader(name);
|
|
3409
|
+
return;
|
|
3410
|
+
}
|
|
3411
|
+
if (name.toLowerCase() === "set-cookie") {
|
|
3412
|
+
const existing = res.getHeader("Set-Cookie");
|
|
3413
|
+
let cookies = [];
|
|
3414
|
+
if (Guards37.isArray(existing)) {
|
|
3415
|
+
cookies = existing;
|
|
3416
|
+
} else if (Guards37.isString(existing)) {
|
|
3417
|
+
cookies = [existing];
|
|
3418
|
+
}
|
|
3419
|
+
if (action === "append") {
|
|
3420
|
+
cookies.push(value);
|
|
3421
|
+
} else {
|
|
3422
|
+
cookies = [value];
|
|
3423
|
+
}
|
|
3424
|
+
res.setHeader("Set-Cookie", cookies);
|
|
3425
|
+
} else {
|
|
3426
|
+
res.setHeader(name, value);
|
|
3427
|
+
}
|
|
3359
3428
|
}
|
|
3360
3429
|
};
|
|
3361
3430
|
}
|
|
@@ -3380,7 +3449,7 @@ var init_http = __esm({
|
|
|
3380
3449
|
});
|
|
3381
3450
|
|
|
3382
3451
|
// src/infrastructure/modules/http-adapter.module.ts
|
|
3383
|
-
import { Guards as
|
|
3452
|
+
import { Guards as Guards38 } from "@xeno-js/shared";
|
|
3384
3453
|
var HttpAdapterModule;
|
|
3385
3454
|
var init_http_adapter_module = __esm({
|
|
3386
3455
|
"src/infrastructure/modules/http-adapter.module.ts"() {
|
|
@@ -3397,7 +3466,7 @@ var init_http_adapter_module = __esm({
|
|
|
3397
3466
|
} else if (opts.fastify) {
|
|
3398
3467
|
const { FastifyHttpAdapter: FastifyHttpAdapter2 } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
3399
3468
|
return new FastifyHttpAdapter2();
|
|
3400
|
-
} else if (
|
|
3469
|
+
} else if (Guards38.isDefined(opts.custom)) {
|
|
3401
3470
|
return opts.custom();
|
|
3402
3471
|
} else {
|
|
3403
3472
|
const { NativeHttpAdapter: NativeHttpAdapter2 } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
@@ -3430,14 +3499,14 @@ var init_http_utils = __esm({
|
|
|
3430
3499
|
*/
|
|
3431
3500
|
async addAxios(container, opts) {
|
|
3432
3501
|
const { NodeAxiosFactory: NodeAxiosFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3433
|
-
const { Guards:
|
|
3434
|
-
if (!
|
|
3502
|
+
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
3503
|
+
if (!Guards51.isDefined(opts.token)) {
|
|
3435
3504
|
throw new Error("HttpConfig.token is required and must be defined.");
|
|
3436
3505
|
}
|
|
3437
3506
|
container.addSingleton(opts.token, () => {
|
|
3438
3507
|
const factory = new NodeAxiosFactory2();
|
|
3439
3508
|
const instance = factory.create(opts.client);
|
|
3440
|
-
if (!
|
|
3509
|
+
if (!Guards51.hasMethod(instance, "get") || !Guards51.hasMethod(instance, "post") || !Guards51.hasMethod(instance, "put") || !Guards51.hasMethod(instance, "patch") || !Guards51.hasMethod(instance, "delete")) {
|
|
3441
3510
|
throw new Error(
|
|
3442
3511
|
"The created HTTP client instance does not implement the required methods of IHttpClient."
|
|
3443
3512
|
);
|
|
@@ -3779,7 +3848,7 @@ var init_composite_middleware = __esm({
|
|
|
3779
3848
|
});
|
|
3780
3849
|
|
|
3781
3850
|
// src/presentation/middlewares/cors.middleware.ts
|
|
3782
|
-
import { Guards as
|
|
3851
|
+
import { Guards as Guards39 } from "@xeno-js/shared";
|
|
3783
3852
|
var CORSMiddleware;
|
|
3784
3853
|
var init_cors_middleware = __esm({
|
|
3785
3854
|
"src/presentation/middlewares/cors.middleware.ts"() {
|
|
@@ -3795,7 +3864,7 @@ var init_cors_middleware = __esm({
|
|
|
3795
3864
|
const { network } = this._requestContext.getContext() ?? {};
|
|
3796
3865
|
const origin = network?.origin;
|
|
3797
3866
|
const response = await next();
|
|
3798
|
-
if (
|
|
3867
|
+
if (Guards39.isDefined(origin))
|
|
3799
3868
|
response.headers = {
|
|
3800
3869
|
...response.headers ?? {},
|
|
3801
3870
|
"Access-Control-Allow-Origin": origin,
|
|
@@ -3812,7 +3881,7 @@ var init_cors_middleware = __esm({
|
|
|
3812
3881
|
import {
|
|
3813
3882
|
ERROR_CODE_MESSAGES as ERROR_CODE_MESSAGES5,
|
|
3814
3883
|
ERROR_CODES as ERROR_CODES6,
|
|
3815
|
-
Guards as
|
|
3884
|
+
Guards as Guards40,
|
|
3816
3885
|
GuidHelper as GuidHelper9,
|
|
3817
3886
|
HttpHelper as HttpHelper6,
|
|
3818
3887
|
STATUS_CODES as STATUS_CODES7
|
|
@@ -3835,7 +3904,7 @@ var init_csrf_middleware = __esm({
|
|
|
3835
3904
|
const { network, tracing, identity } = this._requestContext.getContext() ?? {};
|
|
3836
3905
|
const headerToken = network?.csrf;
|
|
3837
3906
|
const cookieToken = network?.csrfCookie;
|
|
3838
|
-
if (!
|
|
3907
|
+
if (!Guards40.isDefined(headerToken) || !Guards40.isDefined(cookieToken)) {
|
|
3839
3908
|
return HttpHelper6.error(
|
|
3840
3909
|
{
|
|
3841
3910
|
success: false,
|
|
@@ -3877,7 +3946,7 @@ var init_csrf_middleware = __esm({
|
|
|
3877
3946
|
}
|
|
3878
3947
|
);
|
|
3879
3948
|
}
|
|
3880
|
-
if (!
|
|
3949
|
+
if (!Guards40.isDefined(identity?.userId) || !await this._csrfTokenService.validate(headerToken, identity?.userId)) {
|
|
3881
3950
|
return HttpHelper6.error(
|
|
3882
3951
|
{
|
|
3883
3952
|
success: false,
|
|
@@ -3906,7 +3975,7 @@ var init_csrf_middleware = __esm({
|
|
|
3906
3975
|
});
|
|
3907
3976
|
|
|
3908
3977
|
// src/presentation/middlewares/csrf-cookie.middleware.ts
|
|
3909
|
-
import { Guards as
|
|
3978
|
+
import { Guards as Guards41 } from "@xeno-js/shared";
|
|
3910
3979
|
var CsrfCookieMiddleware;
|
|
3911
3980
|
var init_csrf_cookie_middleware = __esm({
|
|
3912
3981
|
"src/presentation/middlewares/csrf-cookie.middleware.ts"() {
|
|
@@ -3925,8 +3994,8 @@ var init_csrf_cookie_middleware = __esm({
|
|
|
3925
3994
|
const context = this._requestContext.getContext();
|
|
3926
3995
|
const identity = context?.identity;
|
|
3927
3996
|
const network = context?.network;
|
|
3928
|
-
if (!
|
|
3929
|
-
if (
|
|
3997
|
+
if (!Guards41.isDefined(identity?.userId)) return response;
|
|
3998
|
+
if (Guards41.isDefined(network?.csrfCookie)) return response;
|
|
3930
3999
|
const token = await this._csrfTokenService.generate(identity.userId);
|
|
3931
4000
|
const cookieName = this._csrf.cookieName ?? "__Host-xeno-csrf";
|
|
3932
4001
|
const maxAge = this._csrf.cookieMaxAgeSeconds ?? 3600;
|
|
@@ -3944,7 +4013,7 @@ var init_csrf_cookie_middleware = __esm({
|
|
|
3944
4013
|
});
|
|
3945
4014
|
|
|
3946
4015
|
// src/presentation/middlewares/options.middleware.ts
|
|
3947
|
-
import { Guards as
|
|
4016
|
+
import { Guards as Guards42, HttpHelper as HttpHelper7, STATUS_CODES as STATUS_CODES8 } from "@xeno-js/shared";
|
|
3948
4017
|
var OptionsMiddleware;
|
|
3949
4018
|
var init_options_middleware = __esm({
|
|
3950
4019
|
"src/presentation/middlewares/options.middleware.ts"() {
|
|
@@ -3965,7 +4034,7 @@ var init_options_middleware = __esm({
|
|
|
3965
4034
|
const network = this._requestContext.getNetworkContext();
|
|
3966
4035
|
const origin = network?.origin;
|
|
3967
4036
|
const headers = {};
|
|
3968
|
-
if (
|
|
4037
|
+
if (Guards42.isDefined(origin)) {
|
|
3969
4038
|
headers["Access-Control-Allow-Origin"] = origin;
|
|
3970
4039
|
headers["Access-Control-Allow-Credentials"] = this._withCredentials;
|
|
3971
4040
|
headers["Vary"] = "Origin";
|
|
@@ -3984,7 +4053,7 @@ var init_options_middleware = __esm({
|
|
|
3984
4053
|
import {
|
|
3985
4054
|
ERROR_CODE_MESSAGES as ERROR_CODE_MESSAGES6,
|
|
3986
4055
|
ERROR_CODES as ERROR_CODES7,
|
|
3987
|
-
Guards as
|
|
4056
|
+
Guards as Guards43,
|
|
3988
4057
|
GuidHelper as GuidHelper10,
|
|
3989
4058
|
HttpHelper as HttpHelper8,
|
|
3990
4059
|
STATUS_CODES as STATUS_CODES9
|
|
@@ -4009,7 +4078,7 @@ var init_rate_limiter_middleware = __esm({
|
|
|
4009
4078
|
async execute(req, _res, next) {
|
|
4010
4079
|
const cacheKey = this._keyBuilder.buildRateLimitKey(req.path);
|
|
4011
4080
|
const { network, tracing } = this._ctxAccessor.getContext() ?? {};
|
|
4012
|
-
if (!
|
|
4081
|
+
if (!Guards43.isDefined(cacheKey))
|
|
4013
4082
|
return HttpHelper8.error(
|
|
4014
4083
|
{
|
|
4015
4084
|
success: false,
|
|
@@ -4061,10 +4130,10 @@ var init_rate_limiter_middleware = __esm({
|
|
|
4061
4130
|
});
|
|
4062
4131
|
|
|
4063
4132
|
// src/presentation/mappers/context.mapper.ts
|
|
4064
|
-
import { Guards as
|
|
4133
|
+
import { Guards as Guards44 } from "@xeno-js/shared";
|
|
4065
4134
|
function _buildMessagingContext(meta) {
|
|
4066
|
-
const hasSequenceData =
|
|
4067
|
-
const hasMessagingData = hasSequenceData ||
|
|
4135
|
+
const hasSequenceData = Guards44.isDefined(meta.sequence?.sequenceId) || Guards44.isDefined(meta.sequence?.position) || Guards44.isDefined(meta.sequence?.size);
|
|
4136
|
+
const hasMessagingData = hasSequenceData || Guards44.isDefined(meta.expiration) || Guards44.isDefined(meta.returnAddress);
|
|
4068
4137
|
const messaging = hasMessagingData ? {
|
|
4069
4138
|
returnAddress: meta.returnAddress,
|
|
4070
4139
|
expiration: meta.expiration,
|
|
@@ -4252,7 +4321,7 @@ var inmemory_cache_exports = {};
|
|
|
4252
4321
|
__export(inmemory_cache_exports, {
|
|
4253
4322
|
InMemoryCacheExtended: () => InMemoryCacheExtended
|
|
4254
4323
|
});
|
|
4255
|
-
import { Guards as
|
|
4324
|
+
import { Guards as Guards45, InMemoryCache } from "@xeno-js/shared";
|
|
4256
4325
|
var InMemoryCacheExtended;
|
|
4257
4326
|
var init_inmemory_cache = __esm({
|
|
4258
4327
|
"src/infrastructure/cache/inmemory.cache.ts"() {
|
|
@@ -4261,7 +4330,7 @@ var init_inmemory_cache = __esm({
|
|
|
4261
4330
|
async increment(key, ttlSeconds) {
|
|
4262
4331
|
const current = await this.get(key) ?? 0;
|
|
4263
4332
|
const next = Number(current) + 1;
|
|
4264
|
-
const ttl =
|
|
4333
|
+
const ttl = Guards45.isDefined(ttlSeconds) ? Number(ttlSeconds) : 60;
|
|
4265
4334
|
await this.set(key, next, ttl);
|
|
4266
4335
|
return next;
|
|
4267
4336
|
}
|
|
@@ -4270,7 +4339,7 @@ var init_inmemory_cache = __esm({
|
|
|
4270
4339
|
});
|
|
4271
4340
|
|
|
4272
4341
|
// src/infrastructure/cache/rate-limit-key-builder.cache.ts
|
|
4273
|
-
import { Guards as
|
|
4342
|
+
import { Guards as Guards46 } from "@xeno-js/shared";
|
|
4274
4343
|
var RateLimitKeyBuilder;
|
|
4275
4344
|
var init_rate_limit_key_builder_cache = __esm({
|
|
4276
4345
|
"src/infrastructure/cache/rate-limit-key-builder.cache.ts"() {
|
|
@@ -4285,12 +4354,12 @@ var init_rate_limit_key_builder_cache = __esm({
|
|
|
4285
4354
|
const tenantId = ctx?.identity?.tenantId;
|
|
4286
4355
|
const userId = ctx?.identity?.userId;
|
|
4287
4356
|
const clientIp = ctx?.network?.clientIp;
|
|
4288
|
-
if (!
|
|
4357
|
+
if (!Guards46.isNullOrEmpty(tenantId) && !Guards46.isNullOrEmpty(userId))
|
|
4289
4358
|
return `ratelimit:tenant:${tenantId}:user:${userId}:${resource}`;
|
|
4290
|
-
if (!
|
|
4359
|
+
if (!Guards46.isNullOrEmpty(tenantId) && !Guards46.isNullOrEmpty(clientIp))
|
|
4291
4360
|
return `ratelimit:tenant:${tenantId}:ip:${clientIp}:${resource}`;
|
|
4292
|
-
if (!
|
|
4293
|
-
if (!
|
|
4361
|
+
if (!Guards46.isNullOrEmpty(userId)) return `ratelimit:user:${userId}:${resource}`;
|
|
4362
|
+
if (!Guards46.isNullOrEmpty(clientIp)) return `ratelimit:ip:${clientIp}:${resource}`;
|
|
4294
4363
|
return void 0;
|
|
4295
4364
|
}
|
|
4296
4365
|
};
|
|
@@ -4324,7 +4393,7 @@ var init_middleware_module = __esm({
|
|
|
4324
4393
|
"use strict";
|
|
4325
4394
|
MiddlewareModule = class {
|
|
4326
4395
|
async configure(container, opts) {
|
|
4327
|
-
const { Guards:
|
|
4396
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
4328
4397
|
const { HttpCookieExtractor: HttpCookieExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4329
4398
|
const { HttpHeaderExtractor: HttpHeaderExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4330
4399
|
const tokenExtractor = await this._getTokenExtractor(
|
|
@@ -4354,7 +4423,7 @@ var init_middleware_module = __esm({
|
|
|
4354
4423
|
logger
|
|
4355
4424
|
)
|
|
4356
4425
|
);
|
|
4357
|
-
if (!
|
|
4426
|
+
if (!Guards51.isNullOrEmpty(opts.allowOrigins)) {
|
|
4358
4427
|
if (opts.withCredentials && opts.allowOrigins.includes("*"))
|
|
4359
4428
|
throw new Error(
|
|
4360
4429
|
"Wildcard CORS origin is not allowed when withCredentials is set to true in addHttpCore"
|
|
@@ -4380,7 +4449,7 @@ var init_middleware_module = __esm({
|
|
|
4380
4449
|
const { CORSMiddleware: CORSMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4381
4450
|
middlewares.push(new CORSMiddleware2(requestContext, withCredentials));
|
|
4382
4451
|
}
|
|
4383
|
-
if (
|
|
4452
|
+
if (Guards51.isDefined(opts.routeRegistry)) {
|
|
4384
4453
|
const { MethodCheckMiddleware: MethodCheckMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4385
4454
|
middlewares.push(new MethodCheckMiddleware2(requestContext, allowMethod));
|
|
4386
4455
|
}
|
|
@@ -4407,13 +4476,13 @@ var init_middleware_module = __esm({
|
|
|
4407
4476
|
)
|
|
4408
4477
|
);
|
|
4409
4478
|
}
|
|
4410
|
-
if (
|
|
4479
|
+
if (Guards51.isDefined(opts.rateLimite.maxRequests) || Guards51.isDefined(opts.rateLimite.windowSeconds)) {
|
|
4411
4480
|
const maxRequests = opts.rateLimite.maxRequests ?? 30;
|
|
4412
|
-
|
|
4413
|
-
|
|
4481
|
+
Guards51.throwIfNegative(maxRequests, "MaxRequests must be positive");
|
|
4482
|
+
Guards51.throwIfNotInteger(maxRequests, "MaxRequests must be an integer");
|
|
4414
4483
|
const windowSeconds = opts.rateLimite.windowSeconds ?? 30;
|
|
4415
|
-
|
|
4416
|
-
|
|
4484
|
+
Guards51.throwIfNegative(windowSeconds, "WindowSeconds must be positive");
|
|
4485
|
+
Guards51.throwIfNotInteger(windowSeconds, "WindowSeconds must be an integer");
|
|
4417
4486
|
const { RateLimitKeyBuilder: RateLimitKeyBuilder2 } = await Promise.resolve().then(() => (init_cache(), cache_exports));
|
|
4418
4487
|
const { RateLimitMiddleware: RateLimitMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4419
4488
|
middlewares.push(
|
|
@@ -4426,7 +4495,7 @@ var init_middleware_module = __esm({
|
|
|
4426
4495
|
)
|
|
4427
4496
|
);
|
|
4428
4497
|
}
|
|
4429
|
-
if (
|
|
4498
|
+
if (Guards51.isDefined(opts.csrf)) {
|
|
4430
4499
|
const csrf = opts.csrf;
|
|
4431
4500
|
const { EdgeCryptoService: EdgeCryptoService2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4432
4501
|
container.addSingleton("CRYPTO_SERVICE", () => new EdgeCryptoService2());
|
|
@@ -4451,8 +4520,8 @@ var init_middleware_module = __esm({
|
|
|
4451
4520
|
});
|
|
4452
4521
|
}
|
|
4453
4522
|
async _getTokenExtractor(isSSR, cookieName, customTokenExtractor) {
|
|
4454
|
-
const { Guards:
|
|
4455
|
-
if (
|
|
4523
|
+
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
4524
|
+
if (Guards51.isDefined(customTokenExtractor)) return customTokenExtractor();
|
|
4456
4525
|
if (isSSR) {
|
|
4457
4526
|
const { SupabaseSsrTokenExtractor: SupabaseSsrTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4458
4527
|
return new SupabaseSsrTokenExtractor2();
|
|
@@ -4462,8 +4531,8 @@ var init_middleware_module = __esm({
|
|
|
4462
4531
|
}
|
|
4463
4532
|
}
|
|
4464
4533
|
async _getAllowMethod(configure, opts) {
|
|
4465
|
-
const { Guards:
|
|
4466
|
-
if (!configure || !
|
|
4534
|
+
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
4535
|
+
if (!configure || !Guards51.isDefined(opts)) return void 0;
|
|
4467
4536
|
const { AllowMethodFactory: AllowMethodFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
4468
4537
|
return new AllowMethodFactory2().create(opts);
|
|
4469
4538
|
}
|
|
@@ -4493,8 +4562,8 @@ var init_cache_utils = __esm({
|
|
|
4493
4562
|
* @link https://github.com/xeno-js/xeno-js
|
|
4494
4563
|
*/
|
|
4495
4564
|
async addCache(container, opts) {
|
|
4496
|
-
const { Guards:
|
|
4497
|
-
if (!opts.inMemory && !
|
|
4565
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
4566
|
+
if (!opts.inMemory && !Guards51.isDefined(opts.redis)) {
|
|
4498
4567
|
throw new Error(
|
|
4499
4568
|
"No cache strategies are configured. Please provide at least one cache strategy."
|
|
4500
4569
|
);
|
|
@@ -4504,12 +4573,12 @@ var init_cache_utils = __esm({
|
|
|
4504
4573
|
TOKENS5.CACHE_KEY_BUILDER,
|
|
4505
4574
|
(c) => new CacheKeyBuilder(c.resolve(TOKENS5.IDENTITY_ACCESSOR))
|
|
4506
4575
|
);
|
|
4507
|
-
if (opts.inMemory || !
|
|
4576
|
+
if (opts.inMemory || !Guards51.isDefined(opts.redis)) {
|
|
4508
4577
|
const { InMemoryCacheExtended: InMemoryCacheExtended2 } = await Promise.resolve().then(() => (init_inmemory_cache(), inmemory_cache_exports));
|
|
4509
4578
|
container.addSingleton(TOKENS5.CACHE, () => new InMemoryCacheExtended2());
|
|
4510
4579
|
return;
|
|
4511
4580
|
}
|
|
4512
|
-
if (
|
|
4581
|
+
if (Guards51.isDefined(opts.redis)) {
|
|
4513
4582
|
const { RedisCacheFactory: RedisCacheFactory2 } = await Promise.resolve().then(() => (init_redis_cache_factory(), redis_cache_factory_exports));
|
|
4514
4583
|
container.addSingleton(TOKENS5.CACHE, () => {
|
|
4515
4584
|
const config = opts.redis;
|
|
@@ -4526,7 +4595,7 @@ var console_logger_exports = {};
|
|
|
4526
4595
|
__export(console_logger_exports, {
|
|
4527
4596
|
ConsoleLogger: () => ConsoleLogger
|
|
4528
4597
|
});
|
|
4529
|
-
import { Guards as
|
|
4598
|
+
import { Guards as Guards47, LOG_LEVEL as LOG_LEVEL5 } from "@xeno-js/shared";
|
|
4530
4599
|
var ConsoleLogger;
|
|
4531
4600
|
var init_console_logger = __esm({
|
|
4532
4601
|
"src/infrastructure/loggers/console.logger.ts"() {
|
|
@@ -4549,7 +4618,7 @@ var init_console_logger = __esm({
|
|
|
4549
4618
|
track(level, message, context, error = void 0) {
|
|
4550
4619
|
if (level < this._minLevel) return;
|
|
4551
4620
|
const logMessage = `[${level}] ${message}`;
|
|
4552
|
-
const payload =
|
|
4621
|
+
const payload = Guards47.isDefined(error) ? { ...context, error } : context;
|
|
4553
4622
|
switch (level) {
|
|
4554
4623
|
case LOG_LEVEL5.ERROR:
|
|
4555
4624
|
console.error(logMessage, payload ?? {});
|
|
@@ -4593,24 +4662,24 @@ var init_logger_utils = __esm({
|
|
|
4593
4662
|
*/
|
|
4594
4663
|
async addLogger(container, opts) {
|
|
4595
4664
|
const loggerDependencies = [];
|
|
4596
|
-
const { Guards:
|
|
4597
|
-
if (!
|
|
4665
|
+
const { Guards: Guards51, LOG_LEVEL: LOG_LEVEL7, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
4666
|
+
if (!Guards51.isDefined(opts) || opts.console) {
|
|
4598
4667
|
const { ConsoleLogger: ConsoleLogger2 } = await Promise.resolve().then(() => (init_console_logger(), console_logger_exports));
|
|
4599
4668
|
loggerDependencies.push(new ConsoleLogger2(opts?.level));
|
|
4600
4669
|
}
|
|
4601
|
-
if (
|
|
4602
|
-
if (
|
|
4670
|
+
if (Guards51.isDefined(opts)) {
|
|
4671
|
+
if (Guards51.isDefined(opts.sentry.config)) {
|
|
4603
4672
|
const { SentryLoggerFactory: SentryLoggerFactory2 } = await Promise.resolve().then(() => (init_sentry_logger_factory(), sentry_logger_factory_exports));
|
|
4604
4673
|
loggerDependencies.push(new SentryLoggerFactory2().create(opts));
|
|
4605
4674
|
}
|
|
4606
|
-
if (
|
|
4675
|
+
if (Guards51.isDefined(opts.pino.config)) {
|
|
4607
4676
|
const { PinoLoggerFactory: PinoLoggerFactory2 } = await Promise.resolve().then(() => (init_pino_logger_factory(), pino_logger_factory_exports));
|
|
4608
4677
|
loggerDependencies.push(new PinoLoggerFactory2().create(opts));
|
|
4609
4678
|
}
|
|
4610
|
-
if (!
|
|
4679
|
+
if (!Guards51.isNullOrEmpty(opts.customLoggers)) {
|
|
4611
4680
|
const customLoggers = opts.customLoggers;
|
|
4612
4681
|
customLoggers.forEach((fn) => {
|
|
4613
|
-
if (
|
|
4682
|
+
if (Guards51.isDefined(fn)) loggerDependencies.push(fn(container));
|
|
4614
4683
|
});
|
|
4615
4684
|
}
|
|
4616
4685
|
}
|
|
@@ -4675,6 +4744,7 @@ __export(index_exports, {
|
|
|
4675
4744
|
BaseAuthorizationStrategy: () => BaseAuthorizationStrategy,
|
|
4676
4745
|
BaseController: () => BaseController,
|
|
4677
4746
|
BaseHandler: () => BaseHandler,
|
|
4747
|
+
BaseHttpAdapter: () => BaseHttpAdapter,
|
|
4678
4748
|
BasePostgresSqlDataSource: () => BasePostgresSqlDataSource,
|
|
4679
4749
|
BaseQuery: () => Query,
|
|
4680
4750
|
BaseSqliteSqlDataSource: () => BaseSqliteSqlDataSource,
|
|
@@ -4687,7 +4757,7 @@ __export(index_exports, {
|
|
|
4687
4757
|
init_application();
|
|
4688
4758
|
|
|
4689
4759
|
// src/infrastructure/builder/app.builder.ts
|
|
4690
|
-
import { Guards as
|
|
4760
|
+
import { Guards as Guards48, LOG_LEVEL as LOG_LEVEL6, TOKENS as TOKENS4 } from "@xeno-js/shared";
|
|
4691
4761
|
|
|
4692
4762
|
// src/infrastructure/configuration/configuration.ts
|
|
4693
4763
|
import { Guards as Guards13 } from "@xeno-js/shared";
|
|
@@ -5125,7 +5195,7 @@ var AppBuilder = class {
|
|
|
5125
5195
|
* @link https://github.com/xeno-js/xeno-js
|
|
5126
5196
|
*/
|
|
5127
5197
|
addLogger(setupAction) {
|
|
5128
|
-
if (
|
|
5198
|
+
if (Guards48.isDefined(setupAction)) setupAction(this._loggerConfig, this._configuration);
|
|
5129
5199
|
if (this._isLoggerModuleQueued) return this;
|
|
5130
5200
|
this._isLoggerModuleQueued = true;
|
|
5131
5201
|
this._modules.push({
|
|
@@ -5150,7 +5220,7 @@ var AppBuilder = class {
|
|
|
5150
5220
|
* @link https://github.com/xeno-js/xeno-js
|
|
5151
5221
|
*/
|
|
5152
5222
|
addCache(setupAction) {
|
|
5153
|
-
if (
|
|
5223
|
+
if (Guards48.isDefined(setupAction)) setupAction(this._config, this._configuration);
|
|
5154
5224
|
if (this._isCacheModuleQueued) return this;
|
|
5155
5225
|
this._isCacheModuleQueued = true;
|
|
5156
5226
|
this._modules.push({
|
|
@@ -5253,7 +5323,7 @@ var AppBuilder = class {
|
|
|
5253
5323
|
* @link https://github.com/xeno-js/xeno-js
|
|
5254
5324
|
*/
|
|
5255
5325
|
addPipeline(setupAction) {
|
|
5256
|
-
if (
|
|
5326
|
+
if (Guards48.isDefined(setupAction)) {
|
|
5257
5327
|
setupAction(this._pipelineConfig, this._configuration);
|
|
5258
5328
|
}
|
|
5259
5329
|
this._queuePipelineModule();
|
|
@@ -5374,7 +5444,7 @@ var AppBuilder = class {
|
|
|
5374
5444
|
console.error(`\u{1F449} Module: **${queued.name}**`);
|
|
5375
5445
|
console.error(`\u{1F4DD} Reason: ${errorMessage}
|
|
5376
5446
|
`);
|
|
5377
|
-
if (error instanceof Error &&
|
|
5447
|
+
if (error instanceof Error && Guards48.isDefined(error.stack)) {
|
|
5378
5448
|
console.error(error.stack);
|
|
5379
5449
|
}
|
|
5380
5450
|
throw new Error(`Bootstrap failed at [${queued.name}]: ${errorMessage}`, { cause: error });
|
|
@@ -5506,6 +5576,7 @@ import { AppError as AppError15, Result as Result16 } from "@xeno-js/shared";
|
|
|
5506
5576
|
|
|
5507
5577
|
// src/infrastructure/index.ts
|
|
5508
5578
|
init_factories();
|
|
5579
|
+
init_http();
|
|
5509
5580
|
init_idempotency();
|
|
5510
5581
|
|
|
5511
5582
|
// src/infrastructure/loggers/index.ts
|
|
@@ -5518,7 +5589,7 @@ init_modules();
|
|
|
5518
5589
|
|
|
5519
5590
|
// src/infrastructure/repositories/read-dao.ts
|
|
5520
5591
|
import { AppError as AppError16, Result as Result17 } from "@xeno-js/shared";
|
|
5521
|
-
import { Guards as
|
|
5592
|
+
import { Guards as Guards49 } from "@xeno-js/shared";
|
|
5522
5593
|
var ReadDao = class {
|
|
5523
5594
|
/**
|
|
5524
5595
|
* Constructs a new ReadDao instance.
|
|
@@ -5540,7 +5611,7 @@ var ReadDao = class {
|
|
|
5540
5611
|
async findById(id, ctx, signal) {
|
|
5541
5612
|
AppError16.throwIfAborted(signal, "ReadDao.findById");
|
|
5542
5613
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5543
|
-
if (
|
|
5614
|
+
if (Guards49.isNullOrEmpty(result)) return Result17.ok();
|
|
5544
5615
|
const entity = this._mapper.toEntity(result);
|
|
5545
5616
|
return Result17.ok(entity);
|
|
5546
5617
|
}
|
|
@@ -5554,7 +5625,7 @@ var ReadDao = class {
|
|
|
5554
5625
|
|
|
5555
5626
|
// src/infrastructure/repositories/repository.ts
|
|
5556
5627
|
import { AppError as AppError17, Result as Result18 } from "@xeno-js/shared";
|
|
5557
|
-
import { Guards as
|
|
5628
|
+
import { Guards as Guards50 } from "@xeno-js/shared";
|
|
5558
5629
|
var Repository = class {
|
|
5559
5630
|
/**
|
|
5560
5631
|
* Constructs a new Repository instance.
|
|
@@ -5576,7 +5647,7 @@ var Repository = class {
|
|
|
5576
5647
|
async findById(id, ctx, signal) {
|
|
5577
5648
|
AppError17.throwIfAborted(signal, "Repository.findById");
|
|
5578
5649
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5579
|
-
if (
|
|
5650
|
+
if (Guards50.isNullOrEmpty(result)) return Result18.ok();
|
|
5580
5651
|
const entity = this._mapper.toEntity(result);
|
|
5581
5652
|
return Result18.ok(entity);
|
|
5582
5653
|
}
|
|
@@ -5627,6 +5698,7 @@ export {
|
|
|
5627
5698
|
BaseAuthorizationStrategy,
|
|
5628
5699
|
BaseController,
|
|
5629
5700
|
BaseHandler,
|
|
5701
|
+
BaseHttpAdapter,
|
|
5630
5702
|
BasePostgresSqlDataSource,
|
|
5631
5703
|
Query as BaseQuery,
|
|
5632
5704
|
BaseSqliteSqlDataSource,
|