drapcode-utility 1.4.5 → 1.4.7

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.
@@ -1,6 +1,6 @@
1
1
  import { AwsConfig, Encryption } from "./model";
2
- export declare const crypt: (data: any, fields: Array<object>, encryption: Encryption, decrypt: boolean) => Promise<any>;
3
- export declare const processItemEncryptDecrypt: (item: any, fields: Array<object>, encryption: Encryption, decrypt: boolean) => Promise<any>;
2
+ export declare const crypt: (data: any, fields: Array<object>, encryption: Encryption, decrypt: boolean, encrypedRefCollections?: Array<object>) => Promise<any>;
3
+ export declare const processItemEncryptDecrypt: (item: any, fields: Array<object>, encryption: Encryption, decrypt: boolean, encrypedRefCollections?: Array<object>) => Promise<any>;
4
4
  export declare const processDataEncryptionDecryption: (data: string, encryption: Encryption, decrypt: boolean) => Promise<string>;
5
5
  /**
6
6
  * This method is used to generate private KEY for KMS ARN
@@ -41,83 +41,115 @@ var client_kms_1 = require("@aws-sdk/client-kms");
41
41
  var crypt_1 = require("./crypt");
42
42
  var file_1 = require("./file");
43
43
  var KMS_1 = require("./KMS");
44
- var crypt = function (data, fields, encryption, decrypt) { return __awaiter(void 0, void 0, void 0, function () {
45
- var _a, accessKeyId, secretAccessKey, region, config, plainTextData, promises;
46
- return __generator(this, function (_b) {
47
- switch (_b.label) {
48
- case 0:
49
- if (!(encryption.encryptionType === "KMS")) return [3 /*break*/, 2];
50
- _a = encryption.awsConfig, accessKeyId = _a.accessKeyId, secretAccessKey = _a.secretAccessKey, region = _a.region;
51
- config = {
52
- region: region,
53
- accessKeyId: accessKeyId,
54
- secretAccessKey: secretAccessKey,
55
- };
56
- return [4 /*yield*/, exports.processKMSDecryption(config, encryption.dataKey, {})];
57
- case 1:
58
- plainTextData = _b.sent();
59
- if (plainTextData.status === "FAILED") {
60
- return [2 /*return*/, plainTextData];
61
- }
62
- encryption.dataKey = plainTextData.data;
63
- _b.label = 2;
64
- case 2:
65
- if (!Array.isArray(data)) return [3 /*break*/, 4];
66
- promises = data.map(function (item) {
67
- return exports.processItemEncryptDecrypt(item, fields, encryption, decrypt);
68
- });
69
- return [4 /*yield*/, Promise.all(promises)];
70
- case 3:
71
- data = _b.sent();
72
- return [3 /*break*/, 6];
73
- case 4: return [4 /*yield*/, exports.processItemEncryptDecrypt(data, fields, encryption, decrypt)];
74
- case 5:
75
- data = _b.sent();
76
- _b.label = 6;
77
- case 6: return [2 /*return*/, data];
78
- }
44
+ var drapcode_constant_1 = require("drapcode-constant");
45
+ var crypt = function (data, fields, encryption, decrypt, encrypedRefCollections) {
46
+ if (encrypedRefCollections === void 0) { encrypedRefCollections = []; }
47
+ return __awaiter(void 0, void 0, void 0, function () {
48
+ var _a, accessKeyId, secretAccessKey, region, config, plainTextData, promises;
49
+ return __generator(this, function (_b) {
50
+ switch (_b.label) {
51
+ case 0:
52
+ if (!(encryption.encryptionType === "KMS")) return [3 /*break*/, 2];
53
+ _a = encryption.awsConfig, accessKeyId = _a.accessKeyId, secretAccessKey = _a.secretAccessKey, region = _a.region;
54
+ config = {
55
+ region: region,
56
+ accessKeyId: accessKeyId,
57
+ secretAccessKey: secretAccessKey,
58
+ };
59
+ return [4 /*yield*/, exports.processKMSDecryption(config, encryption.dataKey, {})];
60
+ case 1:
61
+ plainTextData = _b.sent();
62
+ if (plainTextData.status === "FAILED") {
63
+ return [2 /*return*/, plainTextData];
64
+ }
65
+ encryption.dataKey = plainTextData.data;
66
+ _b.label = 2;
67
+ case 2:
68
+ if (!Array.isArray(data)) return [3 /*break*/, 4];
69
+ promises = data.map(function (item) {
70
+ return exports.processItemEncryptDecrypt(item, fields, encryption, decrypt, encrypedRefCollections);
71
+ });
72
+ return [4 /*yield*/, Promise.all(promises)];
73
+ case 3:
74
+ data = _b.sent();
75
+ return [3 /*break*/, 6];
76
+ case 4: return [4 /*yield*/, exports.processItemEncryptDecrypt(data, fields, encryption, decrypt, encrypedRefCollections)];
77
+ case 5:
78
+ data = _b.sent();
79
+ _b.label = 6;
80
+ case 6: return [2 /*return*/, data];
81
+ }
82
+ });
79
83
  });
80
- }); };
84
+ };
81
85
  exports.crypt = crypt;
82
- var processItemEncryptDecrypt = function (item, fields, encryption, decrypt) { return __awaiter(void 0, void 0, void 0, function () {
83
- var _loop_1, _i, _a, fieldName;
84
- return __generator(this, function (_b) {
85
- switch (_b.label) {
86
- case 0:
87
- if (!(item && typeof item === "object")) return [3 /*break*/, 4];
88
- _loop_1 = function (fieldName) {
89
- var field, _c, _d;
90
- return __generator(this, function (_e) {
91
- switch (_e.label) {
92
- case 0:
93
- field = fields.find(function (field) { return field.fieldName === fieldName; });
94
- if (!(field && field.encrypted)) return [3 /*break*/, 2];
95
- _c = item;
96
- _d = fieldName;
97
- return [4 /*yield*/, exports.processDataEncryptionDecryption(item[fieldName], encryption, decrypt)];
98
- case 1:
99
- _c[_d] = _e.sent();
100
- _e.label = 2;
101
- case 2: return [2 /*return*/];
102
- }
103
- });
104
- };
105
- _i = 0, _a = Object.keys(item);
106
- _b.label = 1;
107
- case 1:
108
- if (!(_i < _a.length)) return [3 /*break*/, 4];
109
- fieldName = _a[_i];
110
- return [5 /*yield**/, _loop_1(fieldName)];
111
- case 2:
112
- _b.sent();
113
- _b.label = 3;
114
- case 3:
115
- _i++;
116
- return [3 /*break*/, 1];
117
- case 4: return [2 /*return*/, item];
118
- }
86
+ var processItemEncryptDecrypt = function (item, fields, encryption, decrypt, encrypedRefCollections) {
87
+ if (encrypedRefCollections === void 0) { encrypedRefCollections = []; }
88
+ return __awaiter(void 0, void 0, void 0, function () {
89
+ var _loop_1, _i, _a, fieldName;
90
+ return __generator(this, function (_b) {
91
+ switch (_b.label) {
92
+ case 0:
93
+ if (!(item && typeof item === "object")) return [3 /*break*/, 4];
94
+ _loop_1 = function (fieldName) {
95
+ var field, _c, _d, refField, _e, _f, _g, _h;
96
+ return __generator(this, function (_j) {
97
+ switch (_j.label) {
98
+ case 0:
99
+ field = fields.find(function (field) { return field.fieldName === fieldName; });
100
+ if (!(field && field.encrypted)) return [3 /*break*/, 2];
101
+ _c = item;
102
+ _d = fieldName;
103
+ return [4 /*yield*/, exports.processDataEncryptionDecryption(item[fieldName], encryption, decrypt)];
104
+ case 1:
105
+ _c[_d] = _j.sent();
106
+ _j.label = 2;
107
+ case 2:
108
+ if (!decrypt) return [3 /*break*/, 6];
109
+ if (![drapcode_constant_1.FieldTypes.reference.id, drapcode_constant_1.FieldTypes.createdBy.id].includes(field === null || field === void 0 ? void 0 : field.type)) return [3 /*break*/, 4];
110
+ refField = field;
111
+ if (!refField.refCollection &&
112
+ field.type === drapcode_constant_1.FieldTypes.createdBy.id) {
113
+ refField.refCollection = {
114
+ collectionField: "userName",
115
+ collectionName: "user",
116
+ };
117
+ }
118
+ _e = item;
119
+ _f = fieldName;
120
+ return [4 /*yield*/, processReferenceItemDecrypt(item[fieldName], encryption, decrypt, refField, encrypedRefCollections)];
121
+ case 3:
122
+ _e[_f] = _j.sent();
123
+ return [3 /*break*/, 6];
124
+ case 4:
125
+ if (!((field === null || field === void 0 ? void 0 : field.type) === drapcode_constant_1.FieldTypes.dynamic_option.id)) return [3 /*break*/, 6];
126
+ _g = item;
127
+ _h = fieldName;
128
+ return [4 /*yield*/, processDynamicFieldDecrypt(item[fieldName], encryption, decrypt, field, encrypedRefCollections)];
129
+ case 5:
130
+ _g[_h] = _j.sent();
131
+ _j.label = 6;
132
+ case 6: return [2 /*return*/];
133
+ }
134
+ });
135
+ };
136
+ _i = 0, _a = Object.keys(item);
137
+ _b.label = 1;
138
+ case 1:
139
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
140
+ fieldName = _a[_i];
141
+ return [5 /*yield**/, _loop_1(fieldName)];
142
+ case 2:
143
+ _b.sent();
144
+ _b.label = 3;
145
+ case 3:
146
+ _i++;
147
+ return [3 /*break*/, 1];
148
+ case 4: return [2 /*return*/, item];
149
+ }
150
+ });
119
151
  });
120
- }); };
152
+ };
121
153
  exports.processItemEncryptDecrypt = processItemEncryptDecrypt;
122
154
  var processDataEncryptionDecryption = function (data, encryption, decrypt) { return __awaiter(void 0, void 0, void 0, function () {
123
155
  var encryptionType, dataKey, _a, result, _b;
@@ -150,6 +182,56 @@ var processDataEncryptionDecryption = function (data, encryption, decrypt) { ret
150
182
  });
151
183
  }); };
152
184
  exports.processDataEncryptionDecryption = processDataEncryptionDecryption;
185
+ var processReferenceItemDecrypt = function (data, encryption, decrypt, refField, encrypedRefCollections) { return __awaiter(void 0, void 0, void 0, function () {
186
+ var refCollection, promises;
187
+ return __generator(this, function (_a) {
188
+ switch (_a.label) {
189
+ case 0:
190
+ refCollection = getEncryptedReferenceCollection(encrypedRefCollections, refField).refCollection;
191
+ if (!refCollection) return [3 /*break*/, 2];
192
+ if (!Array.isArray(data)) return [3 /*break*/, 2];
193
+ promises = data.map(function (item) {
194
+ return exports.processItemEncryptDecrypt(item, refCollection.fields, encryption, decrypt);
195
+ });
196
+ return [4 /*yield*/, Promise.all(promises)];
197
+ case 1:
198
+ data = _a.sent();
199
+ _a.label = 2;
200
+ case 2: return [2 /*return*/, data];
201
+ }
202
+ });
203
+ }); };
204
+ var processDynamicFieldDecrypt = function (data, encryption, decrypt, refField, encrypedRefCollections) { return __awaiter(void 0, void 0, void 0, function () {
205
+ var _a, refCollectionFieldName, refCollection, refCollectionField, promises;
206
+ return __generator(this, function (_b) {
207
+ switch (_b.label) {
208
+ case 0:
209
+ _a = getEncryptedReferenceCollection(encrypedRefCollections, refField), refCollectionFieldName = _a.refCollectionFieldName, refCollection = _a.refCollection;
210
+ if (!refCollection) return [3 /*break*/, 2];
211
+ refCollectionField = refCollection.fields.find(function (field) { return field.fieldName === refCollectionFieldName; });
212
+ if (!(refCollectionField && refCollectionField.encrypted)) return [3 /*break*/, 2];
213
+ if (!Array.isArray(data)) return [3 /*break*/, 2];
214
+ promises = data.map(function (item) {
215
+ return exports.processDataEncryptionDecryption(item, encryption, decrypt);
216
+ });
217
+ return [4 /*yield*/, Promise.all(promises)];
218
+ case 1:
219
+ data = _b.sent();
220
+ _b.label = 2;
221
+ case 2: return [2 /*return*/, data];
222
+ }
223
+ });
224
+ }); };
225
+ var getEncryptedReferenceCollection = function (encrypedRefCollections, refField) {
226
+ var _a = refField === null || refField === void 0 ? void 0 : refField.refCollection, refCollectionName = _a.collectionName, refCollectionFieldName = _a.collectionField;
227
+ var refCollection;
228
+ if (encrypedRefCollections.length) {
229
+ if (refCollectionName) {
230
+ refCollection = encrypedRefCollections.find(function (encColl) { return encColl.collectionName === refCollectionName; });
231
+ }
232
+ }
233
+ return { refCollectionName: refCollectionName, refCollectionFieldName: refCollectionFieldName, refCollection: refCollection };
234
+ };
153
235
  /**
154
236
  * This method is used to generate private KEY for KMS ARN
155
237
  * It requires KMS config and ARN
@@ -0,0 +1 @@
1
+ export declare const getEncryptedReferenceFieldsQuery: (collectionFields: any, projectId: any) => any;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
3
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4
+ to[j] = from[i];
5
+ return to;
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.getEncryptedReferenceFieldsQuery = void 0;
9
+ var drapcode_constant_1 = require("drapcode-constant");
10
+ var getEncryptedReferenceFieldsQuery = function (collectionFields, projectId) {
11
+ var collectionsNamesArr = [];
12
+ collectionFields.map(function (field) {
13
+ if (__spreadArray(__spreadArray([], drapcode_constant_1.onlyReferenceField), [
14
+ drapcode_constant_1.FieldTypes.dynamic_option.id,
15
+ drapcode_constant_1.FieldTypes.createdBy.id,
16
+ ]).includes(field.type)) {
17
+ if (!field.refCollection && field.type === drapcode_constant_1.FieldTypes.createdBy.id) {
18
+ collectionsNamesArr.push("user");
19
+ }
20
+ else {
21
+ var collectionName = field.refCollection.collectionName;
22
+ collectionsNamesArr.push(collectionName);
23
+ }
24
+ }
25
+ });
26
+ var query = [
27
+ {
28
+ $match: {
29
+ projectId: projectId,
30
+ collectionName: { $in: __spreadArray([], collectionsNamesArr) },
31
+ fields: { $elemMatch: { encrypted: true } },
32
+ },
33
+ },
34
+ {
35
+ $project: {
36
+ _id: 0,
37
+ collectionName: 1,
38
+ fields: {
39
+ $filter: {
40
+ input: "$fields",
41
+ as: "item",
42
+ cond: { $eq: ["$$item.encrypted", true] },
43
+ },
44
+ },
45
+ },
46
+ },
47
+ ];
48
+ return query;
49
+ };
50
+ exports.getEncryptedReferenceFieldsQuery = getEncryptedReferenceFieldsQuery;
package/build/index.d.ts CHANGED
@@ -15,5 +15,6 @@ export * from "./utils/check-error";
15
15
  export * from "./utils/prepare-query";
16
16
  export * from "./utils/s3-util";
17
17
  export * from "./encryption/index";
18
+ export * from "./encryption/utility";
18
19
  export * from "./format-fields/index";
19
20
  export * from "./utils/token";
package/build/index.js CHANGED
@@ -27,5 +27,6 @@ __exportStar(require("./utils/check-error"), exports);
27
27
  __exportStar(require("./utils/prepare-query"), exports);
28
28
  __exportStar(require("./utils/s3-util"), exports);
29
29
  __exportStar(require("./encryption/index"), exports);
30
+ __exportStar(require("./encryption/utility"), exports);
30
31
  __exportStar(require("./format-fields/index"), exports);
31
32
  __exportStar(require("./utils/token"), exports);
@@ -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
- if (value.includes(drapcode_constant_1.CURRENT_USER)) {
498
- if (value === drapcode_constant_1.CURRENT_USER) {
499
- return currentUser["uuid"];
500
- }
501
- var splitValues = value.split("::");
502
- console.log("splitValues", splitValues);
503
- var refCollection = "", refCollectionField = "";
504
- if (splitValues.length > 2) {
505
- refCollection = splitValues[1];
506
- refCollectionField = splitValues[2];
507
- }
508
- else if (splitValues.length === 2) {
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",