drapcode-utility 1.2.3 → 1.2.5

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