@punks/backend-entity-manager 0.0.460 → 0.0.462
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 +20 -12
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/actions.d.ts +8 -8
- package/dist/cjs/types/abstractions/manager.d.ts +1 -1
- package/dist/cjs/types/abstractions/queries.d.ts +10 -4
- package/dist/cjs/types/actions/get.d.ts +4 -3
- package/dist/cjs/types/actions/search.d.ts +2 -2
- package/dist/cjs/types/concrete/index.d.ts +2 -2
- package/dist/cjs/types/integrations/repository/typeorm/queryBuilder.d.ts +2 -1
- package/dist/cjs/types/providers/services/entities-locator.d.ts +4 -4
- package/dist/cjs/types/providers/services/entity-locator.d.ts +2 -2
- package/dist/cjs/types/queries/get.d.ts +4 -3
- package/dist/cjs/types/queries/search.d.ts +2 -2
- package/dist/esm/index.js +20 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/actions.d.ts +8 -8
- package/dist/esm/types/abstractions/manager.d.ts +1 -1
- package/dist/esm/types/abstractions/queries.d.ts +10 -4
- package/dist/esm/types/actions/get.d.ts +4 -3
- package/dist/esm/types/actions/search.d.ts +2 -2
- package/dist/esm/types/concrete/index.d.ts +2 -2
- package/dist/esm/types/integrations/repository/typeorm/queryBuilder.d.ts +2 -1
- package/dist/esm/types/providers/services/entities-locator.d.ts +4 -4
- package/dist/esm/types/providers/services/entity-locator.d.ts +2 -2
- package/dist/esm/types/queries/get.d.ts +4 -3
- package/dist/esm/types/queries/search.d.ts +2 -2
- package/dist/index.d.ts +170 -165
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -607,8 +607,8 @@ class EntityGetAction {
|
|
|
607
607
|
constructor(services) {
|
|
608
608
|
this.services = services;
|
|
609
609
|
}
|
|
610
|
-
async execute(id) {
|
|
611
|
-
const entity = await this.services.resolveGetQuery().execute(id);
|
|
610
|
+
async execute(id, options) {
|
|
611
|
+
const entity = await this.services.resolveGetQuery().execute(id, options);
|
|
612
612
|
const converter = this.services.resolveConverter();
|
|
613
613
|
return entity
|
|
614
614
|
? (await converter?.toEntityDto(entity)) ?? entity
|
|
@@ -661,9 +661,9 @@ class EntitiesSearchAction {
|
|
|
661
661
|
constructor(services) {
|
|
662
662
|
this.services = services;
|
|
663
663
|
}
|
|
664
|
-
async execute(request) {
|
|
664
|
+
async execute(request, options) {
|
|
665
665
|
const searchQuery = this.services.resolveSearchQuery();
|
|
666
|
-
const results = await searchQuery.execute(request);
|
|
666
|
+
const results = await searchQuery.execute(request, options);
|
|
667
667
|
const converter = this.services.resolveConverter();
|
|
668
668
|
return {
|
|
669
669
|
items: await backendCore.mapAsync(results.items, async (x) => ((await converter?.toListItemDto(x)) ?? x)),
|
|
@@ -689,7 +689,9 @@ class EntityUpdateAction {
|
|
|
689
689
|
await this.services
|
|
690
690
|
.resolveUpdateCommand()
|
|
691
691
|
.execute(id, updateInput);
|
|
692
|
-
const entity = await this.services
|
|
692
|
+
const entity = await this.services
|
|
693
|
+
.resolveGetQuery()
|
|
694
|
+
.execute(id);
|
|
693
695
|
if (!entity) {
|
|
694
696
|
throw new Error(`Newly created entity not found with id ${id}`);
|
|
695
697
|
}
|
|
@@ -721,7 +723,9 @@ class EntityUpsertAction {
|
|
|
721
723
|
await this.services
|
|
722
724
|
.resolveUpsertCommand()
|
|
723
725
|
.execute(id, updateInput);
|
|
724
|
-
const entity = await this.services
|
|
726
|
+
const entity = await this.services
|
|
727
|
+
.resolveGetQuery()
|
|
728
|
+
.execute(id);
|
|
725
729
|
if (!entity) {
|
|
726
730
|
throw new Error(`Newly created entity not found with id ${id}`);
|
|
727
731
|
}
|
|
@@ -2308,11 +2312,11 @@ class EntityGetQuery {
|
|
|
2308
2312
|
constructor(services) {
|
|
2309
2313
|
this.services = services;
|
|
2310
2314
|
}
|
|
2311
|
-
async execute(id) {
|
|
2315
|
+
async execute(id, options) {
|
|
2312
2316
|
const context = await this.getContext();
|
|
2313
2317
|
const entity = await this.services
|
|
2314
2318
|
.resolveQueryBuilder()
|
|
2315
|
-
.get(id, context);
|
|
2319
|
+
.get(id, context, options);
|
|
2316
2320
|
if (entity) {
|
|
2317
2321
|
await this.authorize(entity);
|
|
2318
2322
|
}
|
|
@@ -2346,11 +2350,14 @@ class EntitiesSearchQuery {
|
|
|
2346
2350
|
constructor(services) {
|
|
2347
2351
|
this.services = services;
|
|
2348
2352
|
}
|
|
2349
|
-
async execute(request) {
|
|
2353
|
+
async execute(request, options) {
|
|
2350
2354
|
const context = await this.getContext();
|
|
2351
2355
|
await this.authorizeSearch(context);
|
|
2352
2356
|
const queryBuilder = this.services.resolveQueryBuilder();
|
|
2353
|
-
const result = await queryBuilder.search(
|
|
2357
|
+
const result = await queryBuilder.search({
|
|
2358
|
+
...request,
|
|
2359
|
+
relations: options?.relations ?? request.relations,
|
|
2360
|
+
}, context);
|
|
2354
2361
|
const filteredEntities = await this.filterAllowedEntities(result.items, context);
|
|
2355
2362
|
return {
|
|
2356
2363
|
...result,
|
|
@@ -3830,9 +3837,10 @@ class TypeOrmQueryBuilder extends QueryBuilderBase {
|
|
|
3830
3837
|
this.clause = new QueryClauseBuilder();
|
|
3831
3838
|
this.permissions = new PermissionsChecker();
|
|
3832
3839
|
}
|
|
3833
|
-
async get(id, context) {
|
|
3840
|
+
async get(id, context, options) {
|
|
3834
3841
|
return await this.getRepository().get(id, {
|
|
3835
|
-
relations:
|
|
3842
|
+
relations: options?.relations ??
|
|
3843
|
+
this.getRelationsToLoad(undefined, context, exports.QueryBuilderOperation.Get),
|
|
3836
3844
|
});
|
|
3837
3845
|
}
|
|
3838
3846
|
async exists(filters, context) {
|