drapcode-utility 1.2.2 → 1.2.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.
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -35,10 +35,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
39
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
40
- to[j] = from[i];
41
- return to;
38
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
42
46
  };
43
47
  Object.defineProperty(exports, "__esModule", { value: true });
44
48
  exports.queryParserNew = void 0;
@@ -81,11 +85,11 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
81
85
  if (searchQueryTypeObj[key]) {
82
86
  aggregateQuery.push({
83
87
  $addFields: (_b = {},
84
- _b["_" + key] = { $toString: "$" + key },
88
+ _b["_".concat(key)] = { $toString: "$".concat(key) },
85
89
  _b),
86
90
  });
87
91
  searchQueryObj_1.push((_c = {},
88
- _c["_" + key] = {
92
+ _c["_".concat(key)] = {
89
93
  $regex: value,
90
94
  $options: "i",
91
95
  },
@@ -119,11 +123,11 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
119
123
  // if input is string and db field type is boolean
120
124
  aggregateQuery.push({
121
125
  $addFields: (_b = {},
122
- _b["_" + key] = "$" + key,
126
+ _b["_".concat(key)] = "$".concat(key),
123
127
  _b),
124
128
  });
125
129
  likeQuery_1.push((_c = {},
126
- _c["_" + key] = toBoolean(value),
130
+ _c["_".concat(key)] = toBoolean(value),
127
131
  _c));
128
132
  }
129
133
  else if ([
@@ -135,22 +139,22 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
135
139
  // if input is string and db field type is array
136
140
  aggregateQuery.push({
137
141
  $addFields: (_d = {},
138
- _d["_" + key] = "$" + key,
142
+ _d["_".concat(key)] = "$".concat(key),
139
143
  _d),
140
144
  });
141
145
  likeQuery_1.push((_e = {},
142
- _e["_" + key] = { $all: [value] },
146
+ _e["_".concat(key)] = { $all: [value] },
143
147
  _e));
144
148
  }
145
149
  else if (searchQueryTypeObj[key] === "tel") {
146
150
  // handling value when db field type is tel
147
151
  aggregateQuery.push({
148
152
  $addFields: (_f = {},
149
- _f["_" + key] = { $toString: "$" + key },
153
+ _f["_".concat(key)] = { $toString: "$".concat(key) },
150
154
  _f),
151
155
  });
152
156
  likeQuery_1.push((_g = {},
153
- _g["_" + key] = {
157
+ _g["_".concat(key)] = {
154
158
  $regex: value.startsWith("+") ? value.replace("+", "") : value,
155
159
  $options: "i",
156
160
  },
@@ -160,11 +164,11 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
160
164
  // handling value when db field type is Double/Int
161
165
  aggregateQuery.push({
162
166
  $addFields: (_h = {},
163
- _h["_" + key] = { $toString: { $toLong: "$" + key } },
167
+ _h["_".concat(key)] = { $toString: { $toLong: "$".concat(key) } },
164
168
  _h),
165
169
  });
166
170
  likeQuery_1.push((_j = {},
167
- _j["_" + key] = {
171
+ _j["_".concat(key)] = {
168
172
  $regex: value,
169
173
  $options: "i",
170
174
  },
@@ -175,11 +179,11 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
175
179
  // converting db field to string first
176
180
  aggregateQuery.push({
177
181
  $addFields: (_k = {},
178
- _k["_" + key] = { $toString: "$" + key },
182
+ _k["_".concat(key)] = { $toString: "$".concat(key) },
179
183
  _k),
180
184
  });
181
185
  likeQuery_1.push((_l = {},
182
- _l["_" + key] = {
186
+ _l["_".concat(key)] = {
183
187
  $regex: value,
184
188
  $options: "i",
185
189
  },
@@ -214,7 +218,7 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
214
218
  if (field.type === "belongsTo") {
215
219
  aggregateQuery.push({
216
220
  $lookup: {
217
- from: "" + collectionName_1,
221
+ from: "".concat(collectionName_1),
218
222
  localField: field.fieldName,
219
223
  foreignField: "uuid",
220
224
  as: field.fieldName,
@@ -229,8 +233,8 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
229
233
  else {
230
234
  aggregateQuery.push({
231
235
  $lookup: {
232
- from: "" + collectionName_1,
233
- let: (_b = {}, _b["" + field.fieldName] = "$" + field.fieldName, _b),
236
+ from: "".concat(collectionName_1),
237
+ let: (_b = {}, _b["".concat(field.fieldName)] = "$".concat(field.fieldName), _b),
234
238
  pipeline: [
235
239
  {
236
240
  $match: {
@@ -240,10 +244,10 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
240
244
  {
241
245
  $cond: {
242
246
  if: {
243
- $in: ["$$" + field.fieldName, ["", null]],
247
+ $in: ["$$".concat(field.fieldName), ["", null]],
244
248
  },
245
249
  then: [],
246
- else: { $ifNull: ["$$" + field.fieldName, []] },
250
+ else: { $ifNull: ["$$".concat(field.fieldName), []] },
247
251
  },
248
252
  },
249
253
  ],
@@ -276,10 +280,10 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
276
280
  aggregateQuery.push({
277
281
  $lookup: {
278
282
  from: "user",
279
- let: (_c = {}, _c["" + field.fieldName] = "$" + field.fieldName, _c),
283
+ let: (_c = {}, _c["".concat(field.fieldName)] = "$".concat(field.fieldName), _c),
280
284
  pipeline: [
281
285
  {
282
- $match: { $expr: { $eq: ["$uuid", "$$" + field.fieldName] } },
286
+ $match: { $expr: { $eq: ["$uuid", "$$".concat(field.fieldName)] } },
283
287
  },
284
288
  { $project: { _id: 0, password: 0 } },
285
289
  ],
@@ -292,7 +296,7 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
292
296
  _b.label = 2;
293
297
  case 2:
294
298
  if (!["COUNT", "SUM", "AVG", "MIN", "MAX"].includes(finder) &&
295
- !util_1.isEmpty(projection)) {
299
+ !(0, util_1.isEmpty)(projection)) {
296
300
  aggregateQuery.push({ $project: projection });
297
301
  }
298
302
  if (finder === "COUNT") {
@@ -300,22 +304,22 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
300
304
  }
301
305
  else if (finder === "SUM") {
302
306
  aggregateQuery.push({
303
- $group: { _id: null, total: { $sum: "$" + aggregateFunctionField } },
307
+ $group: { _id: null, total: { $sum: "$".concat(aggregateFunctionField) } },
304
308
  });
305
309
  }
306
310
  else if (finder === "AVG") {
307
311
  aggregateQuery.push({
308
- $group: { _id: null, average: { $avg: "$" + aggregateFunctionField } },
312
+ $group: { _id: null, average: { $avg: "$".concat(aggregateFunctionField) } },
309
313
  });
310
314
  }
311
315
  else if (finder === "MIN") {
312
316
  aggregateQuery.push({
313
- $group: { _id: null, minimum: { $min: "$" + aggregateFunctionField } },
317
+ $group: { _id: null, minimum: { $min: "$".concat(aggregateFunctionField) } },
314
318
  });
315
319
  }
316
320
  else if (finder === "MAX") {
317
321
  aggregateQuery.push({
318
- $group: { _id: null, maximum: { $max: "$" + aggregateFunctionField } },
322
+ $group: { _id: null, maximum: { $max: "$".concat(aggregateFunctionField) } },
319
323
  });
320
324
  }
321
325
  offset = externalParams.offset || 0;
@@ -331,8 +335,8 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
331
335
  if (finder != "COUNT" && limit) {
332
336
  aggregateQuery.push({ $skip: +offset }, { $limit: +limit });
333
337
  }
334
- queryStr = ".aggregate(" + JSON.stringify(aggregateQuery) + ", { collation: { locale: \"en\" } })";
335
- str = "req.db.collection('" + collectionName + "')" + queryStr;
338
+ queryStr = ".aggregate(".concat(JSON.stringify(aggregateQuery), ", { collation: { locale: \"en\" } })");
339
+ str = "req.db.collection('".concat(collectionName, "')").concat(queryStr);
336
340
  str += ".toArray()";
337
341
  return [2 /*return*/, str];
338
342
  }
@@ -369,7 +373,7 @@ var mongoFilterQuery = function (query, externalParams, constants, currentUser)
369
373
  filterQuery[lastKey].push(mongoQuery);
370
374
  }
371
375
  else {
372
- filterQuery["$or" + index] = [mongoQuery];
376
+ filterQuery["$or".concat(index)] = [mongoQuery];
373
377
  }
374
378
  }
375
379
  else if (queryObj.conjunctionType == "AND") {
@@ -378,11 +382,11 @@ var mongoFilterQuery = function (query, externalParams, constants, currentUser)
378
382
  filterQuery[lastKey].push(mongoQuery);
379
383
  }
380
384
  else {
381
- filterQuery["$and" + index] = [mongoQuery];
385
+ filterQuery["$and".concat(index)] = [mongoQuery];
382
386
  }
383
387
  }
384
388
  else {
385
- filterQuery["$or" + index] = [mongoQuery];
389
+ filterQuery["$or".concat(index)] = [mongoQuery];
386
390
  }
387
391
  });
388
392
  console.log("==> *** filterQuery #2 :>> ", filterQuery);
@@ -398,15 +402,15 @@ var mongoSelectQuery = function (query) {
398
402
  if (fieldsInclude[0] === "*") {
399
403
  fieldsExclude.map(function (field) {
400
404
  if (field)
401
- return (projection["" + field] = 0);
405
+ return (projection["".concat(field)] = 0);
402
406
  });
403
407
  }
404
408
  else {
405
409
  if (["FIND_ALL", "FIND"].includes(finder))
406
- fieldsInclude = util_1.processFieldsInlcude(fieldsInclude);
410
+ fieldsInclude = (0, util_1.processFieldsInlcude)(fieldsInclude);
407
411
  fieldsInclude.map(function (field) {
408
412
  if (field)
409
- return (projection["" + field] = 1);
413
+ return (projection["".concat(field)] = 1);
410
414
  });
411
415
  }
412
416
  return projection;
@@ -497,7 +501,7 @@ var queryToMongo = function (query, requiredExternal, externalParams, constants,
497
501
  return _r = {},
498
502
  _r[field] = {
499
503
  $gte: fieldValue,
500
- $lt: new Date(date_util_1.nextDayDate(fieldValue)),
504
+ $lt: new Date((0, date_util_1.nextDayDate)(fieldValue)),
501
505
  },
502
506
  _r;
503
507
  }
@@ -575,11 +579,11 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
575
579
  if (key === drapcode_constant_1.BETWEEN) {
576
580
  var _a = getMinMaxValue(value), startValue_1 = _a.startValue, endValue_1 = _a.endValue, isInteger = _a.isInteger;
577
581
  if (requiredExternal) {
578
- startValue_1 = "" + externalParams[startValue_1];
579
- endValue_1 = "" + externalParams[endValue_1];
582
+ startValue_1 = "".concat(externalParams[startValue_1]);
583
+ endValue_1 = "".concat(externalParams[endValue_1]);
580
584
  }
581
585
  else {
582
- if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant).some(function (cnst) {
586
+ if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant, true).some(function (cnst) {
583
587
  return startValue_1.includes(cnst);
584
588
  })) {
585
589
  startValue_1 = getValueOfProjectConstant(startValue_1, currentUser);
@@ -587,7 +591,7 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
587
591
  else {
588
592
  startValue_1 = constants.filter(function (constant) { return constant.name == startValue_1; });
589
593
  }
590
- if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant).some(function (cnst) { return endValue_1.includes(cnst); })) {
594
+ if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant, true).some(function (cnst) { return endValue_1.includes(cnst); })) {
591
595
  endValue_1 = getValueOfProjectConstant(endValue_1, currentUser);
592
596
  }
593
597
  else {
@@ -604,10 +608,10 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
604
608
  //TODO: Need to figure out the params should be treated as number/string
605
609
  if (!isNaN(startValue_1)) {
606
610
  console.log("I am Number");
607
- return startValue_1 + "---" + endValue_1 + "^";
611
+ return "".concat(startValue_1, "---").concat(endValue_1, "^");
608
612
  }
609
613
  else
610
- return startValue_1 + "---" + endValue_1;
614
+ return "".concat(startValue_1, "---").concat(endValue_1);
611
615
  }
612
616
  if (value.includes(drapcode_constant_1.CURRENT_USER)) {
613
617
  if (value === drapcode_constant_1.CURRENT_USER) {
@@ -645,11 +649,11 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
645
649
  //TODO: This is just to confirm if external then it should be get from externalParams
646
650
  if (requiredExternal) {
647
651
  //TODO: Value returns from here undefined.
648
- var externalParamValue = externalParams["" + value];
652
+ var externalParamValue = externalParams["".concat(value)];
649
653
  if (!isNaN(externalParamValue)) {
650
654
  return +externalParamValue;
651
655
  }
652
- return externalParams["" + value];
656
+ return externalParams["".concat(value)];
653
657
  }
654
658
  var constantArr = constants.filter(function (constant) { return constant.name == value; });
655
659
  return constantArr.length ? "" + constantArr[0].value : "";
@@ -676,9 +680,9 @@ var getValueOfProjectConstant = function (value, currentUser) {
676
680
  if (value === drapcode_constant_1.CURRENT_USER)
677
681
  return currentUser["uuid"];
678
682
  if (value === drapcode_constant_1.CURRENT_DATE)
679
- return date_util_1.createLoggerDateFormat();
683
+ return (0, date_util_1.createLoggerDateFormat)();
680
684
  if ([drapcode_constant_1.CURRENT_TIME, drapcode_constant_1.CURRENT_DATE_TIME].includes(value))
681
- return date_util_1.createLogsDateFormat();
685
+ return (0, date_util_1.createLogsDateFormat)();
682
686
  if (drapcode_constant_1.DateTimeUnit.some(function (cnst) { return value.includes(cnst); }))
683
- return date_util_1.getDateValue(value);
687
+ return (0, date_util_1.getDateValue)(value);
684
688
  };
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -75,9 +75,9 @@ exports.createS3Client = createS3Client;
75
75
  var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
76
76
  if (options === void 0) { options = {}; }
77
77
  return __awaiter(void 0, void 0, void 0, function () {
78
- var awsConfig, encryptionType, dataKey, accessKeyId, secretAccessKey, region, config, plainTextData, fileOptions, s3Key, _a, _b, _i, index, file, fileObj, fileObj;
79
- return __generator(this, function (_c) {
80
- switch (_c.label) {
78
+ var awsConfig, encryptionType, dataKey, accessKeyId, secretAccessKey, region, config, plainTextData, fileOptions, s3Key, _a, _b, _c, _i, index, file, fileObj, fileObj;
79
+ return __generator(this, function (_d) {
80
+ switch (_d.label) {
81
81
  case 0:
82
82
  if (!encryption) return [3 /*break*/, 2];
83
83
  awsConfig = encryption.awsConfig, encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
@@ -88,38 +88,41 @@ var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
88
88
  accessKeyId: accessKeyId,
89
89
  secretAccessKey: secretAccessKey,
90
90
  };
91
- return [4 /*yield*/, encryption_2.processKMSDecryption(config, dataKey, {})];
91
+ return [4 /*yield*/, (0, encryption_2.processKMSDecryption)(config, dataKey, {})];
92
92
  case 1:
93
- plainTextData = _c.sent();
93
+ plainTextData = _d.sent();
94
94
  if (plainTextData.status === "FAILED") {
95
95
  return [2 /*return*/, plainTextData];
96
96
  }
97
97
  encryption.dataKey = plainTextData.data;
98
- _c.label = 2;
98
+ _d.label = 2;
99
99
  case 2:
100
100
  if (!Array.isArray(files)) return [3 /*break*/, 7];
101
101
  console.log("I have multiple file");
102
102
  fileOptions = [];
103
103
  s3Key = s3Config.key;
104
- _a = [];
105
- for (_b in files)
106
- _a.push(_b);
104
+ _a = files;
105
+ _b = [];
106
+ for (_c in _a)
107
+ _b.push(_c);
107
108
  _i = 0;
108
- _c.label = 3;
109
+ _d.label = 3;
109
110
  case 3:
110
- if (!(_i < _a.length)) return [3 /*break*/, 6];
111
- index = _a[_i];
111
+ if (!(_i < _b.length)) return [3 /*break*/, 6];
112
+ _c = _b[_i];
113
+ if (!(_c in _a)) return [3 /*break*/, 5];
114
+ index = _c;
112
115
  file = files[index];
113
116
  if (s3Config.append) {
114
- s3Config.key = s3Key + "/" + file.originalname;
117
+ s3Config.key = "".concat(s3Key, "/").concat(file.originalname);
115
118
  }
116
119
  return [4 /*yield*/, processFileUploadToS3(file, s3Client, s3Config, encryption, options, encryption ? true : false)];
117
120
  case 4:
118
- fileObj = _c.sent();
121
+ fileObj = _d.sent();
119
122
  if (fileObj) {
120
123
  fileOptions.push(fileObj);
121
124
  }
122
- _c.label = 5;
125
+ _d.label = 5;
123
126
  case 5:
124
127
  _i++;
125
128
  return [3 /*break*/, 3];
@@ -127,11 +130,11 @@ var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
127
130
  case 7:
128
131
  console.log("I have single file");
129
132
  if (s3Config.append) {
130
- s3Config.key = s3Config.key + "/" + files.originalname;
133
+ s3Config.key = "".concat(s3Config.key, "/").concat(files.originalname);
131
134
  }
132
135
  return [4 /*yield*/, processFileUploadToS3(files, s3Client, s3Config, encryption, options, encryption ? true : false)];
133
136
  case 8:
134
- fileObj = _c.sent();
137
+ fileObj = _d.sent();
135
138
  return [2 /*return*/, fileObj];
136
139
  }
137
140
  });
@@ -151,7 +154,7 @@ var processFileUploadToS3 = function (file, s3Client, s3Config, encryption, opti
151
154
  acl = s3Config.acl, key = s3Config.key, bucket = s3Config.bucket;
152
155
  params = null;
153
156
  if (!encrypt) return [3 /*break*/, 2];
154
- return [4 /*yield*/, encryption_1.cryptFile(file.path, encryption, false)];
157
+ return [4 /*yield*/, (0, encryption_1.cryptFile)(file.path, encryption, false)];
155
158
  case 1:
156
159
  encryptedBody = _a.sent();
157
160
  params = __assign({ Bucket: bucket, ACL: acl, Key: key,
@@ -1,6 +1,6 @@
1
1
  export declare const validateString: (str: string) => false | "String should not contain special characters" | "String should not contain any number";
2
2
  export declare const camelize: (str: string) => string;
3
- export declare const clearSpaceAndReformat: (text: string, separator?: string | undefined) => string;
3
+ export declare const clearSpaceAndReformat: (text: string, separator?: string) => string;
4
4
  export declare const isEmpty: (obj: any) => boolean;
5
5
  export declare const isEmptyObject: (object: any) => boolean;
6
6
  export declare const isObject: (item: any) => any;
@@ -21,10 +21,14 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  }
22
22
  return t;
23
23
  };
24
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
25
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
26
- to[j] = from[i];
27
- return to;
24
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
26
+ if (ar || !(i in from)) {
27
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
28
+ ar[i] = from[i];
29
+ }
30
+ }
31
+ return to.concat(ar || Array.prototype.slice.call(from));
28
32
  };
29
33
  var __importDefault = (this && this.__importDefault) || function (mod) {
30
34
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -43,7 +47,7 @@ var validateString = function (str) {
43
47
  };
44
48
  exports.validateString = validateString;
45
49
  var camelize = function (str) {
46
- str = exports.clearSpaceAndReformat(str);
50
+ str = (0, exports.clearSpaceAndReformat)(str);
47
51
  return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
48
52
  return index === 0 ? word.toLowerCase() : word.toUpperCase();
49
53
  });
@@ -170,8 +174,8 @@ var cleanCollectionAndFieldName = function (str) {
170
174
  };
171
175
  exports.cleanCollectionAndFieldName = cleanCollectionAndFieldName;
172
176
  var formatCollectionAndFieldName = function (str) {
173
- var updateString = exports.cleanCollectionAndFieldName(str);
174
- return exports.clearSpaceAndReformat(updateString.trim(), "_");
177
+ var updateString = (0, exports.cleanCollectionAndFieldName)(str);
178
+ return (0, exports.clearSpaceAndReformat)(updateString.trim(), "_");
175
179
  };
176
180
  exports.formatCollectionAndFieldName = formatCollectionAndFieldName;
177
181
  var restructureData = function (data) {
@@ -202,7 +206,7 @@ var restructureData = function (data) {
202
206
  exports.restructureData = restructureData;
203
207
  var checkAndCompareValue = function (input1, input2) {
204
208
  return Array.isArray(input2)
205
- ? exports.arraysEqual(input1, input2.map(function (key) { return key.value; }))
209
+ ? (0, exports.arraysEqual)(input1, input2.map(function (key) { return key.value; }))
206
210
  : input1 === input2.value;
207
211
  };
208
212
  exports.checkAndCompareValue = checkAndCompareValue;
@@ -212,7 +216,7 @@ var arraysEqual = function (array1, array2) {
212
216
  return false;
213
217
  for (var i = 0; i < array1.length; i++ // assert each element equal
214
218
  )
215
- if (!exports.arraysEqual(array1[i], array2[i]))
219
+ if (!(0, exports.arraysEqual)(array1[i], array2[i]))
216
220
  return false;
217
221
  return true;
218
222
  }
@@ -247,7 +251,7 @@ var formatCustomCSSClasses = function (projectCustomCSSClasses) {
247
251
  .replace(/"([^"]+)"/g, "$1")
248
252
  .split(",")
249
253
  .join(";");
250
- projectCustomCSSClassesData += "" + (element.class.startsWith(".") ? element.class : "." + element.class) + (element.pseudoClass ? ":" + element.pseudoClass : "") + unquotedClassWithProp + " ";
254
+ projectCustomCSSClassesData += "".concat(element.class.startsWith(".") ? element.class : "." + element.class).concat(element.pseudoClass ? ":" + element.pseudoClass : "").concat(unquotedClassWithProp, " ");
251
255
  }
252
256
  });
253
257
  return projectCustomCSSClassesData;
@@ -258,18 +262,18 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
258
262
  var contentList = (_a = expression
259
263
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
260
264
  contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
261
- var needle = "{{" + prop + "}}";
265
+ var needle = "{{".concat(prop, "}}");
262
266
  var dataOfItem = "";
263
267
  if (prop.includes("current_user")) {
264
268
  prop = prop.replace("current_user.", "");
265
269
  if (Object.keys(user).length > 0) {
266
- dataOfItem = exports.parseValueFromData(user, prop);
270
+ dataOfItem = (0, exports.parseValueFromData)(user, prop);
267
271
  }
268
272
  }
269
273
  else if (prop.includes("current_tenant")) {
270
274
  prop = prop.replace("current_tenant.", "");
271
275
  if (Object.keys(tenant).length > 0) {
272
- dataOfItem = exports.parseValueFromData(tenant, prop);
276
+ dataOfItem = (0, exports.parseValueFromData)(tenant, prop);
273
277
  }
274
278
  }
275
279
  else if (prop.includes("current_session")) {
@@ -295,7 +299,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
295
299
  }
296
300
  else {
297
301
  if (Object.keys(data).length > 0) {
298
- dataOfItem = exports.parseValueFromData(data, prop);
302
+ dataOfItem = (0, exports.parseValueFromData)(data, prop);
299
303
  //TODO: Need better way
300
304
  delete data[prop];
301
305
  }
@@ -395,7 +399,7 @@ var replaceTransferObjectValueIntoExpression = function (expression, transferObj
395
399
  var contentList = (_a = expression
396
400
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
397
401
  contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
398
- var needle = "{{" + prop + "}}";
402
+ var needle = "{{".concat(prop, "}}");
399
403
  var dataOfItem = "";
400
404
  dataOfItem = transferObject[prop] ? transferObject[prop] : "";
401
405
  expression = dataOfItem
@@ -470,8 +474,8 @@ var processFieldsInlcude = function (fieldsInclude) {
470
474
  fieldsInclude = fieldsInclude.filter(function (field) { return !(field.startsWith("RF::") || field.startsWith("DF::")); });
471
475
  var refFields = processReferenceFieldInclude(refFieldsInclude);
472
476
  var derivedFields = processDerivedFieldInclude(derivedFieldsInclude);
473
- var extraField = __spreadArray(__spreadArray([], refFields), derivedFields).filter(function (value, index, array) { return array.indexOf(value) === index; });
474
- result = __spreadArray(__spreadArray([], fieldsInclude), extraField);
477
+ var extraField = __spreadArray(__spreadArray([], refFields, true), derivedFields, true).filter(function (value, index, array) { return array.indexOf(value) === index; });
478
+ result = __spreadArray(__spreadArray([], fieldsInclude, true), extraField, true);
475
479
  return result;
476
480
  };
477
481
  exports.processFieldsInlcude = processFieldsInlcude;
@@ -496,16 +500,16 @@ var processDerivedFieldInclude = function (derivedFieldsInclude) {
496
500
  if (arg.name === "expression") {
497
501
  var needleList = (_a = arg.key
498
502
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
499
- var tempFields = exports.processFieldsInlcude(needleList);
500
- fields = __spreadArray(__spreadArray([], fields), tempFields);
503
+ var tempFields = (0, exports.processFieldsInlcude)(needleList);
504
+ fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
501
505
  }
502
506
  else if (!derivedFieldExcludes.includes(arg.name)) {
503
507
  var tempFields = Array.isArray(arg.key) ? arg.key : [arg.key];
504
- tempFields = exports.processFieldsInlcude(tempFields);
505
- fields = __spreadArray(__spreadArray([], fields), tempFields);
508
+ tempFields = (0, exports.processFieldsInlcude)(tempFields);
509
+ fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
506
510
  }
507
511
  });
508
- derivedFields = __spreadArray(__spreadArray([], derivedFields), fields);
512
+ derivedFields = __spreadArray(__spreadArray([], derivedFields, true), fields, true);
509
513
  });
510
514
  return derivedFields;
511
515
  };
@@ -38,10 +38,10 @@ var nextGeneratedString = function (str, prepend, minLength, append, algorithm)
38
38
  finalValue = voca_1.default.padLeft(finalValue, minLength, "0");
39
39
  }
40
40
  if (prepend) {
41
- finalValue = "" + prepend + finalValue;
41
+ finalValue = "".concat(prepend).concat(finalValue);
42
42
  }
43
43
  if (append) {
44
- finalValue = "" + finalValue + append;
44
+ finalValue = "".concat(finalValue).concat(append);
45
45
  }
46
46
  return finalValue;
47
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -32,8 +32,8 @@
32
32
  "@types/express": "^4.17.7",
33
33
  "@types/voca": "^1.4.2",
34
34
  "axios": "^1.1.2",
35
- "drapcode-constant": "^1.2.4",
36
- "drapcode-logger": "^1.0.4",
35
+ "drapcode-constant": "^1.2.7",
36
+ "drapcode-logger": "^1.0.5",
37
37
  "drapcode-redis": "^1.0.4",
38
38
  "express": "^4.17.1",
39
39
  "lodash": "^4.17.21",