rez_core 2.1.129 → 2.1.130
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/module/meta/service/entity-service-impl.service.js +9 -0
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/entity-validation.service.js +6 -2
- package/dist/module/meta/service/entity-validation.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/meta/service/entity-service-impl.service.ts +15 -0
- package/src/module/meta/service/entity-validation.service.ts +9 -3
package/package.json
CHANGED
|
@@ -248,6 +248,21 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
248
248
|
loggedInUser,
|
|
249
249
|
);
|
|
250
250
|
|
|
251
|
+
const validationErrors =
|
|
252
|
+
await this.entityValidationService.validateEntityData(
|
|
253
|
+
entityData,
|
|
254
|
+
entityMaster,
|
|
255
|
+
loggedInUser,
|
|
256
|
+
);
|
|
257
|
+
console.log('Validation Errors For Update:', validationErrors); // Debug log
|
|
258
|
+
if (validationErrors && validationErrors.length > 0) {
|
|
259
|
+
return {
|
|
260
|
+
success: false,
|
|
261
|
+
message: 'Validation failed',
|
|
262
|
+
errors: validationErrors,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
251
266
|
const repoService = this.reflectionHelper.getRepoService(
|
|
252
267
|
entityMaster.entity_data_class,
|
|
253
268
|
);
|
|
@@ -52,6 +52,7 @@ export class EntityValidationService {
|
|
|
52
52
|
loggedInUser: any,
|
|
53
53
|
): Promise<ValidationError[]> {
|
|
54
54
|
const errors: ValidationError[] = [];
|
|
55
|
+
const currentId = entityData.id; // assuming 'id' is the primary key
|
|
55
56
|
|
|
56
57
|
for (const attr of attributeData.filter((a) => a.is_unique)) {
|
|
57
58
|
const value = entityData[attr.attribute_key];
|
|
@@ -63,7 +64,7 @@ export class EntityValidationService {
|
|
|
63
64
|
.from(db_table_name, db_table_name)
|
|
64
65
|
.where(`${db_table_name}.${attr.attribute_key} = :value`, { value });
|
|
65
66
|
|
|
66
|
-
// Add AND condition for organization_id if present
|
|
67
|
+
// Add AND condition for organization_id/level_type/level_id if present
|
|
67
68
|
const orgId = loggedInUser.organization_id;
|
|
68
69
|
const level_type = loggedInUser.level_type;
|
|
69
70
|
const level_id = loggedInUser.level_id;
|
|
@@ -73,12 +74,17 @@ export class EntityValidationService {
|
|
|
73
74
|
`${db_table_name}.organization_id = :organization_id AND ${db_table_name}.level_type = :level_type AND ${db_table_name}.level_id = :level_id`,
|
|
74
75
|
{
|
|
75
76
|
organization_id: orgId,
|
|
76
|
-
level_type
|
|
77
|
-
level_id
|
|
77
|
+
level_type,
|
|
78
|
+
level_id,
|
|
78
79
|
},
|
|
79
80
|
);
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
// Skip the current record when checking for uniqueness during update
|
|
84
|
+
if (currentId) {
|
|
85
|
+
qb = qb.andWhere(`${db_table_name}.id != :id`, { id: currentId });
|
|
86
|
+
}
|
|
87
|
+
|
|
82
88
|
const existing = await qb.limit(1).getRawOne();
|
|
83
89
|
|
|
84
90
|
if (existing) {
|