@punks/backend-entity-manager 0.0.79 → 0.0.81
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 +30 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/errors.d.ts +3 -0
- package/dist/esm/index.js +31 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/errors.d.ts +3 -0
- package/dist/index.d.ts +4 -1
- package/package.json +4 -3
package/dist/cjs/index.js
CHANGED
|
@@ -75,6 +75,12 @@ class EntityManagerConfigurationError extends EntityManagerException {
|
|
|
75
75
|
this.name = "EntityManagerConfigurationError";
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
class MissingEntityIdError extends EntityManagerException {
|
|
79
|
+
constructor() {
|
|
80
|
+
super("Missing entity id");
|
|
81
|
+
this.name = "MissingEntityIdError";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
78
84
|
|
|
79
85
|
exports.ReplicationMode = void 0;
|
|
80
86
|
(function (ReplicationMode) {
|
|
@@ -269,11 +275,11 @@ __decorate([
|
|
|
269
275
|
__metadata("design:type", Number)
|
|
270
276
|
], NumericFacetItem.prototype, "value", void 0);
|
|
271
277
|
__decorate([
|
|
272
|
-
swagger.ApiProperty({
|
|
278
|
+
swagger.ApiProperty({ required: false }),
|
|
273
279
|
__metadata("design:type", String)
|
|
274
280
|
], NumericFacetItem.prototype, "name", void 0);
|
|
275
281
|
__decorate([
|
|
276
|
-
swagger.ApiProperty({
|
|
282
|
+
swagger.ApiProperty({ required: false }),
|
|
277
283
|
__metadata("design:type", Number)
|
|
278
284
|
], NumericFacetItem.prototype, "count", void 0);
|
|
279
285
|
class NumericFacet {
|
|
@@ -289,11 +295,11 @@ __decorate([
|
|
|
289
295
|
__metadata("design:type", Boolean)
|
|
290
296
|
], BooleanFacetItem.prototype, "value", void 0);
|
|
291
297
|
__decorate([
|
|
292
|
-
swagger.ApiProperty({
|
|
298
|
+
swagger.ApiProperty({ required: false }),
|
|
293
299
|
__metadata("design:type", String)
|
|
294
300
|
], BooleanFacetItem.prototype, "name", void 0);
|
|
295
301
|
__decorate([
|
|
296
|
-
swagger.ApiProperty({
|
|
302
|
+
swagger.ApiProperty({ required: false }),
|
|
297
303
|
__metadata("design:type", Number)
|
|
298
304
|
], BooleanFacetItem.prototype, "count", void 0);
|
|
299
305
|
class BooleanFacet {
|
|
@@ -309,11 +315,11 @@ __decorate([
|
|
|
309
315
|
__metadata("design:type", String)
|
|
310
316
|
], StringFacetItem.prototype, "value", void 0);
|
|
311
317
|
__decorate([
|
|
312
|
-
swagger.ApiProperty({
|
|
318
|
+
swagger.ApiProperty({ required: false }),
|
|
313
319
|
__metadata("design:type", String)
|
|
314
320
|
], StringFacetItem.prototype, "name", void 0);
|
|
315
321
|
__decorate([
|
|
316
|
-
swagger.ApiProperty({
|
|
322
|
+
swagger.ApiProperty({ required: false }),
|
|
317
323
|
__metadata("design:type", Number)
|
|
318
324
|
], StringFacetItem.prototype, "count", void 0);
|
|
319
325
|
class StringFacet {
|
|
@@ -633,6 +639,9 @@ class EntityDeleteCommand {
|
|
|
633
639
|
this.services = services;
|
|
634
640
|
}
|
|
635
641
|
async execute(id) {
|
|
642
|
+
if (backendCore.isNullOrUndefined(id)) {
|
|
643
|
+
throw new MissingEntityIdError();
|
|
644
|
+
}
|
|
636
645
|
await this.authorize(id);
|
|
637
646
|
await this.services.resolveRepository().delete(id);
|
|
638
647
|
await this.services.resolveEventsManager().processEntityDeletedEvent(id);
|
|
@@ -20404,7 +20413,9 @@ exports.EntityManagerInitializer = EntityManagerInitializer_1 = class EntityMana
|
|
|
20404
20413
|
const converterDict = backendCore.toDict(converters, (c) => c.meta.entityName);
|
|
20405
20414
|
const adapterDict = backendCore.toDict(adapters, (a) => a.meta.entityName);
|
|
20406
20415
|
const authDict = backendCore.toDict(auth, (a) => a.meta.entityName);
|
|
20407
|
-
|
|
20416
|
+
const sortedRepositories = lodash.exports.orderBy(repositories, (x) => x.meta.entityName);
|
|
20417
|
+
this.logger.log(`Discovered repositories: \n${sortedRepositories.join(" \n")}`);
|
|
20418
|
+
for (const repository of sortedRepositories) {
|
|
20408
20419
|
const entityName = repository.meta.entityName;
|
|
20409
20420
|
const queryBuilder = queryBuilderDict[entityName];
|
|
20410
20421
|
if (!queryBuilder) {
|
|
@@ -21017,7 +21028,7 @@ class TypeOrmRepository {
|
|
|
21017
21028
|
return this.innerRepository;
|
|
21018
21029
|
}
|
|
21019
21030
|
async exists(id) {
|
|
21020
|
-
if (
|
|
21031
|
+
if (backendCore.isNullOrUndefined(id)) {
|
|
21021
21032
|
throw new Error("Invalid 'id' parameter.");
|
|
21022
21033
|
}
|
|
21023
21034
|
return await this.innerRepository.exist({
|
|
@@ -21030,7 +21041,7 @@ class TypeOrmRepository {
|
|
|
21030
21041
|
return await this.innerRepository.exist(condition);
|
|
21031
21042
|
}
|
|
21032
21043
|
async get(id) {
|
|
21033
|
-
if (
|
|
21044
|
+
if (backendCore.isNullOrUndefined(id)) {
|
|
21034
21045
|
throw new Error("Invalid 'id' parameter.");
|
|
21035
21046
|
}
|
|
21036
21047
|
const result = await this.innerRepository.findOne({
|
|
@@ -21059,6 +21070,9 @@ class TypeOrmRepository {
|
|
|
21059
21070
|
});
|
|
21060
21071
|
}
|
|
21061
21072
|
async delete(id) {
|
|
21073
|
+
if (backendCore.isNullOrUndefined(id)) {
|
|
21074
|
+
throw new Error("Invalid 'id' parameter.");
|
|
21075
|
+
}
|
|
21062
21076
|
await this.innerRepository.delete({
|
|
21063
21077
|
id: id,
|
|
21064
21078
|
});
|
|
@@ -21078,6 +21092,9 @@ class TypeOrmRepository {
|
|
|
21078
21092
|
return current;
|
|
21079
21093
|
}
|
|
21080
21094
|
async update(id, entity) {
|
|
21095
|
+
if (backendCore.isNullOrUndefined(id)) {
|
|
21096
|
+
throw new Error("Invalid 'id' parameter.");
|
|
21097
|
+
}
|
|
21081
21098
|
await this.innerRepository.update(id, entity);
|
|
21082
21099
|
const current = await this.get(id);
|
|
21083
21100
|
if (!current) {
|
|
@@ -21090,6 +21107,9 @@ class TypeOrmRepository {
|
|
|
21090
21107
|
return await this.findById(updateResult.generatedMaps.map((x) => x.id));
|
|
21091
21108
|
}
|
|
21092
21109
|
async upsert(id, entity) {
|
|
21110
|
+
if (backendCore.isNullOrUndefined(id)) {
|
|
21111
|
+
throw new Error("Invalid 'id' parameter.");
|
|
21112
|
+
}
|
|
21093
21113
|
if (await this.exists(id)) {
|
|
21094
21114
|
return await this.update(id, entity);
|
|
21095
21115
|
}
|
|
@@ -26572,6 +26592,7 @@ exports.EntityOperationUnauthorizedException = EntityOperationUnauthorizedExcept
|
|
|
26572
26592
|
exports.EntitySeeder = EntitySeeder;
|
|
26573
26593
|
exports.InvalidCredentialsError = InvalidCredentialsError;
|
|
26574
26594
|
exports.MemberOf = MemberOf;
|
|
26595
|
+
exports.MissingEntityIdError = MissingEntityIdError;
|
|
26575
26596
|
exports.MultipleEntitiesFoundException = MultipleEntitiesFoundException;
|
|
26576
26597
|
exports.NestEntityActions = NestEntityActions;
|
|
26577
26598
|
exports.NestEntityAuthorizationMiddleware = NestEntityAuthorizationMiddleware;
|