rez_core 1.0.99 → 1.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "1.0.99",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -100,11 +100,11 @@ export class FilterService {
100
100
  // Get and parse filters
101
101
  const savedFilters = await this.getSavedFilters(savedFilterCode);
102
102
  const baseFilters = [
103
- ...(quickFilter || []).filter(f => f.filter_value !== ""),
104
- ...savedFilters.filter(f => f.filter_value !== ""),
105
- ...(attributeFilter || []).filter(f => f.filter_value !== ""),
103
+ ...(quickFilter || []).filter((f) => f.filter_value !== ''),
104
+ ...savedFilters.filter((f) => f.filter_value !== ''),
105
+ ...(attributeFilter || []).filter((f) => f.filter_value !== ''),
106
106
  ];
107
-
107
+
108
108
  const baseWhere = this.buildWhereClauses(baseFilters, attributeMetaMap);
109
109
 
110
110
  // Build query for tab counts (no tab.value filter here)
@@ -229,7 +229,7 @@ export class FilterService {
229
229
  case 'select':
230
230
  return this.buildSelectCondition(attr, op, val, key);
231
231
  case 'multiselect':
232
- return this.buildMultiSelectCondition(attr, val, key);
232
+ return this.buildMultiSelectCondition(attr, op, val, key);
233
233
  default:
234
234
  return null;
235
235
  }
@@ -310,18 +310,56 @@ export class FilterService {
310
310
  case 'equal':
311
311
  return { query: `e.${attr} = :${key}`, params: { [key]: val } };
312
312
 
313
+ case 'not_equal':
314
+ return { query: `e.${attr} != :${key}`, params: { [key]: val } };
315
+
316
+ case 'empty':
317
+ return { query: `e.${attr} IS NULL`, params: {} };
318
+
319
+ case 'not_empty':
320
+ return { query: `e.${attr} IS NOT NULL`, params: {} };
321
+
313
322
  default:
314
323
  throw new BadRequestException(`Unsupported operator for select: ${op}`);
315
324
  }
316
325
  }
317
326
 
318
- private buildMultiSelectCondition(attr: string, val: any[], key: string) {
319
- if (!Array.isArray(val)) {
320
- throw new BadRequestException(`Expected array for multiselect: ${attr}`);
327
+ private buildMultiSelectCondition(
328
+ attr: string,
329
+ op: string,
330
+ val: any,
331
+ key: string,
332
+ ) {
333
+ switch (op) {
334
+ case 'equal':
335
+ if (!Array.isArray(val)) {
336
+ throw new BadRequestException(
337
+ `Value for multi-select must be an array for operator: ${op}`,
338
+ );
339
+ }
340
+ return { query: `e.${attr} IN (:...${key})`, params: { [key]: val } };
341
+
342
+ case 'not_equal':
343
+ if (!Array.isArray(val)) {
344
+ throw new BadRequestException(
345
+ `Value for multi-select must be an array for operator: ${op}`,
346
+ );
347
+ }
348
+ return {
349
+ query: `e.${attr} NOT IN (:...${key})`,
350
+ params: { [key]: val },
351
+ };
352
+
353
+ case 'empty':
354
+ return { query: `e.${attr} IS NULL`, params: {} };
355
+
356
+ case 'not_empty':
357
+ return { query: `e.${attr} IS NOT NULL`, params: {} };
358
+
359
+ default:
360
+ throw new BadRequestException(
361
+ `Unsupported operator for multiselect: ${op}`,
362
+ );
321
363
  }
322
- return {
323
- query: `e.${attr} IN (:...${key})`,
324
- params: { [key]: val },
325
- };
326
364
  }
327
365
  }
@@ -257,17 +257,27 @@ export class MasterService {
257
257
  continue;
258
258
  }
259
259
 
260
+ const existingError = errors.find((e) => e.row === i + 1);
261
+
260
262
  if (refData[0].organization_id !== loggedInUser.organization_id) {
261
- errors.push({
262
- row: i + 1,
263
- errors: [
264
- {
265
- field: attr.name,
266
- message: `Reference entity with code ${row[attr.attribute_key]} does not belong to the organization`,
267
- },
268
- ],
269
- });
270
- continue;
263
+ if (existingError) {
264
+ existingError.errors.push({
265
+ field: attr.name,
266
+ message: `Reference entity not found for code: ${row[attr.attribute_key]} does not belong to the organization`,
267
+ });
268
+ continue;
269
+ } else {
270
+ errors.push({
271
+ row: i + 1,
272
+ errors: [
273
+ {
274
+ field: attr.name,
275
+ message: `Reference entity with code ${row[attr.attribute_key]} does not belong to the organization`,
276
+ },
277
+ ],
278
+ });
279
+ continue;
280
+ }
271
281
  }
272
282
 
273
283
  row[attr.attribute_key] = refData[0].id;
@@ -407,11 +417,17 @@ export class MasterService {
407
417
  entityMaster,
408
418
  );
409
419
 
420
+ const existingError = errors.find((e) => e.row === i + 1);
421
+
410
422
  if (rowErrors?.length > 0) {
411
- errors.push({
412
- row: i + 1,
413
- errors: rowErrors,
414
- });
423
+ if (existingError) {
424
+ existingError.errors.push(...rowErrors);
425
+ } else {
426
+ errors.push({
427
+ row: i + 1,
428
+ errors: rowErrors,
429
+ });
430
+ }
415
431
  }
416
432
  }
417
433
 
@@ -419,7 +435,7 @@ export class MasterService {
419
435
  throw new BadRequestException({
420
436
  status: false,
421
437
  message: `Validation errors found in the uploaded data.`,
422
- details: errors,
438
+ error: errors,
423
439
  });
424
440
  }
425
441