rez_core 2.2.128 → 2.2.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/master/controller/master.controller.d.ts +0 -4
- package/dist/module/master/service/master.service.d.ts +0 -4
- package/dist/module/master/service/master.service.js +6 -13
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/service/entity-validation.service.d.ts +1 -0
- package/dist/module/meta/service/entity-validation.service.js +7 -1
- 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/master/service/master.service.ts +7 -22
- package/src/module/meta/service/entity-validation.service.ts +16 -2
- package/.vscode/extensions.json +0 -5
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
2
|
import { Brackets, EntityManager } from 'typeorm';
|
|
3
3
|
import { ExcelUtil } from 'src/utils/service/excelUtil.service';
|
|
4
4
|
import { EntityMasterService } from '../../meta/service/entity-master.service';
|
|
@@ -220,7 +220,7 @@ export class MasterService {
|
|
|
220
220
|
|
|
221
221
|
const attributes =
|
|
222
222
|
await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
223
|
-
|
|
223
|
+
entityMaster.mapped_entity_type,
|
|
224
224
|
loggedInUser,
|
|
225
225
|
);
|
|
226
226
|
|
|
@@ -358,7 +358,7 @@ export class MasterService {
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
// ✅ validate single row
|
|
361
|
-
const rowErrors = await this.entityValidationService.
|
|
361
|
+
const rowErrors = await this.entityValidationService.validateImportData(
|
|
362
362
|
row,
|
|
363
363
|
entityMaster,
|
|
364
364
|
loggedInUser,
|
|
@@ -371,7 +371,10 @@ export class MasterService {
|
|
|
371
371
|
|
|
372
372
|
// ✅ if any row failed, return errors instead of inserting
|
|
373
373
|
if (errors.length > 0) {
|
|
374
|
-
|
|
374
|
+
throw new BadRequestException({
|
|
375
|
+
message: 'Validation errors found',
|
|
376
|
+
errors,
|
|
377
|
+
});
|
|
375
378
|
}
|
|
376
379
|
|
|
377
380
|
// ✅ only upsert if no validation errors
|
|
@@ -528,24 +531,6 @@ export class MasterService {
|
|
|
528
531
|
await entityService.updateEntity(row, loggedInUser);
|
|
529
532
|
}
|
|
530
533
|
} else {
|
|
531
|
-
const rowErrors = await this.entityValidationService.validateEntityData(
|
|
532
|
-
row,
|
|
533
|
-
entityMaster,
|
|
534
|
-
loggedInUser,
|
|
535
|
-
);
|
|
536
|
-
|
|
537
|
-
if (rowErrors && rowErrors.length > 0) {
|
|
538
|
-
errors.push({
|
|
539
|
-
row: i + 1,
|
|
540
|
-
errors: rowErrors,
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
if (errors.length > 0) {
|
|
545
|
-
throw new Error(
|
|
546
|
-
`Validation errors found in the uploaded data: ${JSON.stringify(errors)}`,
|
|
547
|
-
);
|
|
548
|
-
}
|
|
549
534
|
await entityService.createEntity(row, loggedInUser);
|
|
550
535
|
}
|
|
551
536
|
}
|
|
@@ -134,10 +134,9 @@ export class EntityValidationService {
|
|
|
134
134
|
): Promise<ValidationError[]> {
|
|
135
135
|
const attributes =
|
|
136
136
|
await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
137
|
-
|
|
137
|
+
entityMaster.mapped_entity_type,
|
|
138
138
|
loggedInUser,
|
|
139
139
|
);
|
|
140
|
-
|
|
141
140
|
const requiredErrors = this.validateRequiredFields(entityData, attributes);
|
|
142
141
|
const uniqueErrors = await this.validateUniqueFields(
|
|
143
142
|
entityData,
|
|
@@ -163,6 +162,21 @@ export class EntityValidationService {
|
|
|
163
162
|
// const regexErros = await this.validateRegexFields(entityData, attributes);
|
|
164
163
|
// return [...requiredErrors, ...regexErros];
|
|
165
164
|
// }
|
|
165
|
+
async validateImportData(
|
|
166
|
+
entityData: Record<string, any>,
|
|
167
|
+
entityMaster,
|
|
168
|
+
loggedInUser: any,
|
|
169
|
+
): Promise<ValidationError[]> {
|
|
170
|
+
const attributes =
|
|
171
|
+
await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
172
|
+
entityMaster.mapped_entity_type,
|
|
173
|
+
loggedInUser,
|
|
174
|
+
);
|
|
175
|
+
const requiredErrors = this.validateRequiredFields(entityData, attributes);
|
|
176
|
+
const regexErros = await this.validateRegexFields(entityData, attributes);
|
|
177
|
+
return [...requiredErrors, ...regexErros];
|
|
178
|
+
}
|
|
179
|
+
|
|
166
180
|
private hasValidValue(value: any): boolean {
|
|
167
181
|
if (value === null || value === undefined) return false;
|
|
168
182
|
if (typeof value === 'string' && value.trim() === '') return false;
|