@punks/backend-entity-manager 0.0.224 → 0.0.225

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/cjs/index.js CHANGED
@@ -376,7 +376,9 @@ class EntityCreateAction {
376
376
  async execute(input) {
377
377
  this.logger.debug("Create action started", { input });
378
378
  const converter = this.services.resolveConverter();
379
- const createInput = converter?.createDtoToEntity(input) ?? input;
379
+ const context = await this.getContext();
380
+ const createInput = converter?.createDtoToEntity(input, context) ??
381
+ input;
380
382
  const ref = await this.services
381
383
  .resolveCreateCommand()
382
384
  .execute(createInput);
@@ -390,6 +392,14 @@ class EntityCreateAction {
390
392
  this.logger.debug("Create action completed", { input, result });
391
393
  return result;
392
394
  }
395
+ async getContext() {
396
+ const authorization = this.services.resolveAuthorizationMiddleware();
397
+ if (!authorization) {
398
+ return;
399
+ }
400
+ const contextService = this.services.resolveAuthenticationContextProvider();
401
+ return await contextService?.getContext();
402
+ }
393
403
  }
394
404
 
395
405
  class EntityDeleteAction {
@@ -505,7 +515,9 @@ class EntityUpdateAction {
505
515
  async execute(id, input) {
506
516
  this.logger.debug("Update action started", { id, input });
507
517
  const converter = this.services.resolveConverter();
508
- const updateInput = converter?.updateDtoToEntity(input) ?? input;
518
+ const context = await this.getContext();
519
+ const updateInput = converter?.updateDtoToEntity(input, context) ??
520
+ input;
509
521
  await this.services
510
522
  .resolveUpdateCommand()
511
523
  .execute(id, updateInput);
@@ -517,6 +529,14 @@ class EntityUpdateAction {
517
529
  this.logger.debug("Update action started", { id, input, result });
518
530
  return result;
519
531
  }
532
+ async getContext() {
533
+ const authorization = this.services.resolveAuthorizationMiddleware();
534
+ if (!authorization) {
535
+ return;
536
+ }
537
+ const contextService = this.services.resolveAuthenticationContextProvider();
538
+ return await contextService?.getContext();
539
+ }
520
540
  }
521
541
 
522
542
  class EntityUpsertAction {
@@ -527,7 +547,9 @@ class EntityUpsertAction {
527
547
  async execute(id, input) {
528
548
  this.logger.debug("Upsert action started", { id, input });
529
549
  const converter = this.services.resolveConverter();
530
- const updateInput = converter?.updateDtoToEntity(input) ?? input;
550
+ const context = await this.getContext();
551
+ const updateInput = converter?.updateDtoToEntity(input, context) ??
552
+ input;
531
553
  await this.services
532
554
  .resolveUpsertCommand()
533
555
  .execute(id, updateInput);
@@ -539,6 +561,14 @@ class EntityUpsertAction {
539
561
  this.logger.debug("Upsert action started", { id, input, result });
540
562
  return result;
541
563
  }
564
+ async getContext() {
565
+ const authorization = this.services.resolveAuthorizationMiddleware();
566
+ if (!authorization) {
567
+ return;
568
+ }
569
+ const contextService = this.services.resolveAuthenticationContextProvider();
570
+ return await contextService?.getContext();
571
+ }
542
572
  }
543
573
 
544
574
  class EntityVersionsSearchAction {