@punks/backend-entity-manager 0.0.342 → 0.0.345
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 +7 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/converters.d.ts +4 -4
- package/dist/esm/index.js +8 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/converters.d.ts +4 -4
- package/dist/index.d.ts +4 -4
- package/package.json +2 -2
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { DeepPartial } from "../types";
|
|
2
2
|
import { IAuthenticationContext } from "./authentication";
|
|
3
3
|
export interface IEntitiesSearchActionConverter<TEntity, TListItemDto> {
|
|
4
|
-
toListItemDto(entity: TEntity): TListItemDto
|
|
4
|
+
toListItemDto(entity: TEntity): TListItemDto | Promise<TListItemDto>;
|
|
5
5
|
}
|
|
6
6
|
export interface IEntityGetActionConverter<TEntity, TEntityDto> {
|
|
7
|
-
toEntityDto(entity: TEntity): TEntityDto
|
|
7
|
+
toEntityDto(entity: TEntity): TEntityDto | Promise<TEntityDto>;
|
|
8
8
|
}
|
|
9
9
|
export interface IEntityCreateActionConverter<TEntity, TEntityDto, TEntityCreateDto> {
|
|
10
10
|
createDtoToEntity(data: TEntityCreateDto, context?: IAuthenticationContext<unknown>): DeepPartial<TEntity>;
|
|
11
|
-
toEntityDto(entity: TEntity): TEntityDto
|
|
11
|
+
toEntityDto(entity: TEntity): TEntityDto | Promise<TEntityDto>;
|
|
12
12
|
}
|
|
13
13
|
export interface IEntityUpdateActionConverter<TEntity, TEntityDto, TEntityUpdateDto> {
|
|
14
|
-
toEntityDto(entity: TEntity): TEntityDto
|
|
14
|
+
toEntityDto(entity: TEntity): TEntityDto | Promise<TEntityDto>;
|
|
15
15
|
updateDtoToEntity(data: TEntityUpdateDto, context?: IAuthenticationContext<unknown>): DeepPartial<TEntity>;
|
|
16
16
|
}
|
|
17
17
|
export interface IEntityConverter<TEntity, TEntityDto, TListItemDto, TEntityCreateDto, TEntityUpdateDto> extends IEntitiesSearchActionConverter<TEntity, TListItemDto>, IEntityGetActionConverter<TEntity, TEntityDto>, IEntityCreateActionConverter<TEntity, TEntityDto, TEntityCreateDto>, IEntityUpdateActionConverter<TEntity, TEntityDto, TEntityUpdateDto> {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Log, csvParse, excelParse, excelBuild, csvBuild, isNullOrUndefined, addTime, newUuid as newUuid$1, buildObject, toDict, sleep, sort, byField, toArrayDict, toItemsDict, ensureTailingSlash, ensureStartSlash, removeUndefinedProps } from '@punks/backend-core';
|
|
1
|
+
import { Log, csvParse, excelParse, excelBuild, csvBuild, mapAsync, isNullOrUndefined, addTime, newUuid as newUuid$1, buildObject, toDict, sleep, sort, byField, toArrayDict, toItemsDict, ensureTailingSlash, ensureStartSlash, removeUndefinedProps } from '@punks/backend-core';
|
|
2
2
|
import { QueryCommand, ScanCommand, GetItemCommand, PutItemCommand, DeleteItemCommand, DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
3
3
|
import { unmarshall, marshall } from '@aws-sdk/util-dynamodb';
|
|
4
4
|
import { Module, applyDecorators, Injectable, SetMetadata, createParamDecorator, Global, Scope, Inject, Logger, StreamableFile, HttpException, HttpStatus } from '@nestjs/common';
|
|
@@ -398,7 +398,7 @@ class EntityCreateAction {
|
|
|
398
398
|
if (!entity) {
|
|
399
399
|
throw new Error(`Newly created entity not found with id ${ref.id}`);
|
|
400
400
|
}
|
|
401
|
-
const result = converter?.toEntityDto(entity) ?? entity;
|
|
401
|
+
const result = (await converter?.toEntityDto(entity)) ?? entity;
|
|
402
402
|
this.logger.debug("Create action completed", { input, result });
|
|
403
403
|
return result;
|
|
404
404
|
}
|
|
@@ -466,7 +466,7 @@ class EntityGetAction {
|
|
|
466
466
|
const entity = await this.services.resolveGetQuery().execute(id);
|
|
467
467
|
const converter = this.services.resolveConverter();
|
|
468
468
|
return entity
|
|
469
|
-
? converter?.toEntityDto(entity) ?? entity
|
|
469
|
+
? (await converter?.toEntityDto(entity)) ?? entity
|
|
470
470
|
: undefined;
|
|
471
471
|
}
|
|
472
472
|
}
|
|
@@ -508,7 +508,7 @@ class EntitiesSearchAction {
|
|
|
508
508
|
const results = await searchQuery.execute(request);
|
|
509
509
|
const converter = this.services.resolveConverter();
|
|
510
510
|
return {
|
|
511
|
-
items: results.items
|
|
511
|
+
items: await mapAsync(results.items, async (x) => ((await converter?.toListItemDto(x)) ?? x)),
|
|
512
512
|
paging: results.paging,
|
|
513
513
|
childrenMap: results.childrenMap,
|
|
514
514
|
facets: results.facets,
|
|
@@ -535,7 +535,7 @@ class EntityUpdateAction {
|
|
|
535
535
|
if (!entity) {
|
|
536
536
|
throw new Error(`Newly created entity not found with id ${id}`);
|
|
537
537
|
}
|
|
538
|
-
const result = converter?.toEntityDto(entity) ?? entity;
|
|
538
|
+
const result = (await converter?.toEntityDto(entity)) ?? entity;
|
|
539
539
|
this.logger.debug("Update action started", { id, input, result });
|
|
540
540
|
return result;
|
|
541
541
|
}
|
|
@@ -567,7 +567,7 @@ class EntityUpsertAction {
|
|
|
567
567
|
if (!entity) {
|
|
568
568
|
throw new Error(`Newly created entity not found with id ${id}`);
|
|
569
569
|
}
|
|
570
|
-
const result = converter?.toEntityDto(entity) ?? entity;
|
|
570
|
+
const result = (await converter?.toEntityDto(entity)) ?? entity;
|
|
571
571
|
this.logger.debug("Upsert action started", { id, input, result });
|
|
572
572
|
return result;
|
|
573
573
|
}
|
|
@@ -22420,7 +22420,8 @@ let EmailService = class EmailService {
|
|
|
22420
22420
|
}
|
|
22421
22421
|
async sendTemplatedEmail(input) {
|
|
22422
22422
|
const template = this.getTemplate(input.templateId);
|
|
22423
|
-
const transformedPayload = this.templateMiddleware?.processPayload(input.payload) ??
|
|
22423
|
+
const transformedPayload = (await this.templateMiddleware?.processPayload(input.payload)) ??
|
|
22424
|
+
input.payload;
|
|
22424
22425
|
const sendInput = {
|
|
22425
22426
|
...input,
|
|
22426
22427
|
payload: transformedPayload,
|