@xeno-js/core 1.2.4 → 1.2.6
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 +286 -210
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +170 -94
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1588,7 +1588,7 @@ var init_cookies_service = __esm({
|
|
|
1588
1588
|
contextAccessor;
|
|
1589
1589
|
_config;
|
|
1590
1590
|
_cookieOpts;
|
|
1591
|
-
getAll
|
|
1591
|
+
getAll() {
|
|
1592
1592
|
const network = this.contextAccessor.getNetworkContext();
|
|
1593
1593
|
const req = network?.transport?.req;
|
|
1594
1594
|
if (!Guards19.isDefined(req) || Guards19.isNullOrEmpty(req.headers.get("cookie"))) return [];
|
|
@@ -1596,8 +1596,8 @@ var init_cookies_service = __esm({
|
|
|
1596
1596
|
const [name, ...rest] = cookie.split("=");
|
|
1597
1597
|
return { name: name.trim(), value: rest.join("=") };
|
|
1598
1598
|
}) ?? [];
|
|
1599
|
-
}
|
|
1600
|
-
setAll
|
|
1599
|
+
}
|
|
1600
|
+
setAll(cookies) {
|
|
1601
1601
|
const network = this.contextAccessor.getNetworkContext();
|
|
1602
1602
|
const res = network?.transport?.res;
|
|
1603
1603
|
if (!Guards19.isDefined(res)) return;
|
|
@@ -1607,7 +1607,7 @@ var init_cookies_service = __esm({
|
|
|
1607
1607
|
for (const cookie of [...existingSetCookie, ...serializedCookies]) {
|
|
1608
1608
|
res.headers.append("Set-Cookie", cookie);
|
|
1609
1609
|
}
|
|
1610
|
-
}
|
|
1610
|
+
}
|
|
1611
1611
|
serialize(cookie) {
|
|
1612
1612
|
const safeName = encodeURIComponent(cookie.name);
|
|
1613
1613
|
const safeValue = encodeURIComponent(cookie.value);
|
|
@@ -2593,7 +2593,14 @@ var init_supabase_factory = __esm({
|
|
|
2593
2593
|
const cookieService = this._getCookieSsr(config.ssrOpts, container, config.cookieOpts);
|
|
2594
2594
|
const client = createServerClient(config.url, config.key, {
|
|
2595
2595
|
...config.opts,
|
|
2596
|
-
cookies:
|
|
2596
|
+
cookies: {
|
|
2597
|
+
getAll() {
|
|
2598
|
+
return cookieService.getAll();
|
|
2599
|
+
},
|
|
2600
|
+
setAll(cookiesToSet) {
|
|
2601
|
+
cookieService.setAll(cookiesToSet);
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2597
2604
|
});
|
|
2598
2605
|
const mapper = new SupabaseClaimsMapper();
|
|
2599
2606
|
const sessionMapper = new SupabaseSessionMapper(mapper);
|
|
@@ -2692,8 +2699,8 @@ var init_auth_utils = __esm({
|
|
|
2692
2699
|
async addAuthZ(container, opts) {
|
|
2693
2700
|
const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2694
2701
|
const strategies = [];
|
|
2695
|
-
const { Guards:
|
|
2696
|
-
if (
|
|
2702
|
+
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
2703
|
+
if (Guards51.isDefined(opts.policies)) {
|
|
2697
2704
|
const { PolicyRegistry: PolicyRegistry2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2698
2705
|
const policyRegistry = opts.policies;
|
|
2699
2706
|
const registryInstance = new PolicyRegistry2();
|
|
@@ -2702,16 +2709,16 @@ var init_auth_utils = __esm({
|
|
|
2702
2709
|
for (const [intent, policy] of Object.entries(policyRegistry)) {
|
|
2703
2710
|
const intentLower = intent.toLowerCase();
|
|
2704
2711
|
registryInstance.addPolicy(intentLower, policy);
|
|
2705
|
-
if (!
|
|
2712
|
+
if (!Guards51.isNullOrEmpty(policy.roles)) {
|
|
2706
2713
|
Policies.add("roles");
|
|
2707
2714
|
}
|
|
2708
|
-
if (!
|
|
2715
|
+
if (!Guards51.isNullOrEmpty(policy.permissions)) {
|
|
2709
2716
|
Policies.add("permissions");
|
|
2710
2717
|
}
|
|
2711
|
-
if (!
|
|
2718
|
+
if (!Guards51.isNullOrEmpty(policy.userId)) {
|
|
2712
2719
|
Policies.add("userId");
|
|
2713
2720
|
}
|
|
2714
|
-
if (!
|
|
2721
|
+
if (!Guards51.isNullOrEmpty(policy.tenantId)) {
|
|
2715
2722
|
Policies.add("tenantId");
|
|
2716
2723
|
}
|
|
2717
2724
|
}
|
|
@@ -2732,10 +2739,10 @@ var init_auth_utils = __esm({
|
|
|
2732
2739
|
strategies.push(new TenantAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2733
2740
|
}
|
|
2734
2741
|
}
|
|
2735
|
-
if (!
|
|
2742
|
+
if (!Guards51.isNullOrEmpty(opts.customAuthorizationStrategy)) {
|
|
2736
2743
|
const customStrategies = opts.customAuthorizationStrategy;
|
|
2737
2744
|
customStrategies.forEach((strategyToken) => {
|
|
2738
|
-
if (
|
|
2745
|
+
if (Guards51.isDefined(strategyToken)) {
|
|
2739
2746
|
strategies.push(strategyToken(container));
|
|
2740
2747
|
}
|
|
2741
2748
|
});
|
|
@@ -2755,8 +2762,8 @@ var init_auth_utils = __esm({
|
|
|
2755
2762
|
* @link https://github.com/xeno-js/xeno-js
|
|
2756
2763
|
*/
|
|
2757
2764
|
async addAuthN(container, opts) {
|
|
2758
|
-
const { Guards:
|
|
2759
|
-
if (
|
|
2765
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2766
|
+
if (Guards51.isDefined(opts.customAuth)) {
|
|
2760
2767
|
const authService = opts.customAuth.authExtendedService();
|
|
2761
2768
|
container.addScoped(TOKENS5.AUTH_SERVICE, () => {
|
|
2762
2769
|
return authService;
|
|
@@ -2801,12 +2808,12 @@ var init_validation_utils = __esm({
|
|
|
2801
2808
|
* @link https://github.com/xeno-js/xeno-js
|
|
2802
2809
|
*/
|
|
2803
2810
|
async addValidation(container, opts, logger) {
|
|
2804
|
-
const { Guards:
|
|
2805
|
-
if (!
|
|
2811
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2812
|
+
if (!Guards51.isDefined(opts.zod) && Guards51.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
2806
2813
|
return;
|
|
2807
2814
|
}
|
|
2808
2815
|
const validationStrategies = [];
|
|
2809
|
-
if (
|
|
2816
|
+
if (Guards51.isDefined(opts.zod)) {
|
|
2810
2817
|
const config = opts.zod;
|
|
2811
2818
|
const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
2812
2819
|
const { SchemaValidationStrategy: SchemaValidationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
@@ -2814,9 +2821,9 @@ var init_validation_utils = __esm({
|
|
|
2814
2821
|
container.addSingleton(TOKENS5.VALIDATOR_SERVICE, () => validatorService);
|
|
2815
2822
|
validationStrategies.push(new SchemaValidationStrategy2(validatorService));
|
|
2816
2823
|
}
|
|
2817
|
-
if (!
|
|
2824
|
+
if (!Guards51.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
2818
2825
|
for (const strategyToken of opts.customValidationStrategy) {
|
|
2819
|
-
if (
|
|
2826
|
+
if (Guards51.isDefined(strategyToken)) validationStrategies.push(strategyToken(container));
|
|
2820
2827
|
}
|
|
2821
2828
|
}
|
|
2822
2829
|
const { ValidationPipeline: ValidationPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
@@ -2916,9 +2923,9 @@ var init_pipeline_utils = __esm({
|
|
|
2916
2923
|
* @link https://github.com/xeno-js/xeno-js
|
|
2917
2924
|
*/
|
|
2918
2925
|
async addCommand(container, opts) {
|
|
2919
|
-
const { Guards:
|
|
2926
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2920
2927
|
const pipelines = [];
|
|
2921
|
-
if (
|
|
2928
|
+
if (Guards51.isDefined(opts.idempotency)) {
|
|
2922
2929
|
const { IdempotencyStore: IdempotencyStore2 } = await Promise.resolve().then(() => (init_idempotency(), idempotency_exports));
|
|
2923
2930
|
const imdStore = new IdempotencyStore2(
|
|
2924
2931
|
container.resolve(TOKENS5.CACHE),
|
|
@@ -2936,7 +2943,7 @@ var init_pipeline_utils = __esm({
|
|
|
2936
2943
|
)
|
|
2937
2944
|
);
|
|
2938
2945
|
}
|
|
2939
|
-
if (
|
|
2946
|
+
if (Guards51.isDefined(opts.concurrency)) {
|
|
2940
2947
|
const { ConcurrencyRetryPipeline: ConcurrencyRetryPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2941
2948
|
const config = opts.concurrency;
|
|
2942
2949
|
pipelines.push(new ConcurrencyRetryPipeline2(config?.maxRetries, config?.delayConfig));
|
|
@@ -2993,24 +3000,24 @@ var init_cqrs_module = __esm({
|
|
|
2993
3000
|
new LoggingPipeline2(logger),
|
|
2994
3001
|
new PerformancePipeline2(logger, thresholdMs)
|
|
2995
3002
|
];
|
|
2996
|
-
const { Guards:
|
|
2997
|
-
if (
|
|
3003
|
+
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
3004
|
+
if (Guards51.isDefined(opts.authorization.policies) || Guards51.isDefined(opts.authorization.customAuthorizationStrategy)) {
|
|
2998
3005
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
2999
3006
|
const authPipelines = await AuthUtils2.addAuthZ(container, opts.authorization);
|
|
3000
3007
|
pipelines.push(authPipelines);
|
|
3001
3008
|
}
|
|
3002
|
-
if (
|
|
3009
|
+
if (Guards51.isDefined(opts.validation.zod) || Guards51.isDefined(opts.validation.customValidationStrategy)) {
|
|
3003
3010
|
const { ValidationUtils: ValidationUtils2 } = await Promise.resolve().then(() => (init_validation_utils(), validation_utils_exports));
|
|
3004
3011
|
const validationPipelines = await ValidationUtils2.addValidation(
|
|
3005
3012
|
container,
|
|
3006
3013
|
opts.validation,
|
|
3007
3014
|
logger
|
|
3008
3015
|
);
|
|
3009
|
-
if (
|
|
3016
|
+
if (Guards51.isDefined(validationPipelines)) pipelines.push(validationPipelines);
|
|
3010
3017
|
}
|
|
3011
3018
|
const commandPipelines = [...pipelines];
|
|
3012
3019
|
const queryPipelines = [...pipelines];
|
|
3013
|
-
if (
|
|
3020
|
+
if (Guards51.isDefined(opts.commandBus.idempotency) || Guards51.isDefined(opts.commandBus.concurrency)) {
|
|
3014
3021
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3015
3022
|
const newCommandPipelines = await PipelineUtils2.addCommand(container, opts.commandBus);
|
|
3016
3023
|
commandPipelines.push(...newCommandPipelines);
|
|
@@ -3179,7 +3186,7 @@ var init_db_module = __esm({
|
|
|
3179
3186
|
"use strict";
|
|
3180
3187
|
DbModule = class {
|
|
3181
3188
|
async configure(container, opts) {
|
|
3182
|
-
const { Guards:
|
|
3189
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
3183
3190
|
const { DbUtils: DbUtils2 } = await Promise.resolve().then(() => (init_db_utils(), db_utils_exports));
|
|
3184
3191
|
const db = opts.enableSqlLite ? await DbUtils2.addSqlLite(opts) : await DbUtils2.addDbClient(opts);
|
|
3185
3192
|
const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
|
|
@@ -3196,7 +3203,7 @@ var init_db_module = __esm({
|
|
|
3196
3203
|
return new Proxy(db, {
|
|
3197
3204
|
get(_target, prop, receiver) {
|
|
3198
3205
|
const activeState = ttx.state;
|
|
3199
|
-
if (
|
|
3206
|
+
if (Guards51.isDefined(activeState)) {
|
|
3200
3207
|
if (prop === "transaction") {
|
|
3201
3208
|
return activeState.transaction.bind(activeState);
|
|
3202
3209
|
}
|
|
@@ -3281,7 +3288,7 @@ var init_base_http_adapter = __esm({
|
|
|
3281
3288
|
* @param body The body.
|
|
3282
3289
|
* @returns The XenoWebTransport.
|
|
3283
3290
|
*/
|
|
3284
|
-
createXenoWebTransport(url, method = "GET", headers, body = void 0) {
|
|
3291
|
+
createXenoWebTransport(url, method = "GET", headers, body = void 0, res = void 0) {
|
|
3285
3292
|
const init2 = {
|
|
3286
3293
|
method: method.toUpperCase(),
|
|
3287
3294
|
headers
|
|
@@ -3293,9 +3300,27 @@ var init_base_http_adapter = __esm({
|
|
|
3293
3300
|
}
|
|
3294
3301
|
const extendedRequest = new Request(url, init2);
|
|
3295
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
|
+
}
|
|
3296
3321
|
return {
|
|
3297
3322
|
request: extendedRequest,
|
|
3298
|
-
response:
|
|
3323
|
+
response: webResponse
|
|
3299
3324
|
};
|
|
3300
3325
|
}
|
|
3301
3326
|
};
|
|
@@ -3303,6 +3328,7 @@ var init_base_http_adapter = __esm({
|
|
|
3303
3328
|
});
|
|
3304
3329
|
|
|
3305
3330
|
// src/infrastructure/http/fastify.http-adapter.ts
|
|
3331
|
+
import { Guards as Guards36 } from "@xeno-js/shared";
|
|
3306
3332
|
var FastifyHttpAdapter;
|
|
3307
3333
|
var init_fastify_http_adapter = __esm({
|
|
3308
3334
|
"src/infrastructure/http/fastify.http-adapter.ts"() {
|
|
@@ -3315,6 +3341,29 @@ var init_fastify_http_adapter = __esm({
|
|
|
3315
3341
|
const body = req.body;
|
|
3316
3342
|
return this.createXenoWebTransport(url, req.method, headers, body);
|
|
3317
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
|
+
}
|
|
3366
|
+
}
|
|
3318
3367
|
};
|
|
3319
3368
|
}
|
|
3320
3369
|
});
|
|
@@ -3334,11 +3383,15 @@ var init_native_http_adapter = __esm({
|
|
|
3334
3383
|
response: res
|
|
3335
3384
|
};
|
|
3336
3385
|
}
|
|
3386
|
+
handleHeaderChange(_res, _name, _value, _action) {
|
|
3387
|
+
return;
|
|
3388
|
+
}
|
|
3337
3389
|
};
|
|
3338
3390
|
}
|
|
3339
3391
|
});
|
|
3340
3392
|
|
|
3341
3393
|
// src/infrastructure/http/vercel.http-adapter.ts
|
|
3394
|
+
import { Guards as Guards37 } from "@xeno-js/shared";
|
|
3342
3395
|
var VercelHttpAdapter;
|
|
3343
3396
|
var init_vercel_http_adapter = __esm({
|
|
3344
3397
|
"src/infrastructure/http/vercel.http-adapter.ts"() {
|
|
@@ -3350,6 +3403,29 @@ var init_vercel_http_adapter = __esm({
|
|
|
3350
3403
|
const url = this.parseUrl(req.url, req.headers, req.query);
|
|
3351
3404
|
return this.createXenoWebTransport(url, req.method, headers, req.body);
|
|
3352
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
|
+
}
|
|
3428
|
+
}
|
|
3353
3429
|
};
|
|
3354
3430
|
}
|
|
3355
3431
|
});
|
|
@@ -3373,7 +3449,7 @@ var init_http = __esm({
|
|
|
3373
3449
|
});
|
|
3374
3450
|
|
|
3375
3451
|
// src/infrastructure/modules/http-adapter.module.ts
|
|
3376
|
-
import { Guards as
|
|
3452
|
+
import { Guards as Guards38 } from "@xeno-js/shared";
|
|
3377
3453
|
var HttpAdapterModule;
|
|
3378
3454
|
var init_http_adapter_module = __esm({
|
|
3379
3455
|
"src/infrastructure/modules/http-adapter.module.ts"() {
|
|
@@ -3390,7 +3466,7 @@ var init_http_adapter_module = __esm({
|
|
|
3390
3466
|
} else if (opts.fastify) {
|
|
3391
3467
|
const { FastifyHttpAdapter: FastifyHttpAdapter2 } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
3392
3468
|
return new FastifyHttpAdapter2();
|
|
3393
|
-
} else if (
|
|
3469
|
+
} else if (Guards38.isDefined(opts.custom)) {
|
|
3394
3470
|
return opts.custom();
|
|
3395
3471
|
} else {
|
|
3396
3472
|
const { NativeHttpAdapter: NativeHttpAdapter2 } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
@@ -3423,14 +3499,14 @@ var init_http_utils = __esm({
|
|
|
3423
3499
|
*/
|
|
3424
3500
|
async addAxios(container, opts) {
|
|
3425
3501
|
const { NodeAxiosFactory: NodeAxiosFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3426
|
-
const { Guards:
|
|
3427
|
-
if (!
|
|
3502
|
+
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
3503
|
+
if (!Guards51.isDefined(opts.token)) {
|
|
3428
3504
|
throw new Error("HttpConfig.token is required and must be defined.");
|
|
3429
3505
|
}
|
|
3430
3506
|
container.addSingleton(opts.token, () => {
|
|
3431
3507
|
const factory = new NodeAxiosFactory2();
|
|
3432
3508
|
const instance = factory.create(opts.client);
|
|
3433
|
-
if (!
|
|
3509
|
+
if (!Guards51.hasMethod(instance, "get") || !Guards51.hasMethod(instance, "post") || !Guards51.hasMethod(instance, "put") || !Guards51.hasMethod(instance, "patch") || !Guards51.hasMethod(instance, "delete")) {
|
|
3434
3510
|
throw new Error(
|
|
3435
3511
|
"The created HTTP client instance does not implement the required methods of IHttpClient."
|
|
3436
3512
|
);
|
|
@@ -3772,7 +3848,7 @@ var init_composite_middleware = __esm({
|
|
|
3772
3848
|
});
|
|
3773
3849
|
|
|
3774
3850
|
// src/presentation/middlewares/cors.middleware.ts
|
|
3775
|
-
import { Guards as
|
|
3851
|
+
import { Guards as Guards39 } from "@xeno-js/shared";
|
|
3776
3852
|
var CORSMiddleware;
|
|
3777
3853
|
var init_cors_middleware = __esm({
|
|
3778
3854
|
"src/presentation/middlewares/cors.middleware.ts"() {
|
|
@@ -3788,7 +3864,7 @@ var init_cors_middleware = __esm({
|
|
|
3788
3864
|
const { network } = this._requestContext.getContext() ?? {};
|
|
3789
3865
|
const origin = network?.origin;
|
|
3790
3866
|
const response = await next();
|
|
3791
|
-
if (
|
|
3867
|
+
if (Guards39.isDefined(origin))
|
|
3792
3868
|
response.headers = {
|
|
3793
3869
|
...response.headers ?? {},
|
|
3794
3870
|
"Access-Control-Allow-Origin": origin,
|
|
@@ -3805,7 +3881,7 @@ var init_cors_middleware = __esm({
|
|
|
3805
3881
|
import {
|
|
3806
3882
|
ERROR_CODE_MESSAGES as ERROR_CODE_MESSAGES5,
|
|
3807
3883
|
ERROR_CODES as ERROR_CODES6,
|
|
3808
|
-
Guards as
|
|
3884
|
+
Guards as Guards40,
|
|
3809
3885
|
GuidHelper as GuidHelper9,
|
|
3810
3886
|
HttpHelper as HttpHelper6,
|
|
3811
3887
|
STATUS_CODES as STATUS_CODES7
|
|
@@ -3828,7 +3904,7 @@ var init_csrf_middleware = __esm({
|
|
|
3828
3904
|
const { network, tracing, identity } = this._requestContext.getContext() ?? {};
|
|
3829
3905
|
const headerToken = network?.csrf;
|
|
3830
3906
|
const cookieToken = network?.csrfCookie;
|
|
3831
|
-
if (!
|
|
3907
|
+
if (!Guards40.isDefined(headerToken) || !Guards40.isDefined(cookieToken)) {
|
|
3832
3908
|
return HttpHelper6.error(
|
|
3833
3909
|
{
|
|
3834
3910
|
success: false,
|
|
@@ -3870,7 +3946,7 @@ var init_csrf_middleware = __esm({
|
|
|
3870
3946
|
}
|
|
3871
3947
|
);
|
|
3872
3948
|
}
|
|
3873
|
-
if (!
|
|
3949
|
+
if (!Guards40.isDefined(identity?.userId) || !await this._csrfTokenService.validate(headerToken, identity?.userId)) {
|
|
3874
3950
|
return HttpHelper6.error(
|
|
3875
3951
|
{
|
|
3876
3952
|
success: false,
|
|
@@ -3899,7 +3975,7 @@ var init_csrf_middleware = __esm({
|
|
|
3899
3975
|
});
|
|
3900
3976
|
|
|
3901
3977
|
// src/presentation/middlewares/csrf-cookie.middleware.ts
|
|
3902
|
-
import { Guards as
|
|
3978
|
+
import { Guards as Guards41 } from "@xeno-js/shared";
|
|
3903
3979
|
var CsrfCookieMiddleware;
|
|
3904
3980
|
var init_csrf_cookie_middleware = __esm({
|
|
3905
3981
|
"src/presentation/middlewares/csrf-cookie.middleware.ts"() {
|
|
@@ -3918,8 +3994,8 @@ var init_csrf_cookie_middleware = __esm({
|
|
|
3918
3994
|
const context = this._requestContext.getContext();
|
|
3919
3995
|
const identity = context?.identity;
|
|
3920
3996
|
const network = context?.network;
|
|
3921
|
-
if (!
|
|
3922
|
-
if (
|
|
3997
|
+
if (!Guards41.isDefined(identity?.userId)) return response;
|
|
3998
|
+
if (Guards41.isDefined(network?.csrfCookie)) return response;
|
|
3923
3999
|
const token = await this._csrfTokenService.generate(identity.userId);
|
|
3924
4000
|
const cookieName = this._csrf.cookieName ?? "__Host-xeno-csrf";
|
|
3925
4001
|
const maxAge = this._csrf.cookieMaxAgeSeconds ?? 3600;
|
|
@@ -3937,7 +4013,7 @@ var init_csrf_cookie_middleware = __esm({
|
|
|
3937
4013
|
});
|
|
3938
4014
|
|
|
3939
4015
|
// src/presentation/middlewares/options.middleware.ts
|
|
3940
|
-
import { Guards as
|
|
4016
|
+
import { Guards as Guards42, HttpHelper as HttpHelper7, STATUS_CODES as STATUS_CODES8 } from "@xeno-js/shared";
|
|
3941
4017
|
var OptionsMiddleware;
|
|
3942
4018
|
var init_options_middleware = __esm({
|
|
3943
4019
|
"src/presentation/middlewares/options.middleware.ts"() {
|
|
@@ -3958,7 +4034,7 @@ var init_options_middleware = __esm({
|
|
|
3958
4034
|
const network = this._requestContext.getNetworkContext();
|
|
3959
4035
|
const origin = network?.origin;
|
|
3960
4036
|
const headers = {};
|
|
3961
|
-
if (
|
|
4037
|
+
if (Guards42.isDefined(origin)) {
|
|
3962
4038
|
headers["Access-Control-Allow-Origin"] = origin;
|
|
3963
4039
|
headers["Access-Control-Allow-Credentials"] = this._withCredentials;
|
|
3964
4040
|
headers["Vary"] = "Origin";
|
|
@@ -3977,7 +4053,7 @@ var init_options_middleware = __esm({
|
|
|
3977
4053
|
import {
|
|
3978
4054
|
ERROR_CODE_MESSAGES as ERROR_CODE_MESSAGES6,
|
|
3979
4055
|
ERROR_CODES as ERROR_CODES7,
|
|
3980
|
-
Guards as
|
|
4056
|
+
Guards as Guards43,
|
|
3981
4057
|
GuidHelper as GuidHelper10,
|
|
3982
4058
|
HttpHelper as HttpHelper8,
|
|
3983
4059
|
STATUS_CODES as STATUS_CODES9
|
|
@@ -4002,7 +4078,7 @@ var init_rate_limiter_middleware = __esm({
|
|
|
4002
4078
|
async execute(req, _res, next) {
|
|
4003
4079
|
const cacheKey = this._keyBuilder.buildRateLimitKey(req.path);
|
|
4004
4080
|
const { network, tracing } = this._ctxAccessor.getContext() ?? {};
|
|
4005
|
-
if (!
|
|
4081
|
+
if (!Guards43.isDefined(cacheKey))
|
|
4006
4082
|
return HttpHelper8.error(
|
|
4007
4083
|
{
|
|
4008
4084
|
success: false,
|
|
@@ -4054,10 +4130,10 @@ var init_rate_limiter_middleware = __esm({
|
|
|
4054
4130
|
});
|
|
4055
4131
|
|
|
4056
4132
|
// src/presentation/mappers/context.mapper.ts
|
|
4057
|
-
import { Guards as
|
|
4133
|
+
import { Guards as Guards44 } from "@xeno-js/shared";
|
|
4058
4134
|
function _buildMessagingContext(meta) {
|
|
4059
|
-
const hasSequenceData =
|
|
4060
|
-
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);
|
|
4061
4137
|
const messaging = hasMessagingData ? {
|
|
4062
4138
|
returnAddress: meta.returnAddress,
|
|
4063
4139
|
expiration: meta.expiration,
|
|
@@ -4245,7 +4321,7 @@ var inmemory_cache_exports = {};
|
|
|
4245
4321
|
__export(inmemory_cache_exports, {
|
|
4246
4322
|
InMemoryCacheExtended: () => InMemoryCacheExtended
|
|
4247
4323
|
});
|
|
4248
|
-
import { Guards as
|
|
4324
|
+
import { Guards as Guards45, InMemoryCache } from "@xeno-js/shared";
|
|
4249
4325
|
var InMemoryCacheExtended;
|
|
4250
4326
|
var init_inmemory_cache = __esm({
|
|
4251
4327
|
"src/infrastructure/cache/inmemory.cache.ts"() {
|
|
@@ -4254,7 +4330,7 @@ var init_inmemory_cache = __esm({
|
|
|
4254
4330
|
async increment(key, ttlSeconds) {
|
|
4255
4331
|
const current = await this.get(key) ?? 0;
|
|
4256
4332
|
const next = Number(current) + 1;
|
|
4257
|
-
const ttl =
|
|
4333
|
+
const ttl = Guards45.isDefined(ttlSeconds) ? Number(ttlSeconds) : 60;
|
|
4258
4334
|
await this.set(key, next, ttl);
|
|
4259
4335
|
return next;
|
|
4260
4336
|
}
|
|
@@ -4263,7 +4339,7 @@ var init_inmemory_cache = __esm({
|
|
|
4263
4339
|
});
|
|
4264
4340
|
|
|
4265
4341
|
// src/infrastructure/cache/rate-limit-key-builder.cache.ts
|
|
4266
|
-
import { Guards as
|
|
4342
|
+
import { Guards as Guards46 } from "@xeno-js/shared";
|
|
4267
4343
|
var RateLimitKeyBuilder;
|
|
4268
4344
|
var init_rate_limit_key_builder_cache = __esm({
|
|
4269
4345
|
"src/infrastructure/cache/rate-limit-key-builder.cache.ts"() {
|
|
@@ -4278,12 +4354,12 @@ var init_rate_limit_key_builder_cache = __esm({
|
|
|
4278
4354
|
const tenantId = ctx?.identity?.tenantId;
|
|
4279
4355
|
const userId = ctx?.identity?.userId;
|
|
4280
4356
|
const clientIp = ctx?.network?.clientIp;
|
|
4281
|
-
if (!
|
|
4357
|
+
if (!Guards46.isNullOrEmpty(tenantId) && !Guards46.isNullOrEmpty(userId))
|
|
4282
4358
|
return `ratelimit:tenant:${tenantId}:user:${userId}:${resource}`;
|
|
4283
|
-
if (!
|
|
4359
|
+
if (!Guards46.isNullOrEmpty(tenantId) && !Guards46.isNullOrEmpty(clientIp))
|
|
4284
4360
|
return `ratelimit:tenant:${tenantId}:ip:${clientIp}:${resource}`;
|
|
4285
|
-
if (!
|
|
4286
|
-
if (!
|
|
4361
|
+
if (!Guards46.isNullOrEmpty(userId)) return `ratelimit:user:${userId}:${resource}`;
|
|
4362
|
+
if (!Guards46.isNullOrEmpty(clientIp)) return `ratelimit:ip:${clientIp}:${resource}`;
|
|
4287
4363
|
return void 0;
|
|
4288
4364
|
}
|
|
4289
4365
|
};
|
|
@@ -4317,7 +4393,7 @@ var init_middleware_module = __esm({
|
|
|
4317
4393
|
"use strict";
|
|
4318
4394
|
MiddlewareModule = class {
|
|
4319
4395
|
async configure(container, opts) {
|
|
4320
|
-
const { Guards:
|
|
4396
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
4321
4397
|
const { HttpCookieExtractor: HttpCookieExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4322
4398
|
const { HttpHeaderExtractor: HttpHeaderExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4323
4399
|
const tokenExtractor = await this._getTokenExtractor(
|
|
@@ -4347,7 +4423,7 @@ var init_middleware_module = __esm({
|
|
|
4347
4423
|
logger
|
|
4348
4424
|
)
|
|
4349
4425
|
);
|
|
4350
|
-
if (!
|
|
4426
|
+
if (!Guards51.isNullOrEmpty(opts.allowOrigins)) {
|
|
4351
4427
|
if (opts.withCredentials && opts.allowOrigins.includes("*"))
|
|
4352
4428
|
throw new Error(
|
|
4353
4429
|
"Wildcard CORS origin is not allowed when withCredentials is set to true in addHttpCore"
|
|
@@ -4373,7 +4449,7 @@ var init_middleware_module = __esm({
|
|
|
4373
4449
|
const { CORSMiddleware: CORSMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4374
4450
|
middlewares.push(new CORSMiddleware2(requestContext, withCredentials));
|
|
4375
4451
|
}
|
|
4376
|
-
if (
|
|
4452
|
+
if (Guards51.isDefined(opts.routeRegistry)) {
|
|
4377
4453
|
const { MethodCheckMiddleware: MethodCheckMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4378
4454
|
middlewares.push(new MethodCheckMiddleware2(requestContext, allowMethod));
|
|
4379
4455
|
}
|
|
@@ -4400,13 +4476,13 @@ var init_middleware_module = __esm({
|
|
|
4400
4476
|
)
|
|
4401
4477
|
);
|
|
4402
4478
|
}
|
|
4403
|
-
if (
|
|
4479
|
+
if (Guards51.isDefined(opts.rateLimite.maxRequests) || Guards51.isDefined(opts.rateLimite.windowSeconds)) {
|
|
4404
4480
|
const maxRequests = opts.rateLimite.maxRequests ?? 30;
|
|
4405
|
-
|
|
4406
|
-
|
|
4481
|
+
Guards51.throwIfNegative(maxRequests, "MaxRequests must be positive");
|
|
4482
|
+
Guards51.throwIfNotInteger(maxRequests, "MaxRequests must be an integer");
|
|
4407
4483
|
const windowSeconds = opts.rateLimite.windowSeconds ?? 30;
|
|
4408
|
-
|
|
4409
|
-
|
|
4484
|
+
Guards51.throwIfNegative(windowSeconds, "WindowSeconds must be positive");
|
|
4485
|
+
Guards51.throwIfNotInteger(windowSeconds, "WindowSeconds must be an integer");
|
|
4410
4486
|
const { RateLimitKeyBuilder: RateLimitKeyBuilder2 } = await Promise.resolve().then(() => (init_cache(), cache_exports));
|
|
4411
4487
|
const { RateLimitMiddleware: RateLimitMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4412
4488
|
middlewares.push(
|
|
@@ -4419,7 +4495,7 @@ var init_middleware_module = __esm({
|
|
|
4419
4495
|
)
|
|
4420
4496
|
);
|
|
4421
4497
|
}
|
|
4422
|
-
if (
|
|
4498
|
+
if (Guards51.isDefined(opts.csrf)) {
|
|
4423
4499
|
const csrf = opts.csrf;
|
|
4424
4500
|
const { EdgeCryptoService: EdgeCryptoService2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4425
4501
|
container.addSingleton("CRYPTO_SERVICE", () => new EdgeCryptoService2());
|
|
@@ -4444,8 +4520,8 @@ var init_middleware_module = __esm({
|
|
|
4444
4520
|
});
|
|
4445
4521
|
}
|
|
4446
4522
|
async _getTokenExtractor(isSSR, cookieName, customTokenExtractor) {
|
|
4447
|
-
const { Guards:
|
|
4448
|
-
if (
|
|
4523
|
+
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
4524
|
+
if (Guards51.isDefined(customTokenExtractor)) return customTokenExtractor();
|
|
4449
4525
|
if (isSSR) {
|
|
4450
4526
|
const { SupabaseSsrTokenExtractor: SupabaseSsrTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4451
4527
|
return new SupabaseSsrTokenExtractor2();
|
|
@@ -4455,8 +4531,8 @@ var init_middleware_module = __esm({
|
|
|
4455
4531
|
}
|
|
4456
4532
|
}
|
|
4457
4533
|
async _getAllowMethod(configure, opts) {
|
|
4458
|
-
const { Guards:
|
|
4459
|
-
if (!configure || !
|
|
4534
|
+
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
4535
|
+
if (!configure || !Guards51.isDefined(opts)) return void 0;
|
|
4460
4536
|
const { AllowMethodFactory: AllowMethodFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
4461
4537
|
return new AllowMethodFactory2().create(opts);
|
|
4462
4538
|
}
|
|
@@ -4486,8 +4562,8 @@ var init_cache_utils = __esm({
|
|
|
4486
4562
|
* @link https://github.com/xeno-js/xeno-js
|
|
4487
4563
|
*/
|
|
4488
4564
|
async addCache(container, opts) {
|
|
4489
|
-
const { Guards:
|
|
4490
|
-
if (!opts.inMemory && !
|
|
4565
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
4566
|
+
if (!opts.inMemory && !Guards51.isDefined(opts.redis)) {
|
|
4491
4567
|
throw new Error(
|
|
4492
4568
|
"No cache strategies are configured. Please provide at least one cache strategy."
|
|
4493
4569
|
);
|
|
@@ -4497,12 +4573,12 @@ var init_cache_utils = __esm({
|
|
|
4497
4573
|
TOKENS5.CACHE_KEY_BUILDER,
|
|
4498
4574
|
(c) => new CacheKeyBuilder(c.resolve(TOKENS5.IDENTITY_ACCESSOR))
|
|
4499
4575
|
);
|
|
4500
|
-
if (opts.inMemory || !
|
|
4576
|
+
if (opts.inMemory || !Guards51.isDefined(opts.redis)) {
|
|
4501
4577
|
const { InMemoryCacheExtended: InMemoryCacheExtended2 } = await Promise.resolve().then(() => (init_inmemory_cache(), inmemory_cache_exports));
|
|
4502
4578
|
container.addSingleton(TOKENS5.CACHE, () => new InMemoryCacheExtended2());
|
|
4503
4579
|
return;
|
|
4504
4580
|
}
|
|
4505
|
-
if (
|
|
4581
|
+
if (Guards51.isDefined(opts.redis)) {
|
|
4506
4582
|
const { RedisCacheFactory: RedisCacheFactory2 } = await Promise.resolve().then(() => (init_redis_cache_factory(), redis_cache_factory_exports));
|
|
4507
4583
|
container.addSingleton(TOKENS5.CACHE, () => {
|
|
4508
4584
|
const config = opts.redis;
|
|
@@ -4519,7 +4595,7 @@ var console_logger_exports = {};
|
|
|
4519
4595
|
__export(console_logger_exports, {
|
|
4520
4596
|
ConsoleLogger: () => ConsoleLogger
|
|
4521
4597
|
});
|
|
4522
|
-
import { Guards as
|
|
4598
|
+
import { Guards as Guards47, LOG_LEVEL as LOG_LEVEL5 } from "@xeno-js/shared";
|
|
4523
4599
|
var ConsoleLogger;
|
|
4524
4600
|
var init_console_logger = __esm({
|
|
4525
4601
|
"src/infrastructure/loggers/console.logger.ts"() {
|
|
@@ -4542,7 +4618,7 @@ var init_console_logger = __esm({
|
|
|
4542
4618
|
track(level, message, context, error = void 0) {
|
|
4543
4619
|
if (level < this._minLevel) return;
|
|
4544
4620
|
const logMessage = `[${level}] ${message}`;
|
|
4545
|
-
const payload =
|
|
4621
|
+
const payload = Guards47.isDefined(error) ? { ...context, error } : context;
|
|
4546
4622
|
switch (level) {
|
|
4547
4623
|
case LOG_LEVEL5.ERROR:
|
|
4548
4624
|
console.error(logMessage, payload ?? {});
|
|
@@ -4586,24 +4662,24 @@ var init_logger_utils = __esm({
|
|
|
4586
4662
|
*/
|
|
4587
4663
|
async addLogger(container, opts) {
|
|
4588
4664
|
const loggerDependencies = [];
|
|
4589
|
-
const { Guards:
|
|
4590
|
-
if (!
|
|
4665
|
+
const { Guards: Guards51, LOG_LEVEL: LOG_LEVEL7, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
4666
|
+
if (!Guards51.isDefined(opts) || opts.console) {
|
|
4591
4667
|
const { ConsoleLogger: ConsoleLogger2 } = await Promise.resolve().then(() => (init_console_logger(), console_logger_exports));
|
|
4592
4668
|
loggerDependencies.push(new ConsoleLogger2(opts?.level));
|
|
4593
4669
|
}
|
|
4594
|
-
if (
|
|
4595
|
-
if (
|
|
4670
|
+
if (Guards51.isDefined(opts)) {
|
|
4671
|
+
if (Guards51.isDefined(opts.sentry.config)) {
|
|
4596
4672
|
const { SentryLoggerFactory: SentryLoggerFactory2 } = await Promise.resolve().then(() => (init_sentry_logger_factory(), sentry_logger_factory_exports));
|
|
4597
4673
|
loggerDependencies.push(new SentryLoggerFactory2().create(opts));
|
|
4598
4674
|
}
|
|
4599
|
-
if (
|
|
4675
|
+
if (Guards51.isDefined(opts.pino.config)) {
|
|
4600
4676
|
const { PinoLoggerFactory: PinoLoggerFactory2 } = await Promise.resolve().then(() => (init_pino_logger_factory(), pino_logger_factory_exports));
|
|
4601
4677
|
loggerDependencies.push(new PinoLoggerFactory2().create(opts));
|
|
4602
4678
|
}
|
|
4603
|
-
if (!
|
|
4679
|
+
if (!Guards51.isNullOrEmpty(opts.customLoggers)) {
|
|
4604
4680
|
const customLoggers = opts.customLoggers;
|
|
4605
4681
|
customLoggers.forEach((fn) => {
|
|
4606
|
-
if (
|
|
4682
|
+
if (Guards51.isDefined(fn)) loggerDependencies.push(fn(container));
|
|
4607
4683
|
});
|
|
4608
4684
|
}
|
|
4609
4685
|
}
|
|
@@ -4680,7 +4756,7 @@ __export(index_exports, {
|
|
|
4680
4756
|
init_application();
|
|
4681
4757
|
|
|
4682
4758
|
// src/infrastructure/builder/app.builder.ts
|
|
4683
|
-
import { Guards as
|
|
4759
|
+
import { Guards as Guards48, LOG_LEVEL as LOG_LEVEL6, TOKENS as TOKENS4 } from "@xeno-js/shared";
|
|
4684
4760
|
|
|
4685
4761
|
// src/infrastructure/configuration/configuration.ts
|
|
4686
4762
|
import { Guards as Guards13 } from "@xeno-js/shared";
|
|
@@ -5118,7 +5194,7 @@ var AppBuilder = class {
|
|
|
5118
5194
|
* @link https://github.com/xeno-js/xeno-js
|
|
5119
5195
|
*/
|
|
5120
5196
|
addLogger(setupAction) {
|
|
5121
|
-
if (
|
|
5197
|
+
if (Guards48.isDefined(setupAction)) setupAction(this._loggerConfig, this._configuration);
|
|
5122
5198
|
if (this._isLoggerModuleQueued) return this;
|
|
5123
5199
|
this._isLoggerModuleQueued = true;
|
|
5124
5200
|
this._modules.push({
|
|
@@ -5143,7 +5219,7 @@ var AppBuilder = class {
|
|
|
5143
5219
|
* @link https://github.com/xeno-js/xeno-js
|
|
5144
5220
|
*/
|
|
5145
5221
|
addCache(setupAction) {
|
|
5146
|
-
if (
|
|
5222
|
+
if (Guards48.isDefined(setupAction)) setupAction(this._config, this._configuration);
|
|
5147
5223
|
if (this._isCacheModuleQueued) return this;
|
|
5148
5224
|
this._isCacheModuleQueued = true;
|
|
5149
5225
|
this._modules.push({
|
|
@@ -5246,7 +5322,7 @@ var AppBuilder = class {
|
|
|
5246
5322
|
* @link https://github.com/xeno-js/xeno-js
|
|
5247
5323
|
*/
|
|
5248
5324
|
addPipeline(setupAction) {
|
|
5249
|
-
if (
|
|
5325
|
+
if (Guards48.isDefined(setupAction)) {
|
|
5250
5326
|
setupAction(this._pipelineConfig, this._configuration);
|
|
5251
5327
|
}
|
|
5252
5328
|
this._queuePipelineModule();
|
|
@@ -5367,7 +5443,7 @@ var AppBuilder = class {
|
|
|
5367
5443
|
console.error(`\u{1F449} Module: **${queued.name}**`);
|
|
5368
5444
|
console.error(`\u{1F4DD} Reason: ${errorMessage}
|
|
5369
5445
|
`);
|
|
5370
|
-
if (error instanceof Error &&
|
|
5446
|
+
if (error instanceof Error && Guards48.isDefined(error.stack)) {
|
|
5371
5447
|
console.error(error.stack);
|
|
5372
5448
|
}
|
|
5373
5449
|
throw new Error(`Bootstrap failed at [${queued.name}]: ${errorMessage}`, { cause: error });
|
|
@@ -5511,7 +5587,7 @@ init_modules();
|
|
|
5511
5587
|
|
|
5512
5588
|
// src/infrastructure/repositories/read-dao.ts
|
|
5513
5589
|
import { AppError as AppError16, Result as Result17 } from "@xeno-js/shared";
|
|
5514
|
-
import { Guards as
|
|
5590
|
+
import { Guards as Guards49 } from "@xeno-js/shared";
|
|
5515
5591
|
var ReadDao = class {
|
|
5516
5592
|
/**
|
|
5517
5593
|
* Constructs a new ReadDao instance.
|
|
@@ -5533,7 +5609,7 @@ var ReadDao = class {
|
|
|
5533
5609
|
async findById(id, ctx, signal) {
|
|
5534
5610
|
AppError16.throwIfAborted(signal, "ReadDao.findById");
|
|
5535
5611
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5536
|
-
if (
|
|
5612
|
+
if (Guards49.isNullOrEmpty(result)) return Result17.ok();
|
|
5537
5613
|
const entity = this._mapper.toEntity(result);
|
|
5538
5614
|
return Result17.ok(entity);
|
|
5539
5615
|
}
|
|
@@ -5547,7 +5623,7 @@ var ReadDao = class {
|
|
|
5547
5623
|
|
|
5548
5624
|
// src/infrastructure/repositories/repository.ts
|
|
5549
5625
|
import { AppError as AppError17, Result as Result18 } from "@xeno-js/shared";
|
|
5550
|
-
import { Guards as
|
|
5626
|
+
import { Guards as Guards50 } from "@xeno-js/shared";
|
|
5551
5627
|
var Repository = class {
|
|
5552
5628
|
/**
|
|
5553
5629
|
* Constructs a new Repository instance.
|
|
@@ -5569,7 +5645,7 @@ var Repository = class {
|
|
|
5569
5645
|
async findById(id, ctx, signal) {
|
|
5570
5646
|
AppError17.throwIfAborted(signal, "Repository.findById");
|
|
5571
5647
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5572
|
-
if (
|
|
5648
|
+
if (Guards50.isNullOrEmpty(result)) return Result18.ok();
|
|
5573
5649
|
const entity = this._mapper.toEntity(result);
|
|
5574
5650
|
return Result18.ok(entity);
|
|
5575
5651
|
}
|