drapcode-utility 1.4.5 → 1.4.6
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/build/utils/query-parser.js +84 -124
- package/package.json +1 -1
|
@@ -456,6 +456,22 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
456
456
|
});
|
|
457
457
|
});
|
|
458
458
|
}
|
|
459
|
+
else {
|
|
460
|
+
var constantDataObj = [
|
|
461
|
+
{ constantName: drapcode_constant_1.CURRENT_USER, data: currentUser },
|
|
462
|
+
{ constantName: drapcode_constant_1.CURRENT_TENANT, data: currentTenant },
|
|
463
|
+
{ constantName: drapcode_constant_1.CURRENT_SETTINGS, data: currentUserSetting },
|
|
464
|
+
];
|
|
465
|
+
constantDataObj.forEach(function (cnst) {
|
|
466
|
+
if (value.includes(cnst.constantName)) {
|
|
467
|
+
var currentDataValue = getCurrentDataValueFrom(value, cnst.constantName, cnst.data, true);
|
|
468
|
+
if (currentDataValue) {
|
|
469
|
+
valueList_1 = Array.isArray(currentDataValue)
|
|
470
|
+
? __spreadArray(__spreadArray([], valueList_1), currentDataValue) : __spreadArray(__spreadArray([], valueList_1), [currentDataValue]);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
459
475
|
return valueList_1;
|
|
460
476
|
}
|
|
461
477
|
if (key === drapcode_constant_1.BETWEEN) {
|
|
@@ -494,130 +510,18 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
494
510
|
else
|
|
495
511
|
return startValue_1 + "---" + endValue_1;
|
|
496
512
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
refCollection = splitValues[0];
|
|
510
|
-
refCollectionField = splitValues[1];
|
|
511
|
-
}
|
|
512
|
-
else {
|
|
513
|
-
refCollection = splitValues[0];
|
|
514
|
-
refCollectionField = "";
|
|
515
|
-
}
|
|
516
|
-
console.log("refCollection", refCollection);
|
|
517
|
-
console.log("refCollectionField", refCollectionField);
|
|
518
|
-
console.log("first", refCollectionField && refCollection);
|
|
519
|
-
if (refCollection && refCollectionField) {
|
|
520
|
-
console.log("I have refCollection and Field");
|
|
521
|
-
if (refCollection === drapcode_constant_1.CURRENT_USER) {
|
|
522
|
-
return currentUser[refCollectionField];
|
|
523
|
-
}
|
|
524
|
-
else {
|
|
525
|
-
var refCollectionData = currentUser[refCollection];
|
|
526
|
-
if (!refCollectionData) {
|
|
527
|
-
return "";
|
|
528
|
-
}
|
|
529
|
-
if (refCollectionData.length > 1) {
|
|
530
|
-
//TODO: Need to handle multi ref
|
|
531
|
-
return "";
|
|
532
|
-
}
|
|
533
|
-
refCollectionData = refCollectionData[0];
|
|
534
|
-
console.log("refCollectionData[refCollectionField]", refCollectionData[refCollectionField]);
|
|
535
|
-
return refCollectionData[refCollectionField];
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
//this means that data has to be match with currnet user field that is not ref type
|
|
539
|
-
if (refCollection) {
|
|
540
|
-
return currentUser[refCollection];
|
|
541
|
-
}
|
|
542
|
-
return currentUser["uuid"];
|
|
543
|
-
}
|
|
544
|
-
if (value.includes(drapcode_constant_1.CURRENT_TENANT)) {
|
|
545
|
-
if (value === drapcode_constant_1.CURRENT_TENANT) {
|
|
546
|
-
return currentTenant["uuid"];
|
|
547
|
-
}
|
|
548
|
-
var splitValues = value.split("::");
|
|
549
|
-
console.log("splitValues", splitValues);
|
|
550
|
-
var refCollection = "", refCollectionField = "";
|
|
551
|
-
if (splitValues.length > 2) {
|
|
552
|
-
refCollection = splitValues[1];
|
|
553
|
-
refCollectionField = splitValues[2];
|
|
554
|
-
}
|
|
555
|
-
else if (splitValues.length === 2) {
|
|
556
|
-
refCollection = splitValues[0];
|
|
557
|
-
refCollectionField = splitValues[1];
|
|
558
|
-
}
|
|
559
|
-
else {
|
|
560
|
-
refCollection = splitValues[0];
|
|
561
|
-
refCollectionField = "";
|
|
562
|
-
}
|
|
563
|
-
if (refCollection && refCollectionField) {
|
|
564
|
-
console.log("I have refCollection and Field");
|
|
565
|
-
if (refCollection === "CURRENT_TENANT") {
|
|
566
|
-
return currentTenant[refCollectionField];
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
var refCollectionData = currentTenant[refCollection];
|
|
570
|
-
if (!refCollectionData)
|
|
571
|
-
return "";
|
|
572
|
-
if (refCollectionData.length > 1)
|
|
573
|
-
return "";
|
|
574
|
-
refCollectionData = refCollectionData[0];
|
|
575
|
-
return refCollectionData[refCollectionField];
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
//this means that data has to be match with currnet user field that is not ref type
|
|
579
|
-
if (refCollection)
|
|
580
|
-
return currentTenant[refCollection];
|
|
581
|
-
return currentTenant["uuid"];
|
|
582
|
-
}
|
|
583
|
-
if (value.includes(drapcode_constant_1.CURRENT_SETTINGS)) {
|
|
584
|
-
if (value === drapcode_constant_1.CURRENT_SETTINGS) {
|
|
585
|
-
return currentUserSetting["uuid"];
|
|
586
|
-
}
|
|
587
|
-
var splitValues = value.split("::");
|
|
588
|
-
console.log("splitValues", splitValues);
|
|
589
|
-
var refCollection = "", refCollectionField = "";
|
|
590
|
-
if (splitValues.length > 2) {
|
|
591
|
-
refCollection = splitValues[1];
|
|
592
|
-
refCollectionField = splitValues[2];
|
|
593
|
-
}
|
|
594
|
-
else if (splitValues.length === 2) {
|
|
595
|
-
refCollection = splitValues[0];
|
|
596
|
-
refCollectionField = splitValues[1];
|
|
597
|
-
}
|
|
598
|
-
else {
|
|
599
|
-
refCollection = splitValues[0];
|
|
600
|
-
refCollectionField = "";
|
|
601
|
-
}
|
|
602
|
-
if (refCollection && refCollectionField) {
|
|
603
|
-
console.log("I have refCollection and Field", refCollection, refCollectionField);
|
|
604
|
-
if (refCollection === "CURRENT_SETTINGS") {
|
|
605
|
-
return currentUserSetting[refCollectionField];
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
var refCollectionData = currentUserSetting[refCollection];
|
|
609
|
-
if (!refCollectionData)
|
|
610
|
-
return "";
|
|
611
|
-
if (refCollectionData.length > 1)
|
|
612
|
-
return "";
|
|
613
|
-
refCollectionData = refCollectionData[0];
|
|
614
|
-
return refCollectionData[refCollectionField];
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
if (refCollection)
|
|
618
|
-
return currentUserSetting[refCollection];
|
|
619
|
-
return currentUserSetting["uuid"];
|
|
620
|
-
}
|
|
513
|
+
var currentUserValue = getCurrentDataValueFrom(value, drapcode_constant_1.CURRENT_USER, currentUser);
|
|
514
|
+
console.log("\n currentUserValue :>> ", currentUserValue);
|
|
515
|
+
if (currentUserValue)
|
|
516
|
+
return currentUserValue;
|
|
517
|
+
var currentTenantValue = getCurrentDataValueFrom(value, drapcode_constant_1.CURRENT_TENANT, currentTenant);
|
|
518
|
+
console.log("\n currentTenantValue :>> ", currentTenantValue);
|
|
519
|
+
if (currentTenantValue)
|
|
520
|
+
return currentTenantValue;
|
|
521
|
+
var currentUserSettingsValue = getCurrentDataValueFrom(value, drapcode_constant_1.CURRENT_SETTINGS, currentUserSetting);
|
|
522
|
+
console.log("\n currentUserSettingsValue :>> ", currentUserSettingsValue);
|
|
523
|
+
if (currentUserSettingsValue)
|
|
524
|
+
return currentUserSettingsValue;
|
|
621
525
|
if (drapcode_constant_1.DateConstant.some(function (cnst) { return value.includes(cnst); })) {
|
|
622
526
|
return getValueOfProjectConstant(value, {}, timezone);
|
|
623
527
|
}
|
|
@@ -789,3 +693,59 @@ var getSearchObjQuery = function (searchObj, searchQueryTypeObj, timezone) {
|
|
|
789
693
|
console.log("==> likeQuery", JSON.stringify(likeQuery));
|
|
790
694
|
return { searchAggregateQuery: searchAggregateQuery, likeQuery: likeQuery };
|
|
791
695
|
};
|
|
696
|
+
var getCurrentDataValueFrom = function (value, constantName, data, isMultiRef) {
|
|
697
|
+
if (isMultiRef === void 0) { isMultiRef = false; }
|
|
698
|
+
if (value.includes(constantName)) {
|
|
699
|
+
if (value === constantName)
|
|
700
|
+
return data["uuid"];
|
|
701
|
+
var splitValues = value.split("::");
|
|
702
|
+
console.log("splitValues", splitValues);
|
|
703
|
+
var refCollection = "", refCollectionField_1 = "";
|
|
704
|
+
if (splitValues.length > 2) {
|
|
705
|
+
refCollection = splitValues[1];
|
|
706
|
+
refCollectionField_1 = splitValues[2];
|
|
707
|
+
}
|
|
708
|
+
else if (splitValues.length === 2) {
|
|
709
|
+
refCollection = splitValues[0];
|
|
710
|
+
refCollectionField_1 = splitValues[1];
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
refCollection = splitValues[0];
|
|
714
|
+
refCollectionField_1 = "";
|
|
715
|
+
}
|
|
716
|
+
console.log("refCollection", refCollection);
|
|
717
|
+
console.log("refCollectionField", refCollectionField_1);
|
|
718
|
+
console.log("first", refCollectionField_1 && refCollection);
|
|
719
|
+
if (refCollection && refCollectionField_1) {
|
|
720
|
+
console.log("I have refCollection and Field");
|
|
721
|
+
if (refCollection === constantName) {
|
|
722
|
+
return data[refCollectionField_1];
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
var refCollectionData = data[refCollection];
|
|
726
|
+
console.log("refCollectionData", refCollectionData);
|
|
727
|
+
if (!refCollectionData)
|
|
728
|
+
return "";
|
|
729
|
+
if (refCollectionData.length > 1) {
|
|
730
|
+
//TODO: Need to handle multi ref
|
|
731
|
+
// Handled For IN_LIST and NOT_IN_LIST Condition
|
|
732
|
+
if (!isMultiRef)
|
|
733
|
+
return "";
|
|
734
|
+
var finalValue_1 = [];
|
|
735
|
+
refCollectionData.forEach(function (refData) {
|
|
736
|
+
if (refData[refCollectionField_1])
|
|
737
|
+
finalValue_1.push(refData[refCollectionField_1]);
|
|
738
|
+
});
|
|
739
|
+
return finalValue_1;
|
|
740
|
+
}
|
|
741
|
+
refCollectionData = refCollectionData[0];
|
|
742
|
+
console.log("refCollectionData[refCollectionField]", refCollectionData[refCollectionField_1]);
|
|
743
|
+
return refCollectionData[refCollectionField_1];
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
//this means that data has to be match with currnet user field that is not ref type
|
|
747
|
+
if (refCollection)
|
|
748
|
+
return data[refCollection];
|
|
749
|
+
return data["uuid"];
|
|
750
|
+
}
|
|
751
|
+
};
|