av6-core 1.0.2 → 1.0.3
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/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +57 -40
- package/dist/index.mjs +57 -40
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -126,6 +126,8 @@ interface DropdownRequest {
|
|
|
126
126
|
shortCode: string;
|
|
127
127
|
searchColumns: string[];
|
|
128
128
|
searchText?: string;
|
|
129
|
+
fixedSearch?: Record<string, ColValue>;
|
|
130
|
+
fixedNotSearch?: Record<string, ColValue>;
|
|
129
131
|
}
|
|
130
132
|
interface DropdownRequestService<T extends DynamicShortCode> extends DropdownRequest {
|
|
131
133
|
shortCodeData: T;
|
|
@@ -280,4 +282,4 @@ interface CreateTransaction {
|
|
|
280
282
|
*/
|
|
281
283
|
declare function findDifferences<T extends Record<string, any>>(obj1: T, obj2: T): CreateTransaction[];
|
|
282
284
|
|
|
283
|
-
export { type CacheAdapter, type CalculationRes, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, type PaginatedResponse, type SearchRequest, type SearchRequestService, type Store, type ToggleActive, type UpdateStatusRequestRepository, type ValidationErrorItem, commonService, customOmit, findDifferences, getDynamicValue, getPattern, objectTo2DArray, toNumberOrNull, type updateStatusParams };
|
|
285
|
+
export { type CacheAdapter, type CalculationRes, type ColValue, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, type PaginatedResponse, type SearchRequest, type SearchRequestService, type Store, type ToggleActive, type UpdateStatusRequestRepository, type ValidationErrorItem, commonService, customOmit, findDifferences, getDynamicValue, getPattern, objectTo2DArray, toNumberOrNull, type updateStatusParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,8 @@ interface DropdownRequest {
|
|
|
126
126
|
shortCode: string;
|
|
127
127
|
searchColumns: string[];
|
|
128
128
|
searchText?: string;
|
|
129
|
+
fixedSearch?: Record<string, ColValue>;
|
|
130
|
+
fixedNotSearch?: Record<string, ColValue>;
|
|
129
131
|
}
|
|
130
132
|
interface DropdownRequestService<T extends DynamicShortCode> extends DropdownRequest {
|
|
131
133
|
shortCodeData: T;
|
|
@@ -280,4 +282,4 @@ interface CreateTransaction {
|
|
|
280
282
|
*/
|
|
281
283
|
declare function findDifferences<T extends Record<string, any>>(obj1: T, obj2: T): CreateTransaction[];
|
|
282
284
|
|
|
283
|
-
export { type CacheAdapter, type CalculationRes, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, type PaginatedResponse, type SearchRequest, type SearchRequestService, type Store, type ToggleActive, type UpdateStatusRequestRepository, type ValidationErrorItem, commonService, customOmit, findDifferences, getDynamicValue, getPattern, objectTo2DArray, toNumberOrNull, type updateStatusParams };
|
|
285
|
+
export { type CacheAdapter, type CalculationRes, type ColValue, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, type PaginatedResponse, type SearchRequest, type SearchRequestService, type Store, type ToggleActive, type UpdateStatusRequestRepository, type ValidationErrorItem, commonService, customOmit, findDifferences, getDynamicValue, getPattern, objectTo2DArray, toNumberOrNull, type updateStatusParams };
|
package/dist/index.js
CHANGED
|
@@ -322,10 +322,17 @@ var commonRepository = (serviceDeps) => {
|
|
|
322
322
|
async commonDropdownSearch({
|
|
323
323
|
searchText,
|
|
324
324
|
searchColumns,
|
|
325
|
-
shortCodeData
|
|
325
|
+
shortCodeData,
|
|
326
|
+
fixedSearch,
|
|
327
|
+
fixedNotSearch
|
|
326
328
|
}) {
|
|
327
329
|
logger.info("entering::commonSearch::repository");
|
|
328
330
|
const tableName = shortCodeData.tableName;
|
|
331
|
+
const rootCondition = await this.generateRootCondition({
|
|
332
|
+
fixedSearch,
|
|
333
|
+
fixedNotSearch
|
|
334
|
+
});
|
|
335
|
+
const customWhereClause = { ...rootCondition };
|
|
329
336
|
const whereClause = {};
|
|
330
337
|
if (searchText && searchColumns.length > 0) {
|
|
331
338
|
whereClause.OR = searchColumns.map((column) => {
|
|
@@ -352,7 +359,7 @@ var commonRepository = (serviceDeps) => {
|
|
|
352
359
|
});
|
|
353
360
|
}
|
|
354
361
|
const query = {
|
|
355
|
-
where: { ...whereClause, ...fixWhere },
|
|
362
|
+
where: { ...whereClause, ...fixWhere, ...customWhereClause },
|
|
356
363
|
select: selectClause
|
|
357
364
|
};
|
|
358
365
|
const results = await model.findMany(query);
|
|
@@ -456,18 +463,39 @@ var commonRepository = (serviceDeps) => {
|
|
|
456
463
|
logger.info("exiting::commonUpdateStatus::repository");
|
|
457
464
|
return results;
|
|
458
465
|
},
|
|
459
|
-
async
|
|
460
|
-
searchText,
|
|
461
|
-
sortBy,
|
|
462
|
-
sortDir,
|
|
463
|
-
searchColumns,
|
|
464
|
-
// now [{ col: string, type: string }, ...]
|
|
466
|
+
async generateRootCondition({
|
|
465
467
|
fixedSearch,
|
|
466
|
-
// now { [fieldName]: { type: string, value: any[] } }
|
|
467
468
|
fixedNotSearch
|
|
468
|
-
// same structure
|
|
469
469
|
}) {
|
|
470
|
-
|
|
470
|
+
function mergeTopLevel(objA, objB) {
|
|
471
|
+
for (const k of Object.keys(objB)) {
|
|
472
|
+
if (objA[k] === void 0) {
|
|
473
|
+
objA[k] = objB[k];
|
|
474
|
+
} else {
|
|
475
|
+
objA[k] = deepMerge(objA[k], objB[k]);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function deepMerge(a, b) {
|
|
480
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
481
|
+
const result = { ...a };
|
|
482
|
+
for (const key of Object.keys(b)) {
|
|
483
|
+
if (result[key] === void 0) {
|
|
484
|
+
result[key] = b[key];
|
|
485
|
+
} else {
|
|
486
|
+
result[key] = deepMerge(result[key], b[key]);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return result;
|
|
490
|
+
}
|
|
491
|
+
if ((0, import_util2.isDeepStrictEqual)(a, b) || isPlainObject(b) && Object.keys(b).length === 0) {
|
|
492
|
+
return a;
|
|
493
|
+
}
|
|
494
|
+
if (isPlainObject(a) && Object.keys(a).length === 0) {
|
|
495
|
+
return b;
|
|
496
|
+
}
|
|
497
|
+
return { AND: [a, b] };
|
|
498
|
+
}
|
|
471
499
|
const rootCondition = {};
|
|
472
500
|
if (fixedSearch) {
|
|
473
501
|
for (const [field, defObj] of Object.entries(fixedSearch)) {
|
|
@@ -502,35 +530,24 @@ var commonRepository = (serviceDeps) => {
|
|
|
502
530
|
mergeTopLevel(rootCondition, cond);
|
|
503
531
|
}
|
|
504
532
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
}
|
|
524
|
-
return result;
|
|
525
|
-
}
|
|
526
|
-
if ((0, import_util2.isDeepStrictEqual)(a, b) || isPlainObject(b) && Object.keys(b).length === 0) {
|
|
527
|
-
return a;
|
|
528
|
-
}
|
|
529
|
-
if (isPlainObject(a) && Object.keys(a).length === 0) {
|
|
530
|
-
return b;
|
|
531
|
-
}
|
|
532
|
-
return { AND: [a, b] };
|
|
533
|
-
}
|
|
533
|
+
return rootCondition;
|
|
534
|
+
},
|
|
535
|
+
async commonFunctionForFixedSearch({
|
|
536
|
+
searchText,
|
|
537
|
+
sortBy,
|
|
538
|
+
sortDir,
|
|
539
|
+
searchColumns,
|
|
540
|
+
// now [{ col: string, type: string }, ...]
|
|
541
|
+
fixedSearch,
|
|
542
|
+
// now { [fieldName]: { type: string, value: any[] } }
|
|
543
|
+
fixedNotSearch
|
|
544
|
+
// same structure
|
|
545
|
+
}) {
|
|
546
|
+
logger.info("entering::fixedSearch::repository");
|
|
547
|
+
const rootCondition = await this.generateRootCondition({
|
|
548
|
+
fixedSearch,
|
|
549
|
+
fixedNotSearch
|
|
550
|
+
});
|
|
534
551
|
let searchOR;
|
|
535
552
|
if (searchText && searchColumns && searchColumns.length > 0) {
|
|
536
553
|
searchOR = [];
|
package/dist/index.mjs
CHANGED
|
@@ -280,10 +280,17 @@ var commonRepository = (serviceDeps) => {
|
|
|
280
280
|
async commonDropdownSearch({
|
|
281
281
|
searchText,
|
|
282
282
|
searchColumns,
|
|
283
|
-
shortCodeData
|
|
283
|
+
shortCodeData,
|
|
284
|
+
fixedSearch,
|
|
285
|
+
fixedNotSearch
|
|
284
286
|
}) {
|
|
285
287
|
logger.info("entering::commonSearch::repository");
|
|
286
288
|
const tableName = shortCodeData.tableName;
|
|
289
|
+
const rootCondition = await this.generateRootCondition({
|
|
290
|
+
fixedSearch,
|
|
291
|
+
fixedNotSearch
|
|
292
|
+
});
|
|
293
|
+
const customWhereClause = { ...rootCondition };
|
|
287
294
|
const whereClause = {};
|
|
288
295
|
if (searchText && searchColumns.length > 0) {
|
|
289
296
|
whereClause.OR = searchColumns.map((column) => {
|
|
@@ -310,7 +317,7 @@ var commonRepository = (serviceDeps) => {
|
|
|
310
317
|
});
|
|
311
318
|
}
|
|
312
319
|
const query = {
|
|
313
|
-
where: { ...whereClause, ...fixWhere },
|
|
320
|
+
where: { ...whereClause, ...fixWhere, ...customWhereClause },
|
|
314
321
|
select: selectClause
|
|
315
322
|
};
|
|
316
323
|
const results = await model.findMany(query);
|
|
@@ -414,18 +421,39 @@ var commonRepository = (serviceDeps) => {
|
|
|
414
421
|
logger.info("exiting::commonUpdateStatus::repository");
|
|
415
422
|
return results;
|
|
416
423
|
},
|
|
417
|
-
async
|
|
418
|
-
searchText,
|
|
419
|
-
sortBy,
|
|
420
|
-
sortDir,
|
|
421
|
-
searchColumns,
|
|
422
|
-
// now [{ col: string, type: string }, ...]
|
|
424
|
+
async generateRootCondition({
|
|
423
425
|
fixedSearch,
|
|
424
|
-
// now { [fieldName]: { type: string, value: any[] } }
|
|
425
426
|
fixedNotSearch
|
|
426
|
-
// same structure
|
|
427
427
|
}) {
|
|
428
|
-
|
|
428
|
+
function mergeTopLevel(objA, objB) {
|
|
429
|
+
for (const k of Object.keys(objB)) {
|
|
430
|
+
if (objA[k] === void 0) {
|
|
431
|
+
objA[k] = objB[k];
|
|
432
|
+
} else {
|
|
433
|
+
objA[k] = deepMerge(objA[k], objB[k]);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function deepMerge(a, b) {
|
|
438
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
439
|
+
const result = { ...a };
|
|
440
|
+
for (const key of Object.keys(b)) {
|
|
441
|
+
if (result[key] === void 0) {
|
|
442
|
+
result[key] = b[key];
|
|
443
|
+
} else {
|
|
444
|
+
result[key] = deepMerge(result[key], b[key]);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return result;
|
|
448
|
+
}
|
|
449
|
+
if (isDeepStrictEqual2(a, b) || isPlainObject(b) && Object.keys(b).length === 0) {
|
|
450
|
+
return a;
|
|
451
|
+
}
|
|
452
|
+
if (isPlainObject(a) && Object.keys(a).length === 0) {
|
|
453
|
+
return b;
|
|
454
|
+
}
|
|
455
|
+
return { AND: [a, b] };
|
|
456
|
+
}
|
|
429
457
|
const rootCondition = {};
|
|
430
458
|
if (fixedSearch) {
|
|
431
459
|
for (const [field, defObj] of Object.entries(fixedSearch)) {
|
|
@@ -460,35 +488,24 @@ var commonRepository = (serviceDeps) => {
|
|
|
460
488
|
mergeTopLevel(rootCondition, cond);
|
|
461
489
|
}
|
|
462
490
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
return result;
|
|
483
|
-
}
|
|
484
|
-
if (isDeepStrictEqual2(a, b) || isPlainObject(b) && Object.keys(b).length === 0) {
|
|
485
|
-
return a;
|
|
486
|
-
}
|
|
487
|
-
if (isPlainObject(a) && Object.keys(a).length === 0) {
|
|
488
|
-
return b;
|
|
489
|
-
}
|
|
490
|
-
return { AND: [a, b] };
|
|
491
|
-
}
|
|
491
|
+
return rootCondition;
|
|
492
|
+
},
|
|
493
|
+
async commonFunctionForFixedSearch({
|
|
494
|
+
searchText,
|
|
495
|
+
sortBy,
|
|
496
|
+
sortDir,
|
|
497
|
+
searchColumns,
|
|
498
|
+
// now [{ col: string, type: string }, ...]
|
|
499
|
+
fixedSearch,
|
|
500
|
+
// now { [fieldName]: { type: string, value: any[] } }
|
|
501
|
+
fixedNotSearch
|
|
502
|
+
// same structure
|
|
503
|
+
}) {
|
|
504
|
+
logger.info("entering::fixedSearch::repository");
|
|
505
|
+
const rootCondition = await this.generateRootCondition({
|
|
506
|
+
fixedSearch,
|
|
507
|
+
fixedNotSearch
|
|
508
|
+
});
|
|
492
509
|
let searchOR;
|
|
493
510
|
if (searchText && searchColumns && searchColumns.length > 0) {
|
|
494
511
|
searchOR = [];
|