drapcode-utility 2.0.0 → 2.0.2

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.
Files changed (50) hide show
  1. package/build/encryption/KMS.js +54 -102
  2. package/build/encryption/crypt.d.ts +4 -2
  3. package/build/encryption/crypt.js +76 -91
  4. package/build/encryption/file.d.ts +0 -2
  5. package/build/encryption/file.js +14 -130
  6. package/build/encryption/index.js +162 -334
  7. package/build/encryption/utility.js +7 -10
  8. package/build/errors/app-error.js +9 -27
  9. package/build/errors/axios-error.js +3 -3
  10. package/build/errors/bad-request-error.js +10 -28
  11. package/build/errors/custom-error.js +5 -23
  12. package/build/errors/not-found.js +9 -27
  13. package/build/format-fields/index.d.ts +0 -1
  14. package/build/format-fields/index.js +32 -65
  15. package/build/index.d.ts +1 -4
  16. package/build/index.js +1 -4
  17. package/build/middlewares/error-logger.d.ts +1 -1
  18. package/build/middlewares/error-logger.js +29 -29
  19. package/build/middlewares/redis/request-log.js +24 -74
  20. package/build/query/queryBuilder.d.ts +9 -0
  21. package/build/query/queryBuilder.js +567 -0
  22. package/build/utils/check-error.d.ts +15 -8
  23. package/build/utils/check-error.js +71 -160
  24. package/build/utils/common-util.d.ts +40 -39
  25. package/build/utils/common-util.js +60 -59
  26. package/build/utils/date-util.d.ts +28 -7
  27. package/build/utils/date-util.js +180 -127
  28. package/build/utils/file-util.d.ts +51 -6
  29. package/build/utils/file-util.js +36 -40
  30. package/build/utils/prepare-query.js +70 -43
  31. package/build/utils/project-util.d.ts +43 -5
  32. package/build/utils/project-util.js +176 -121
  33. package/build/utils/query-parser.d.ts +1 -1
  34. package/build/utils/query-parser.js +289 -342
  35. package/build/utils/query-utils.d.ts +2 -2
  36. package/build/utils/query-utils.js +103 -116
  37. package/build/utils/rest-client.js +236 -328
  38. package/build/utils/s3-util.js +238 -469
  39. package/build/utils/token.js +34 -81
  40. package/build/utils/util.d.ts +58 -13
  41. package/build/utils/util.js +424 -494
  42. package/build/utils/uuid-generator.d.ts +20 -1
  43. package/build/utils/uuid-generator.js +111 -47
  44. package/package.json +7 -5
  45. package/build/middlewares/interceptor-logger-new.d.ts +0 -2
  46. package/build/middlewares/interceptor-logger-new.js +0 -53
  47. package/build/middlewares/interceptor-logger.d.ts +0 -2
  48. package/build/middlewares/interceptor-logger.js +0 -52
  49. package/build/utils/query-parser-new.d.ts +0 -1
  50. package/build/utils/query-parser-new.js +0 -541
@@ -1,91 +1,25 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
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
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __rest = (this && this.__rest) || function (s, e) {
50
- var t = {};
51
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
52
- t[p] = s[p];
53
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
54
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
55
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
56
- t[p[i]] = s[p[i]];
57
- }
58
- return t;
59
- };
60
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
61
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
62
- if (ar || !(i in from)) {
63
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
64
- ar[i] = from[i];
65
- }
66
- }
67
- return to.concat(ar || Array.prototype.slice.call(from));
68
- };
69
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
70
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
71
4
  };
72
5
  Object.defineProperty(exports, "__esModule", { value: true });
73
- exports.average = exports.substraction = exports.addition = exports.validateNumbers = exports.checkAndConvertNumber = exports.evaluateCustomSentence = exports.strJoin = exports.markdownToHtml = exports.substr = exports.truncate = exports.titleCase = exports.trim = exports.slugify = exports.upperCase = exports.lowerCase = exports.capitalize = exports.replaceUnderscoreWithSlash = exports.replaceSlashWithUnderscore = exports.toggleConsoleLogs = exports.validateUrl = exports.validateData = exports.fillDefaultValues = exports.replaceValueFromSource = exports.processFieldsInclude = exports.removeMongoDbId = exports.replaceTransferObjectValueIntoExpression = exports.unflattenObject = exports.parseValueFromData = exports.parseJsonString = exports.replaceDataValueIntoExpression = exports.formatCustomCSSClasses = exports.validateAlphanumericString = exports.convertItemToArray = exports.arraysEqual = exports.checkAndCompareValue = exports.restructureData = exports.formatCollectionAndFieldName = exports.cleanCollectionAndFieldName = exports.stringToExpression = exports.expressionToString = exports.getSpecialCharectorReplacedExpression = exports.validateUuidString = exports.validateEmail = exports.dynamicSort = exports.isObject = exports.isEmptyObject = exports.isEmpty = exports.clearSpaceAndReformat = exports.camelize = exports.validateString = void 0;
74
- exports.getAwsSignature = exports.replaceValuesFromRequestMapping = exports.replaceValuesFromObjArr = exports.checkFieldValueType = exports.getPrimaryFieldNameOfDataSource = exports.getFieldSchemaForDataSourcePrimaryId = exports.getMappingObjKey = exports.getItemDataForArrayFields = exports.getFileObjectList = exports.getFindQuery = exports.mergeObjects = exports.dateDifference = exports.formatDate = exports.evaluateJSLogic = exports.evaluateCurrency = exports.evaluateExpression = exports.divide = exports.multiply = void 0;
75
- var drapcode_constant_1 = require("drapcode-constant");
76
- var lodash_1 = __importDefault(require("lodash"));
77
- var showdown_1 = __importDefault(require("showdown"));
78
- var format_fields_1 = require("../format-fields");
79
- var uuid_1 = require("uuid");
80
- var voca_1 = __importDefault(require("voca"));
81
- var numeral_1 = __importDefault(require("numeral"));
82
- var mathjs_1 = __importDefault(require("mathjs"));
83
- var moment_1 = __importDefault(require("moment"));
84
- var mime_types_1 = __importDefault(require("mime-types"));
85
- var uuid_2 = require("uuid");
86
- var aws4_1 = require("aws4");
87
- // TODO: Refactor
88
- var derivedFieldExcludes = [
6
+ exports.multiply = exports.average = exports.substraction = exports.addition = exports.validateNumbers = exports.checkAndConvertNumber = exports.evaluateCustomSentence = exports.strJoin = exports.markdownToHtml = exports.substr = exports.truncate = exports.titleCase = exports.trim = exports.slugify = exports.upperCase = exports.lowerCase = exports.capitalize = exports.replaceUnderscoreWithSlash = exports.replaceSlashWithUnderscore = exports.toggleConsoleLogs = exports.validateUrl = exports.validateData = exports.fillDefaultValues = exports.replaceValueFromSource = exports.processFieldsInclude = exports.removeMongoDbId = exports.replaceTransferObjectValueIntoExpression = exports.unflattenObject = exports.parseValueFromData = exports.parseJsonString = exports.replaceDataValueIntoExpression = exports.formatCustomCSSClasses = exports.validateAlphanumericString = exports.convertItemToArray = exports.arraysEqual = exports.checkAndCompareValue = exports.restructureData = exports.formatCollectionAndFieldName = exports.cleanCollectionAndFieldName = exports.getSpecialCharectorReplacedExpression = exports.validateUuidString = exports.validateEmail = exports.dynamicSort = exports.isObject = exports.isEmptyObject = exports.isEmpty = exports.clearSpaceAndReformat = exports.camelize = exports.validateString = exports.nonFindQuery = void 0;
7
+ exports.getAwsSignature = exports.replaceValuesFromRequestMapping = exports.replaceValuesFromObjArr = exports.checkFieldValueType = exports.getPrimaryFieldNameOfDataSource = exports.getFieldSchemaForDataSourcePrimaryId = exports.getMappingObjKey = exports.getItemDataForArrayFields = exports.getFileObjectList = exports.getFindQuery = exports.mergeObjects = exports.dateDifference = exports.formatDate = exports.evaluateJSLogic = exports.evaluateCurrency = exports.evaluateExpression = exports.divide = void 0;
8
+ const drapcode_constant_1 = require("drapcode-constant");
9
+ const lodash_1 = __importDefault(require("lodash"));
10
+ const showdown_1 = __importDefault(require("showdown"));
11
+ const format_fields_1 = require("../format-fields");
12
+ const uuid_1 = require("uuid");
13
+ const voca_1 = __importDefault(require("voca"));
14
+ const numeral_1 = __importDefault(require("numeral"));
15
+ const mathjs_1 = __importDefault(require("mathjs"));
16
+ const moment_1 = __importDefault(require("moment"));
17
+ const mime_types_1 = __importDefault(require("mime-types"));
18
+ const uuid_2 = require("uuid");
19
+ const aws4_1 = require("aws4");
20
+ exports.nonFindQuery = ["COUNT", "SUM", "AVG", "MIN", "MAX"];
21
+ // Constants
22
+ const DERIVED_FIELD_EXCLUDES = [
89
23
  "formatType",
90
24
  "restToLower",
91
25
  "whitespace",
@@ -113,167 +47,210 @@ var derivedFieldExcludes = [
113
47
  "elementToRender",
114
48
  "indexNum",
115
49
  ];
116
- var environmentFixKey = "environment_variable.";
117
- var tenantFixKey = "current_tenant.";
118
- var CONSOLE_LOG_MODIFIED = false;
119
- var OLD_CONSOLE_LOG = null;
120
- var OLD_CONSOLE_INFO = null;
121
- var validateString = function (str) {
122
- var specialChar = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
123
- var isNumber = str.match(/\d+/g);
124
- if (specialChar.test(str))
50
+ const ENVIRONMENT_FIX_KEY = "environment_variable.";
51
+ const TENANT_FIX_KEY = "current_tenant.";
52
+ const PREFIXES = [
53
+ drapcode_constant_1.CURRENT_USER_LOWER,
54
+ drapcode_constant_1.CURRENT_SESSION,
55
+ drapcode_constant_1.SESSION_STORAGE,
56
+ drapcode_constant_1.LOCAL_STORAGE,
57
+ drapcode_constant_1.COOKIES,
58
+ drapcode_constant_1.FORM_DATA_SESSION,
59
+ drapcode_constant_1.ENVIRONMENT_VARIABLE,
60
+ drapcode_constant_1.PROJECT_CONSTANTS_PREFIX,
61
+ ];
62
+ // State
63
+ const consoleState = {
64
+ isModified: false,
65
+ oldConsoleLog: null,
66
+ oldConsoleInfo: null,
67
+ };
68
+ /**
69
+ * Validates a string for special characters and numbers
70
+ * @param str - The string to validate
71
+ * @returns Error message if invalid, false if valid
72
+ */
73
+ const validateString = (str) => {
74
+ const specialChar = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
75
+ const isNumber = str.match(/\d+/g);
76
+ if (specialChar.test(str)) {
125
77
  return "String should not contain special characters";
126
- if (isNumber)
78
+ }
79
+ if (isNumber) {
127
80
  return "String should not contain any number";
81
+ }
128
82
  return false;
129
83
  };
130
84
  exports.validateString = validateString;
131
- var camelize = function (str) {
85
+ /**
86
+ * Converts a string to camelCase
87
+ * @param str - The string to convert
88
+ * @returns The camelCase string
89
+ */
90
+ const camelize = (str) => {
132
91
  str = (0, exports.clearSpaceAndReformat)(str);
133
- return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
92
+ return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => {
134
93
  return index === 0 ? word.toLowerCase() : word.toUpperCase();
135
94
  });
136
95
  };
137
96
  exports.camelize = camelize;
138
- var clearSpaceAndReformat = function (text, separator) {
97
+ /**
98
+ * Clears spaces and reformats a string
99
+ * @param text - The text to format
100
+ * @param separator - Optional separator to use
101
+ * @returns The formatted string
102
+ */
103
+ const clearSpaceAndReformat = (text, separator) => {
139
104
  if (!text) {
140
105
  return "";
141
106
  }
142
107
  return text
143
108
  .toString()
144
109
  .toLowerCase()
145
- .replace(/\s+/g, separator ? separator : "");
110
+ .replace(/\s+/g, separator ?? "");
146
111
  };
147
112
  exports.clearSpaceAndReformat = clearSpaceAndReformat;
148
- var isEmpty = function (obj) {
113
+ /**
114
+ * Checks if an object is empty
115
+ * @param obj - The object to check
116
+ * @returns True if the object is empty
117
+ */
118
+ const isEmpty = (obj) => {
149
119
  return Object.keys(obj).length === 0;
150
120
  };
151
121
  exports.isEmpty = isEmpty;
152
- var isEmptyObject = function (object) {
122
+ /**
123
+ * Checks if an object is empty and is a plain object
124
+ * @param object - The object to check
125
+ * @returns True if the object is empty and is a plain object
126
+ */
127
+ const isEmptyObject = (object) => {
153
128
  return (0, exports.isEmpty)(object) && object.constructor === Object;
154
129
  };
155
130
  exports.isEmptyObject = isEmptyObject;
156
- var isObject = function (item) {
157
- return item && typeof item === "object" && !Array.isArray(item);
131
+ /**
132
+ * Checks if a value is an object
133
+ * @param item - The value to check
134
+ * @returns True if the value is an object
135
+ */
136
+ const isObject = (item) => {
137
+ return item !== null && typeof item === "object" && !Array.isArray(item);
158
138
  };
159
139
  exports.isObject = isObject;
160
- var dynamicSort = function (property) {
161
- return function (a, b) {
162
- var result = 0;
163
- if (a[property] &&
164
- b[property] &&
165
- a[property] !== "undefined" &&
166
- b[property] !== "undefined") {
167
- if (typeof a[property] === "number" || typeof b[property] === "number") {
168
- result =
169
- a[property] < b[property] ? -1 : a[property] > b[property] ? 1 : 0;
170
- }
171
- else {
172
- result =
173
- a[property].toLowerCase() < b[property].toLowerCase()
174
- ? -1
175
- : a[property].toLowerCase() > b[property].toLowerCase()
176
- ? 1
177
- : 0;
178
- }
140
+ /**
141
+ * Creates a dynamic sort function for an array
142
+ * @param property - The property to sort by
143
+ * @returns A sort function
144
+ */
145
+ const dynamicSort = (property) => {
146
+ return (a, b) => {
147
+ const aValue = a[property];
148
+ const bValue = b[property];
149
+ if (!aValue ||
150
+ !bValue ||
151
+ aValue === "undefined" ||
152
+ bValue === "undefined") {
153
+ return 0;
179
154
  }
180
- else {
181
- result = 0;
155
+ if (typeof aValue === "number" || typeof bValue === "number") {
156
+ return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
182
157
  }
183
- return result;
158
+ const aStr = String(aValue).toLowerCase();
159
+ const bStr = String(bValue).toLowerCase();
160
+ return aStr < bStr ? -1 : aStr > bStr ? 1 : 0;
184
161
  };
185
162
  };
186
163
  exports.dynamicSort = dynamicSort;
187
- var validateEmail = function (email) {
164
+ /**
165
+ * Validates an email address
166
+ * @param email - The email to validate
167
+ * @returns True if the email is valid
168
+ */
169
+ const validateEmail = (email) => {
188
170
  if (!email) {
189
171
  return false;
190
172
  }
191
- var regexCode = new RegExp(/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/);
192
- return email.match(regexCode);
173
+ const regexCode = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/;
174
+ return regexCode.test(email);
193
175
  };
194
176
  exports.validateEmail = validateEmail;
195
- var validateUuidString = function (uuid) {
177
+ /**
178
+ * Validates a UUID string
179
+ * @param uuid - The UUID to validate
180
+ * @returns True if the UUID is valid
181
+ */
182
+ const validateUuidString = (uuid) => {
196
183
  if (!uuid)
197
184
  return false;
198
- var regexCode = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i);
199
- return uuid.match(regexCode);
185
+ const regexCode = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
186
+ return regexCode.test(uuid);
200
187
  };
201
188
  exports.validateUuidString = validateUuidString;
202
- var getSpecialCharectorReplacedExpression = function (expression) {
203
- return expression
204
- .replace(/##@@##@@##/g, " ")
205
- .replace(/##@@##@@@@/g, ">")
206
- .replace(/@@@@##@@@@/g, "<")
207
- .replace(/U\+000A/g, "<br/>");
189
+ const expressionMap = {
190
+ " ": "##@@##@@##",
191
+ ">": "##@@##@@@@",
192
+ "<": "@@@@##@@@@",
193
+ "\n": "U+000A",
194
+ '"': "U+0022",
195
+ "'": "U+0027",
196
+ };
197
+ // Helper to escape special regex characters
198
+ const escapeRegExp = (string) => {
199
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
200
+ };
201
+ // If you want to render HTML line breaks only (like in JSX innerHTML or a browser)
202
+ const getSpecialCharectorReplacedExpression = (expression) => {
203
+ return expressionToString(expression).replace(/\n/g, "<br/>");
208
204
  };
209
205
  exports.getSpecialCharectorReplacedExpression = getSpecialCharectorReplacedExpression;
210
- var expressionToString = function (ex) {
211
- return ex
212
- .replace(/##@@##@@##/g, " ")
213
- .replace(/##@@##@@@@/g, ">")
214
- .replace(/@@@@##@@@@/g, "<")
215
- .replace(/U\+0022/g, '"')
216
- .replace(/U\+0027/g, "'")
217
- .replace(/U\+000A/g, "\n");
218
- };
219
- exports.expressionToString = expressionToString;
220
- var stringToExpression = function (str) {
221
- return str
222
- .replace(/ /g, "##@@##@@##")
223
- .replace(/>/g, "##@@##@@@@")
224
- .replace(/</g, "@@@@##@@@@")
225
- .replace(/\n/g, "U+000A")
226
- .replace(/"/g, "U+0022")
227
- .replace(/'/g, "U+0027");
228
- };
229
- exports.stringToExpression = stringToExpression;
230
- var cleanCollectionAndFieldName = function (str) {
206
+ const expressionToString = (ex) => {
207
+ return Object.entries(expressionMap).reduce((acc, [char, token]) => {
208
+ return acc.replace(new RegExp(escapeRegExp(token), "g"), char);
209
+ }, ex);
210
+ };
211
+ const cleanCollectionAndFieldName = (str) => {
231
212
  str = str.replace(/[^A-Za-z0-9\s_]/, "");
232
213
  return str;
233
214
  };
234
215
  exports.cleanCollectionAndFieldName = cleanCollectionAndFieldName;
235
- var formatCollectionAndFieldName = function (str) {
236
- var updateString = (0, exports.cleanCollectionAndFieldName)(str);
216
+ const formatCollectionAndFieldName = (str) => {
217
+ let updateString = (0, exports.cleanCollectionAndFieldName)(str);
237
218
  return (0, exports.clearSpaceAndReformat)(updateString.trim(), "_");
238
219
  };
239
220
  exports.formatCollectionAndFieldName = formatCollectionAndFieldName;
240
- var restructureData = function (data) {
241
- if (!data)
221
+ const restructureData = (data) => {
222
+ if (data == null)
242
223
  return [];
243
- var dataType = typeof data;
244
224
  if (Array.isArray(data)) {
245
- if (data.length) {
246
- var firstEle = data[0];
247
- if (!firstEle)
248
- return [];
249
- if (typeof firstEle === "string" || typeof firstEle === "number") {
250
- return data.map(function (el) {
251
- return { value: el };
252
- });
253
- }
254
- return data;
225
+ if (!data.length)
226
+ return [];
227
+ let firstEle = data[0];
228
+ if (typeof firstEle === "string" || typeof firstEle === "number") {
229
+ return data.map((el) => {
230
+ value: el;
231
+ });
255
232
  }
256
- return [];
233
+ return data;
257
234
  }
258
235
  else {
259
- if (dataType === "string" || dataType === "number") {
236
+ if (typeof data === "string" || typeof data === "number") {
260
237
  return [{ value: data }];
261
238
  }
262
239
  return [data];
263
240
  }
264
241
  };
265
242
  exports.restructureData = restructureData;
266
- var checkAndCompareValue = function (input1, input2) {
243
+ const checkAndCompareValue = (input1, input2) => {
267
244
  return Array.isArray(input2)
268
- ? (0, exports.arraysEqual)(input1, input2.map(function (key) { return key.value; }))
245
+ ? (0, exports.arraysEqual)(input1, input2.map((key) => key.value))
269
246
  : input1 === input2.value;
270
247
  };
271
248
  exports.checkAndCompareValue = checkAndCompareValue;
272
- var arraysEqual = function (array1, array2) {
249
+ const arraysEqual = (array1, array2) => {
273
250
  if (array1 instanceof Array && array2 instanceof Array) {
274
251
  if (array1.length != array2.length)
275
252
  return false;
276
- for (var i = 0; i < array1.length; i++ // assert each element equal
253
+ for (let i = 0; i < array1.length; i++ // assert each element equal
277
254
  )
278
255
  if (!(0, exports.arraysEqual)(array1[i], array2[i]))
279
256
  return false;
@@ -284,47 +261,47 @@ var arraysEqual = function (array1, array2) {
284
261
  }
285
262
  };
286
263
  exports.arraysEqual = arraysEqual;
287
- var convertItemToArray = function (itemValue) {
264
+ const convertItemToArray = (itemValue) => {
288
265
  if (Array.isArray(itemValue)) {
289
266
  return itemValue;
290
267
  }
291
268
  return itemValue ? [itemValue] : [];
292
269
  };
293
270
  exports.convertItemToArray = convertItemToArray;
294
- var validateAlphanumericString = function (str) {
271
+ const validateAlphanumericString = (str) => {
295
272
  if (/[^A-Za-z0-9\s_]/.test(str)) {
296
273
  return "String should contain only numbers and letters";
297
274
  }
298
275
  return false;
299
276
  };
300
277
  exports.validateAlphanumericString = validateAlphanumericString;
301
- var formatCustomCSSClasses = function (customClasses) {
278
+ const formatCustomCSSClasses = (customClasses) => {
302
279
  if (!customClasses || !Array.isArray(customClasses)) {
303
280
  return "";
304
281
  }
305
- var projectCustomCSSClassesData = "";
306
- customClasses.forEach(function (element) {
282
+ let projectCustomCSSClassesData = "";
283
+ customClasses.forEach((element) => {
307
284
  if (element.classProperty) {
308
- var classWithProp = JSON.stringify(element.classProperty);
309
- var unquotedClassWithProp = classWithProp
285
+ const classWithProp = JSON.stringify(element.classProperty);
286
+ const unquotedClassWithProp = classWithProp
310
287
  .replace(/"([^"]+)"/g, "$1")
311
288
  .split(",")
312
289
  .join(";");
313
- projectCustomCSSClassesData += "".concat(element.class.startsWith(".") ? element.class : "." + element.class).concat(element.pseudoClass ? ":" + element.pseudoClass : "").concat(unquotedClassWithProp, " ");
290
+ projectCustomCSSClassesData += `${element.class.startsWith(".") ? element.class : "." + element.class}${element.pseudoClass ? ":" + element.pseudoClass : ""}${unquotedClassWithProp} `;
314
291
  }
315
292
  });
316
293
  return projectCustomCSSClassesData;
317
294
  };
318
295
  exports.formatCustomCSSClasses = formatCustomCSSClasses;
319
- var replaceDataValueIntoExpression = function (expression, data, user, tenant, userSetting, subTenant, sessionValue, envConstants, sessionFormValue, localStorageValue, cookiesValue) {
320
- var _a;
321
- var contentList = (_a = expression
322
- .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
296
+ const replaceDataValueIntoExpression = (expression, data, user, tenant, userSetting, subTenant, sessionValue, envConstants, sessionFormValue, localStorageValue, cookiesValue) => {
297
+ const contentList = expression
298
+ .match(/{{(.*?)}}/g)
299
+ ?.map((b) => b.replace(/{{(.*?)}}/g, "$1"));
323
300
  console.log("1 replaceDataValueIntoExpression");
324
- contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
325
- var needle = "{{".concat(prop, "}}");
301
+ contentList?.forEach((prop) => {
302
+ const needle = `{{${prop}}}`;
326
303
  console.log("needle :>> ", needle);
327
- var dataOfItem = "";
304
+ let dataOfItem = "";
328
305
  if (prop.includes("current_user")) {
329
306
  console.log("Current User");
330
307
  prop = prop.replace("current_user.", "");
@@ -396,7 +373,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
396
373
  console.log("Environment Variable");
397
374
  prop = prop.replace("environment_variable.", "");
398
375
  if (Object.keys(envConstants).length > 0) {
399
- var selectedConstant = envConstants.find(function (constant) { return constant.name === prop; });
376
+ const selectedConstant = envConstants.find((constant) => constant.name === prop);
400
377
  dataOfItem = selectedConstant ? selectedConstant.value : "";
401
378
  }
402
379
  }
@@ -415,12 +392,12 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
415
392
  return expression;
416
393
  };
417
394
  exports.replaceDataValueIntoExpression = replaceDataValueIntoExpression;
418
- var replaceValueInExpression = function (needle, replacement, expression) {
419
- var match = new RegExp(needle, "ig");
395
+ const replaceValueInExpression = (needle, replacement, expression) => {
396
+ const match = new RegExp(needle, "ig");
420
397
  replacement = replacement ? replacement : "";
421
398
  return expression.replace(match, replacement);
422
399
  };
423
- var parseJsonString = function (str) {
400
+ const parseJsonString = (str) => {
424
401
  try {
425
402
  str = str
426
403
  .replace(/\\n/g, "\\n")
@@ -442,28 +419,28 @@ var parseJsonString = function (str) {
442
419
  }
443
420
  };
444
421
  exports.parseJsonString = parseJsonString;
445
- var parseValueFromData = function (data, fieldName) {
446
- var value = "";
422
+ const parseValueFromData = (data, fieldName) => {
423
+ let value = "";
447
424
  if (fieldName && fieldName.includes(".")) {
448
- var fullNameParts = fieldName.split(".");
449
- var prefix_1 = "";
450
- var stack = data || "";
451
- for (var k = 0; k < fullNameParts.length; k++) {
452
- prefix_1 = fullNameParts[k];
425
+ let fullNameParts = fieldName.split(".");
426
+ let prefix = "";
427
+ let stack = data || "";
428
+ for (let k = 0; k < fullNameParts.length; k++) {
429
+ prefix = fullNameParts[k];
453
430
  if (Array.isArray(stack)) {
454
- stack[prefix_1] = stack.map(function (item) {
455
- if (item[prefix_1])
456
- return item[prefix_1];
431
+ stack[prefix] = stack.map((item) => {
432
+ if (item[prefix])
433
+ return item[prefix];
457
434
  });
458
435
  }
459
- if (stack && stack[prefix_1] === undefined) {
460
- stack[prefix_1] = "";
436
+ if (stack && stack[prefix] === undefined) {
437
+ stack[prefix] = "";
461
438
  }
462
- stack = stack[prefix_1];
439
+ stack = stack[prefix];
463
440
  }
464
441
  value = stack ? stack : "";
465
442
  if (Array.isArray(value)) {
466
- value = value.filter(function () { return true; });
443
+ value = value.filter(() => true);
467
444
  }
468
445
  }
469
446
  else {
@@ -479,8 +456,8 @@ var parseValueFromData = function (data, fieldName) {
479
456
  return value;
480
457
  };
481
458
  exports.parseValueFromData = parseValueFromData;
482
- var unflattenObject = function (obj) {
483
- var result = {}, temp, substrings, property, i;
459
+ const unflattenObject = (obj) => {
460
+ let result = {}, temp, substrings, property, i;
484
461
  for (property in obj) {
485
462
  substrings = property.split(".");
486
463
  temp = result;
@@ -500,14 +477,14 @@ var unflattenObject = function (obj) {
500
477
  return result;
501
478
  };
502
479
  exports.unflattenObject = unflattenObject;
503
- var replaceTransferObjectValueIntoExpression = function (expression, transferObject) {
504
- var _a;
480
+ const replaceTransferObjectValueIntoExpression = (expression, transferObject) => {
505
481
  if (transferObject && Object.keys(transferObject).length > 0) {
506
- var contentList = (_a = expression
507
- .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
508
- contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
509
- var needle = "{{".concat(prop, "}}");
510
- var dataOfItem = "";
482
+ const contentList = expression
483
+ .match(/{{(.*?)}}/g)
484
+ ?.map((b) => b.replace(/{{(.*?)}}/g, "$1"));
485
+ contentList?.forEach((prop) => {
486
+ const needle = `{{${prop}}}`;
487
+ let dataOfItem = "";
511
488
  dataOfItem = transferObject[prop] ? transferObject[prop] : "";
512
489
  expression = dataOfItem
513
490
  ? replaceValueInExpression(needle, dataOfItem, expression)
@@ -517,8 +494,8 @@ var replaceTransferObjectValueIntoExpression = function (expression, transferObj
517
494
  return expression;
518
495
  };
519
496
  exports.replaceTransferObjectValueIntoExpression = replaceTransferObjectValueIntoExpression;
520
- var removeMongoDbId = function (result) {
521
- var removeIdRecursively = function (obj) {
497
+ const removeMongoDbId = function (result) {
498
+ const removeIdRecursively = function (obj) {
522
499
  if (Array.isArray(obj)) {
523
500
  return obj.map(removeIdRecursively);
524
501
  }
@@ -534,69 +511,65 @@ var removeMongoDbId = function (result) {
534
511
  }
535
512
  return obj;
536
513
  };
537
- var moveUuidToTopLevel = function (obj) {
538
- var uuid = obj.uuid, rest = __rest(obj, ["uuid"]);
539
- return __assign({ uuid: uuid }, removeIdRecursively(rest));
514
+ const moveUuidToTopLevel = function (obj) {
515
+ const { uuid, ...rest } = obj;
516
+ return { uuid, ...removeIdRecursively(rest) };
540
517
  };
541
518
  return result.map(moveUuidToTopLevel);
542
519
  };
543
520
  exports.removeMongoDbId = removeMongoDbId;
544
- var processFieldsInclude = function (fieldsInclude) {
545
- var result = fieldsInclude;
546
- var refFieldsInclude = fieldsInclude.filter(function (field) {
547
- return field.startsWith("RF::");
548
- });
549
- var derivedFieldsInclude = fieldsInclude.filter(function (field) {
550
- return field.startsWith("DF::");
551
- });
552
- fieldsInclude = fieldsInclude.filter(function (field) { return !(field.startsWith("RF::") || field.startsWith("DF::")); });
553
- var refFields = processReferenceFieldInclude(refFieldsInclude);
554
- var derivedFields = processDerivedFieldInclude(derivedFieldsInclude);
555
- var extraField = __spreadArray(__spreadArray([], refFields, true), derivedFields, true).filter(function (value, index, array) { return array.indexOf(value) === index; });
556
- result = __spreadArray(__spreadArray([], fieldsInclude, true), extraField, true);
521
+ const processFieldsInclude = (fieldsInclude) => {
522
+ let result = fieldsInclude;
523
+ const refFieldsInclude = fieldsInclude.filter((field) => field.startsWith("RF::"));
524
+ const derivedFieldsInclude = fieldsInclude.filter((field) => field.startsWith("DF::"));
525
+ fieldsInclude = fieldsInclude.filter((field) => !(field.startsWith("RF::") || field.startsWith("DF::")));
526
+ const refFields = processReferenceFieldInclude(refFieldsInclude);
527
+ const derivedFields = processDerivedFieldInclude(derivedFieldsInclude);
528
+ const extraField = [...refFields, ...derivedFields].filter((value, index, array) => array.indexOf(value) === index);
529
+ result = [...fieldsInclude, ...extraField];
557
530
  return result;
558
531
  };
559
532
  exports.processFieldsInclude = processFieldsInclude;
560
- var processReferenceFieldInclude = function (refFieldsInclude) {
561
- var refFields = [];
562
- refFieldsInclude.forEach(function (exField) {
563
- var field = exField.replace("RF::", "");
533
+ const processReferenceFieldInclude = (refFieldsInclude) => {
534
+ let refFields = [];
535
+ refFieldsInclude.forEach((exField) => {
536
+ let field = exField.replace("RF::", "");
564
537
  field = field.split(".")[0];
565
538
  refFields.push(field);
566
539
  });
567
540
  return refFields;
568
541
  };
569
- var processDerivedFieldInclude = function (derivedFieldsInclude) {
570
- var derivedFields = [];
571
- derivedFieldsInclude.forEach(function (exField) {
572
- var derivedFieldStr = exField.replace("DF::", "");
542
+ const processDerivedFieldInclude = (derivedFieldsInclude) => {
543
+ let derivedFields = [];
544
+ derivedFieldsInclude.forEach((exField) => {
545
+ let derivedFieldStr = exField.replace("DF::", "");
573
546
  derivedFieldStr = derivedFieldStr.replaceAll("*#*#", '"');
574
- var derivedFieldObj = JSON.parse(derivedFieldStr);
575
- var fields = [];
576
- derivedFieldObj.args.forEach(function (arg) {
577
- var _a;
547
+ const derivedFieldObj = JSON.parse(derivedFieldStr);
548
+ let fields = [];
549
+ derivedFieldObj.args.forEach((arg) => {
578
550
  if (arg.name === "expression") {
579
- var needleList = (_a = arg.key
580
- .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
581
- var tempFields = (0, exports.processFieldsInclude)(needleList);
582
- fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
551
+ const needleList = arg.key
552
+ .match(/{{(.*?)}}/g)
553
+ ?.map((b) => b.replace(/{{(.*?)}}/g, "$1"));
554
+ const tempFields = (0, exports.processFieldsInclude)(needleList);
555
+ fields = [...fields, ...tempFields];
583
556
  }
584
- else if (!derivedFieldExcludes.includes(arg.name)) {
585
- var tempFields = Array.isArray(arg.key) ? arg.key : [arg.key];
557
+ else if (!DERIVED_FIELD_EXCLUDES.includes(arg.name)) {
558
+ let tempFields = Array.isArray(arg.key) ? arg.key : [arg.key];
586
559
  tempFields = (0, exports.processFieldsInclude)(tempFields);
587
- fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
560
+ fields = [...fields, ...tempFields];
588
561
  }
589
562
  });
590
- derivedFields = __spreadArray(__spreadArray([], derivedFields, true), fields, true);
563
+ derivedFields = [...derivedFields, ...fields];
591
564
  });
592
565
  return derivedFields;
593
566
  };
594
- var replaceValueFromSource = function (variableName, environment, tenant) {
567
+ const replaceValueFromSource = (variableName, environment, tenant) => {
595
568
  if (variableName && typeof variableName === "string") {
596
- if (variableName.startsWith(environmentFixKey)) {
569
+ if (variableName.startsWith(ENVIRONMENT_FIX_KEY)) {
597
570
  return replaceValueFromEnvironment(variableName, environment);
598
571
  }
599
- else if (variableName.startsWith(tenantFixKey)) {
572
+ else if (variableName.startsWith(TENANT_FIX_KEY)) {
600
573
  return replaceValueFromTenant(variableName, tenant);
601
574
  }
602
575
  else {
@@ -608,41 +581,39 @@ var replaceValueFromSource = function (variableName, environment, tenant) {
608
581
  }
609
582
  };
610
583
  exports.replaceValueFromSource = replaceValueFromSource;
611
- var replaceValueFromEnvironment = function (variableName, environment) {
584
+ const replaceValueFromEnvironment = (variableName, environment) => {
612
585
  if (variableName &&
613
586
  typeof variableName === "string" &&
614
- variableName.startsWith(environmentFixKey) &&
587
+ variableName.startsWith(ENVIRONMENT_FIX_KEY) &&
615
588
  environment &&
616
589
  environment.constants) {
617
- var envConstant = environment.constants.find(function (env) { return env.name === variableName.replace(environmentFixKey, ""); });
590
+ const envConstant = environment.constants.find((env) => env.name === variableName.replace(ENVIRONMENT_FIX_KEY, ""));
618
591
  return envConstant.value;
619
592
  }
620
593
  else {
621
594
  return variableName;
622
595
  }
623
596
  };
624
- var replaceValueFromTenant = function (variableName, tenant) {
597
+ const replaceValueFromTenant = (variableName, tenant) => {
625
598
  if (!tenant) {
626
599
  return variableName;
627
600
  }
628
- variableName = variableName.replace(tenantFixKey, "");
601
+ variableName = variableName.replace(TENANT_FIX_KEY, "");
629
602
  return lodash_1.default.get(tenant, variableName);
630
603
  };
631
- var fillDefaultValues = function (collection, itemdata) {
632
- var filledItemData = __assign({}, itemdata);
633
- var fieldsToSkip = drapcode_constant_1.hiddenFormField;
634
- var fieldTypesToSkip = [drapcode_constant_1.FieldTypes.boolean.id];
635
- var allFields = collection.fields.filter(function (field) {
636
- return !fieldsToSkip.includes(field.fieldName) &&
637
- !fieldTypesToSkip.includes(field.type);
638
- });
639
- allFields.forEach(function (field) {
640
- var fieldName = field.fieldName;
604
+ const fillDefaultValues = (collection, itemdata) => {
605
+ const filledItemData = { ...itemdata };
606
+ const fieldsToSkip = drapcode_constant_1.hiddenFormField;
607
+ const fieldTypesToSkip = [drapcode_constant_1.FieldTypes.boolean.id];
608
+ const allFields = collection.fields.filter((field) => !fieldsToSkip.includes(field.fieldName) &&
609
+ !fieldTypesToSkip.includes(field.type));
610
+ allFields.forEach((field) => {
611
+ const fieldName = field.fieldName;
641
612
  if (!(fieldName in filledItemData) ||
642
613
  filledItemData[fieldName] === "" ||
643
614
  filledItemData[fieldName] === 0 ||
644
615
  filledItemData[fieldName] === false) {
645
- var formattedField = JSON.parse(JSON.stringify(field));
616
+ const formattedField = JSON.parse(JSON.stringify(field));
646
617
  if (field.extraFieldSetting &&
647
618
  "defaultValue" in formattedField.extraFieldSetting) {
648
619
  filledItemData[fieldName] = assignFieldValue(formattedField, field, fieldName, filledItemData);
@@ -652,33 +623,30 @@ var fillDefaultValues = function (collection, itemdata) {
652
623
  return filledItemData;
653
624
  };
654
625
  exports.fillDefaultValues = fillDefaultValues;
655
- var assignFieldValue = function (formattedField, field, fieldName, filledItemdata) {
656
- var value = "";
626
+ const assignFieldValue = (formattedField, field, fieldName, filledItemData) => {
627
+ let value = "";
657
628
  value = formattedField.extraFieldSetting
658
629
  ? formattedField.extraFieldSetting.defaultValue
659
- : filledItemdata[fieldName];
630
+ : filledItemData[fieldName];
660
631
  value = (0, format_fields_1.getFormatFieldData)(value, field.type);
661
632
  return value;
662
633
  };
663
- var validateData = function (fields, data) {
664
- var errors = [];
634
+ const validateData = (fields, data) => {
635
+ const errors = [];
665
636
  fields
666
- .filter(function (field) { return field.encrypted === false; })
667
- .forEach(function (field) {
668
- var fieldValue = data[field.fieldName];
669
- if (fieldValue === null ||
670
- fieldValue === undefined ||
671
- typeof fieldValue === "undefined" ||
672
- fieldValue.length <= 0) {
637
+ .filter((field) => field.encrypted === false)
638
+ .forEach((field) => {
639
+ let fieldValue = data[field.fieldName];
640
+ if (fieldValue == null || fieldValue.length <= 0) {
673
641
  return;
674
642
  }
675
- var fieldTitle = field.fieldTitle.en || field.fieldTitle.get("en");
643
+ const fieldTitle = field.fieldTitle.en || field.fieldTitle.get("en");
676
644
  if (field.type === "file" && typeof fieldValue === "string") {
677
645
  try {
678
646
  fieldValue = JSON.parse(fieldValue);
679
647
  }
680
648
  catch (error) {
681
- errors.push("Error parsing ".concat(fieldTitle, ": ").concat(error.message));
649
+ errors.push(`Error parsing ${fieldTitle}: ${error.message}`);
682
650
  return;
683
651
  }
684
652
  }
@@ -687,24 +655,24 @@ var validateData = function (fields, data) {
687
655
  if (typeof fieldValue !== "string" &&
688
656
  typeof fieldValue !== "number" &&
689
657
  Object.prototype.toString.call(fieldValue) !== "[object Date]") {
690
- errors.push("".concat(fieldTitle, " must be a string"));
658
+ errors.push(`${fieldTitle} must be a string`);
691
659
  }
692
660
  break;
693
661
  case "large_text":
694
662
  case "color":
695
663
  if (typeof fieldValue !== "string") {
696
- errors.push("".concat(fieldTitle, " must be a string"));
664
+ errors.push(`${fieldTitle} must be a string`);
697
665
  }
698
666
  break;
699
667
  case "uuid":
700
668
  if (typeof fieldValue !== "string" || !(0, uuid_1.validate)(fieldValue)) {
701
- errors.push("".concat(fieldTitle, " must be a valid UUID string"));
669
+ errors.push(`${fieldTitle} must be a valid UUID string`);
702
670
  }
703
671
  break;
704
672
  case "reference":
705
673
  case "belongsTo":
706
674
  if (Array.isArray(fieldValue)) {
707
- var invalid = fieldValue.some(function (item) {
675
+ const invalid = fieldValue.some((item) => {
708
676
  if (typeof item === "string")
709
677
  return false;
710
678
  if (typeof item === "object" && typeof item.uuid === "string")
@@ -712,14 +680,14 @@ var validateData = function (fields, data) {
712
680
  return true;
713
681
  });
714
682
  if (invalid) {
715
- errors.push("".concat(fieldTitle, " must be an array of UUID strings or objects with a uuid"));
683
+ errors.push(`${fieldTitle} must be an array of UUID strings or objects with a uuid`);
716
684
  }
717
685
  }
718
686
  else {
719
687
  if (!(typeof fieldValue === "string" ||
720
688
  (typeof fieldValue === "object" &&
721
- typeof (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.uuid) === "string"))) {
722
- errors.push("".concat(fieldTitle, " must be a UUID string or an object with a uuid"));
689
+ typeof fieldValue?.uuid === "string"))) {
690
+ errors.push(`${fieldTitle} must be a UUID string or an object with a uuid`);
723
691
  }
724
692
  }
725
693
  break;
@@ -727,27 +695,27 @@ var validateData = function (fields, data) {
727
695
  case "updatedAt":
728
696
  case "date":
729
697
  if (fieldValue && isNaN(Date.parse(fieldValue))) {
730
- errors.push("".concat(fieldTitle, " must be a valid date"));
698
+ errors.push(`${fieldTitle} must be a valid date`);
731
699
  }
732
700
  break;
733
701
  case "boolean":
734
702
  if (typeof fieldValue !== "boolean") {
735
- errors.push("".concat(fieldTitle, " must be a boolean"));
703
+ errors.push(`${fieldTitle} must be a boolean`);
736
704
  }
737
705
  break;
738
706
  case "email":
739
707
  if (typeof fieldValue !== "string" ||
740
708
  !/\S+@\S+\.\S+/.test(fieldValue)) {
741
- errors.push("".concat(fieldTitle, " must be a valid email address"));
709
+ errors.push(`${fieldTitle} must be a valid email address`);
742
710
  break;
743
711
  }
744
712
  break;
745
713
  case "tel":
746
- var removedSpace = fieldValue.replace(/\s+/g, "");
747
- var telPattern = /^\+?(\d{1,3})?[-]?(\(\d{1,4}\)|\d{1,4})[-]?(\d{1,4}[-]?\d{1,4}|\d{7,10})$/;
714
+ const removedSpace = fieldValue.replace(/\s+/g, "");
715
+ const telPattern = /^\+?(\d{1,3})?[-]?(\(\d{1,4}\)|\d{1,4})[-]?(\d{1,4}[-]?\d{1,4}|\d{7,10})$/;
748
716
  if (typeof removedSpace !== "string" ||
749
717
  !telPattern.test(removedSpace)) {
750
- errors.push("".concat(fieldTitle, " must be a valid phone number"));
718
+ errors.push(`${fieldTitle} must be a valid phone number`);
751
719
  }
752
720
  break;
753
721
  case "static_option":
@@ -756,38 +724,36 @@ var validateData = function (fields, data) {
756
724
  break;
757
725
  }
758
726
  else if (Array.isArray(fieldValue)) {
759
- if (fieldValue.some(function (item) { return typeof item !== "string"; })) {
760
- errors.push("".concat(fieldTitle, " must be an array of strings"));
727
+ if (fieldValue.some((item) => typeof item !== "string")) {
728
+ errors.push(`${fieldTitle} must be an array of strings`);
761
729
  }
762
730
  }
763
731
  else {
764
- errors.push("".concat(fieldTitle, " must be a string or an array of strings"));
732
+ errors.push(`${fieldTitle} must be a string or an array of strings`);
765
733
  }
766
734
  break;
767
735
  case "url":
768
736
  if (typeof fieldValue !== "string" || !(0, exports.validateUrl)(fieldValue)) {
769
- errors.push("".concat(fieldTitle, " must be a valid URL"));
737
+ errors.push(`${fieldTitle} must be a valid URL`);
770
738
  }
771
739
  break;
772
740
  case "file":
773
741
  if (Array.isArray(fieldValue)) {
774
- if (fieldValue.some(function (item) {
775
- return typeof item !== "object" ||
776
- !item.key ||
777
- typeof item.key !== "string";
778
- })) {
779
- errors.push("".concat(fieldTitle, " must be an array of objects with 'key' property as string"));
742
+ if (fieldValue.some((item) => typeof item !== "object" ||
743
+ !item.key ||
744
+ typeof item.key !== "string")) {
745
+ errors.push(`${fieldTitle} must be an array of objects with 'key' property as string`);
780
746
  }
781
747
  }
782
748
  else if (typeof fieldValue !== "object" ||
783
749
  !fieldValue.key ||
784
750
  typeof fieldValue.key !== "string") {
785
- errors.push("".concat(fieldTitle, " must be an object with 'key' property as string"));
751
+ errors.push(`${fieldTitle} must be an object with 'key' property as string`);
786
752
  }
787
753
  break;
788
754
  case "number":
789
755
  if (isNaN(Number(fieldValue))) {
790
- errors.push("".concat(fieldTitle, " must be a valid number."));
756
+ errors.push(`${fieldTitle} must be a valid number.`);
791
757
  }
792
758
  break;
793
759
  default:
@@ -795,15 +761,15 @@ var validateData = function (fields, data) {
795
761
  }
796
762
  });
797
763
  if (errors.length > 0) {
798
- return { isValid: false, errors: errors };
764
+ return { isValid: false, errors };
799
765
  }
800
766
  else {
801
767
  return { isValid: true, errors: [] };
802
768
  }
803
769
  };
804
770
  exports.validateData = validateData;
805
- var validateUrl = function (url) {
806
- var pattern = new RegExp("^((ft|htt)ps?:\\/\\/)?" +
771
+ const validateUrl = (url) => {
772
+ const pattern = new RegExp("^((ft|htt)ps?:\\/\\/)?" +
807
773
  "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" +
808
774
  "((\\d{1,3}\\.){3}\\d{1,3}))" +
809
775
  "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" +
@@ -812,58 +778,58 @@ var validateUrl = function (url) {
812
778
  return !!pattern.test(url);
813
779
  };
814
780
  exports.validateUrl = validateUrl;
815
- var toggleConsoleLogs = function (enable) {
816
- if (enable && CONSOLE_LOG_MODIFIED) {
781
+ const toggleConsoleLogs = (enable) => {
782
+ if (enable && consoleState.isModified) {
817
783
  console.log("==> Enabling console log|info...");
818
- if (OLD_CONSOLE_LOG && OLD_CONSOLE_INFO) {
819
- console.log = OLD_CONSOLE_LOG;
820
- console.info = OLD_CONSOLE_INFO;
821
- CONSOLE_LOG_MODIFIED = false;
822
- console.log("==> Enabling Console log modified: ".concat(CONSOLE_LOG_MODIFIED));
784
+ if (consoleState.oldConsoleLog && consoleState.oldConsoleInfo) {
785
+ console.log = consoleState.oldConsoleLog;
786
+ console.info = consoleState.oldConsoleInfo;
787
+ consoleState.isModified = false;
788
+ console.log(`==> Enabling Console log modified: ${consoleState.isModified}`);
823
789
  }
824
790
  }
825
- else if (!enable && !CONSOLE_LOG_MODIFIED) {
826
- OLD_CONSOLE_LOG = console.log;
827
- OLD_CONSOLE_INFO = console.info;
791
+ else if (!enable && !consoleState.isModified) {
792
+ consoleState.oldConsoleLog = console.log;
793
+ consoleState.oldConsoleInfo = console.info;
828
794
  console.log("==> Disabling console log|info...");
829
795
  console.log = function () { };
830
796
  console.info = function () { };
831
- CONSOLE_LOG_MODIFIED = true;
832
- console.log("==> Disabling Console log modified: ".concat(CONSOLE_LOG_MODIFIED));
797
+ consoleState.isModified = true;
798
+ console.log(`==> Disabling Console log modified: ${consoleState.isModified}`);
833
799
  }
834
800
  };
835
801
  exports.toggleConsoleLogs = toggleConsoleLogs;
836
802
  // Utility function to replace '/' with '____'
837
- var replaceSlashWithUnderscore = function (value) {
838
- return value && typeof value === 'string' && value.includes('/')
839
- ? value.replace(/\//g, '____')
803
+ const replaceSlashWithUnderscore = (value) => {
804
+ return value && typeof value === "string" && value.includes("/")
805
+ ? value.replace(/\//g, "____")
840
806
  : value;
841
807
  };
842
808
  exports.replaceSlashWithUnderscore = replaceSlashWithUnderscore;
843
809
  // Utility function to replace '____' with '/'
844
- var replaceUnderscoreWithSlash = function (value) {
845
- return value && typeof value === 'string' && value.includes('____')
846
- ? value.replace(/____/g, '/')
810
+ const replaceUnderscoreWithSlash = (value) => {
811
+ return value && typeof value === "string" && value.includes("____")
812
+ ? value.replace(/____/g, "/")
847
813
  : value;
848
814
  };
849
815
  exports.replaceUnderscoreWithSlash = replaceUnderscoreWithSlash;
850
- var capitalize = function (str, restToLower) {
816
+ const capitalize = function (str, restToLower) {
851
817
  return voca_1.default.capitalize(str, restToLower === "TRUE");
852
818
  };
853
819
  exports.capitalize = capitalize;
854
- var lowerCase = function (subject) {
820
+ const lowerCase = function (subject) {
855
821
  return voca_1.default.lowerCase(subject);
856
822
  };
857
823
  exports.lowerCase = lowerCase;
858
- var upperCase = function (subject) {
824
+ const upperCase = function (subject) {
859
825
  return voca_1.default.upperCase(subject);
860
826
  };
861
827
  exports.upperCase = upperCase;
862
- var slugify = function (subject) {
828
+ const slugify = function (subject) {
863
829
  return voca_1.default.slugify(subject);
864
830
  };
865
831
  exports.slugify = slugify;
866
- var trim = function (subject, whitespace, type) {
832
+ const trim = function (subject, whitespace, type) {
867
833
  if (type === "LEFT") {
868
834
  return voca_1.default.trimLeft(subject, whitespace);
869
835
  }
@@ -875,57 +841,56 @@ var trim = function (subject, whitespace, type) {
875
841
  }
876
842
  };
877
843
  exports.trim = trim;
878
- var titleCase = function (subject, noSplitopt) {
844
+ const titleCase = function (subject, noSplitopt) {
879
845
  return voca_1.default.titleCase(subject, [noSplitopt]);
880
846
  };
881
847
  exports.titleCase = titleCase;
882
- var truncate = function (subject, length, endopt) {
848
+ const truncate = function (subject, length, endopt) {
883
849
  return voca_1.default.truncate(subject, length, endopt);
884
850
  };
885
851
  exports.truncate = truncate;
886
- var substr = function (subject, startLength, endLength) {
852
+ const substr = function (subject, startLength, endLength) {
887
853
  return voca_1.default.substr(subject, startLength, endLength);
888
854
  };
889
855
  exports.substr = substr;
890
- var markdownToHtml = function (subject) {
891
- var converter = new showdown_1.default.Converter({ tables: true });
892
- var html = converter.makeHtml(subject);
856
+ const markdownToHtml = function (subject) {
857
+ const converter = new showdown_1.default.Converter({ tables: true });
858
+ const html = converter.makeHtml(subject);
893
859
  return html;
894
860
  };
895
861
  exports.markdownToHtml = markdownToHtml;
896
- var strJoin = function (dataArr, separator, startString, endString) {
862
+ const strJoin = function (dataArr, separator, startString, endString) {
897
863
  separator = separator ? separator.replace(/##@@##@@##/g, " ") : " ";
898
864
  dataArr = Array.isArray(dataArr) ? dataArr : [dataArr];
899
865
  dataArr = dataArr.filter(Boolean);
900
- return "".concat(startString ? startString.replace(/##@@##@@##/g, " ") + separator : "").concat(dataArr.join(separator)).concat(endString ? separator + endString.replace(/##@@##@@##/g, " ") : "");
866
+ return `${startString ? startString.replace(/##@@##@@##/g, " ") + separator : ""}${dataArr.join(separator)}${endString ? separator + endString.replace(/##@@##@@##/g, " ") : ""}`;
901
867
  };
902
868
  exports.strJoin = strJoin;
903
- var evaluateCustomSentence = function (expression, data, user, envConstants) {
869
+ const evaluateCustomSentence = function (expression, data, user, envConstants) {
904
870
  expression = expression
905
871
  ? (0, exports.getSpecialCharectorReplacedExpression)(expression)
906
872
  : " ";
907
873
  return (0, exports.replaceDataValueIntoExpression)(expression, data, user, {}, {}, {}, {}, envConstants, {}, {}, {});
908
874
  };
909
875
  exports.evaluateCustomSentence = evaluateCustomSentence;
910
- var checkAndConvertNumber = function (number) {
876
+ const checkAndConvertNumber = (number) => {
911
877
  return lodash_1.default.isNumber(number) ? number : Number(number);
912
878
  };
913
879
  exports.checkAndConvertNumber = checkAndConvertNumber;
914
- var validateNumbers = function (numbers) {
915
- return numbers.map(function (number) {
880
+ const validateNumbers = (numbers) => {
881
+ return numbers.map((number) => {
916
882
  return (0, exports.checkAndConvertNumber)(number);
917
883
  });
918
884
  };
919
885
  exports.validateNumbers = validateNumbers;
920
- var addition = function (formatType, _a) {
921
- var numbers = _a.numbers;
886
+ const addition = function (formatType, { numbers }) {
922
887
  try {
923
888
  if (!Array.isArray(numbers)) {
924
889
  numbers = [numbers, 0];
925
890
  }
926
- numbers = numbers.map(function (number) { return (isNaN(number) ? 0 : number); });
927
- var allNumbers = (0, exports.validateNumbers)(numbers);
928
- return (0, numeral_1.default)(mathjs_1.default.add.apply(mathjs_1.default, allNumbers)).format(formatType ? formatType : "00.00");
891
+ numbers = numbers.map((number) => (isNaN(number) ? 0 : number));
892
+ const allNumbers = (0, exports.validateNumbers)(numbers);
893
+ return (0, numeral_1.default)(mathjs_1.default.add(...allNumbers)).format(formatType ? formatType : "00.00");
929
894
  }
930
895
  catch (err) {
931
896
  console.log("🚀 ~ file: util.js:89 ~ addition ~ error:", err);
@@ -933,13 +898,14 @@ var addition = function (formatType, _a) {
933
898
  }
934
899
  };
935
900
  exports.addition = addition;
936
- var substraction = function (formatType, _a) {
937
- var numbers1 = _a.numbers1, numbers2 = _a.numbers2;
901
+ const substraction = function (formatType, { numbers1, numbers2 }) {
938
902
  try {
939
- var actNumber1 = Array.isArray(numbers1)
940
- ? mathjs_1.default.add.apply(mathjs_1.default, numbers1) : numbers1;
941
- var actNumber2 = Array.isArray(numbers2)
942
- ? mathjs_1.default.add.apply(mathjs_1.default, numbers2) : numbers2;
903
+ const actNumber1 = Array.isArray(numbers1)
904
+ ? mathjs_1.default.add(...numbers1)
905
+ : numbers1;
906
+ const actNumber2 = Array.isArray(numbers2)
907
+ ? mathjs_1.default.add(...numbers2)
908
+ : numbers2;
943
909
  return (0, numeral_1.default)(mathjs_1.default.subtract(actNumber1, actNumber2)).format(formatType ? formatType : "00.00");
944
910
  }
945
911
  catch (err) {
@@ -948,15 +914,14 @@ var substraction = function (formatType, _a) {
948
914
  }
949
915
  };
950
916
  exports.substraction = substraction;
951
- var average = function (formatType, _a) {
952
- var numbers = _a.numbers;
917
+ const average = function (formatType, { numbers }) {
953
918
  try {
954
919
  if (!Array.isArray(numbers)) {
955
920
  numbers = [numbers];
956
921
  }
957
- numbers = numbers.map(function (number) { return (isNaN(number) ? 0 : number); });
958
- var allNumbers = (0, exports.validateNumbers)(numbers);
959
- return (0, numeral_1.default)(mathjs_1.default.mean.apply(mathjs_1.default, allNumbers)).format(formatType ? formatType : "00.00");
922
+ numbers = numbers.map((number) => (isNaN(number) ? 0 : number));
923
+ const allNumbers = (0, exports.validateNumbers)(numbers);
924
+ return (0, numeral_1.default)(mathjs_1.default.mean(...allNumbers)).format(formatType ? formatType : "00.00");
960
925
  }
961
926
  catch (err) {
962
927
  console.log("🚀 ~ file: util.js:98 ~ average ~ error:", err);
@@ -964,15 +929,14 @@ var average = function (formatType, _a) {
964
929
  }
965
930
  };
966
931
  exports.average = average;
967
- var multiply = function (formatType, _a) {
968
- var numbers = _a.numbers;
932
+ const multiply = function (formatType, { numbers }) {
969
933
  try {
970
934
  if (!Array.isArray(numbers)) {
971
935
  numbers = [numbers, 1];
972
936
  }
973
- numbers = numbers.map(function (number) { return (isNaN(number) ? 1 : number); });
974
- var allNumbers = (0, exports.validateNumbers)(numbers);
975
- return (0, numeral_1.default)(mathjs_1.default.multiply.apply(mathjs_1.default, allNumbers)).format(formatType ? formatType : "00.00");
937
+ numbers = numbers.map((number) => (isNaN(number) ? 1 : number));
938
+ const allNumbers = (0, exports.validateNumbers)(numbers);
939
+ return (0, numeral_1.default)(mathjs_1.default.multiply(...allNumbers)).format(formatType ? formatType : "00.00");
976
940
  }
977
941
  catch (err) {
978
942
  console.log("🚀 ~ file: util.js:106 ~ multiply ~ error:", err);
@@ -980,11 +944,10 @@ var multiply = function (formatType, _a) {
980
944
  }
981
945
  };
982
946
  exports.multiply = multiply;
983
- var divide = function (formatType, _a) {
984
- var number1 = _a.number1, number2 = _a.number2;
947
+ const divide = function (formatType, { number1, number2 }) {
985
948
  try {
986
- var num1 = (0, exports.checkAndConvertNumber)(number1);
987
- var num2 = (0, exports.checkAndConvertNumber)(number2);
949
+ const num1 = (0, exports.checkAndConvertNumber)(number1);
950
+ const num2 = (0, exports.checkAndConvertNumber)(number2);
988
951
  return (0, numeral_1.default)(mathjs_1.default.divide(num1, num2)).format(formatType ? formatType : "00.00");
989
952
  }
990
953
  catch (err) {
@@ -993,11 +956,11 @@ var divide = function (formatType, _a) {
993
956
  }
994
957
  };
995
958
  exports.divide = divide;
996
- var evaluateExpression = function (expression, data, user, formatType, envConstants) {
959
+ const evaluateExpression = function (expression, data, user, formatType, envConstants) {
997
960
  expression = expression
998
961
  ? (0, exports.getSpecialCharectorReplacedExpression)(expression)
999
962
  : " ";
1000
- var replacedExpression = (0, exports.replaceDataValueIntoExpression)(expression, data, user, {}, {}, {}, {}, envConstants, {}, {}, {});
963
+ const replacedExpression = (0, exports.replaceDataValueIntoExpression)(expression, data, user, {}, {}, {}, {}, envConstants, {}, {}, {});
1001
964
  try {
1002
965
  return (0, numeral_1.default)(mathjs_1.default.evaluate(replacedExpression)).format(formatType ? formatType : "00.00");
1003
966
  }
@@ -1006,26 +969,26 @@ var evaluateExpression = function (expression, data, user, formatType, envConsta
1006
969
  }
1007
970
  };
1008
971
  exports.evaluateExpression = evaluateExpression;
1009
- var evaluateCurrency = function (formatType, subject, currency, position, maxFraction) {
972
+ const evaluateCurrency = function (formatType, subject, currency, position, maxFraction) {
1010
973
  try {
1011
974
  if (!subject)
1012
975
  subject = 0;
1013
976
  if (!maxFraction && maxFraction !== 0)
1014
977
  maxFraction = 2;
1015
- var multiplier = Math.pow(10, maxFraction || 0);
1016
- var digit = Math.round(subject * multiplier) / multiplier;
978
+ const multiplier = Math.pow(10, maxFraction || 0);
979
+ const digit = Math.round(subject * multiplier) / multiplier;
1017
980
  subject = new Intl.NumberFormat(formatType, {
1018
981
  minimumFractionDigits: maxFraction,
1019
982
  }).format(digit);
1020
983
  switch (position) {
1021
984
  case "FRONT":
1022
- return "".concat(currency).concat(subject);
985
+ return `${currency}${subject}`;
1023
986
  case "FRONT_WITH_SPACE":
1024
- return "".concat(currency, " ").concat(subject);
987
+ return `${currency} ${subject}`;
1025
988
  case "BACK":
1026
- return "".concat(subject).concat(currency);
989
+ return `${subject}${currency}`;
1027
990
  case "BACK_WITH_SPACE":
1028
- return "".concat(subject, " ").concat(currency);
991
+ return `${subject} ${currency}`;
1029
992
  default:
1030
993
  return "";
1031
994
  }
@@ -1035,13 +998,13 @@ var evaluateCurrency = function (formatType, subject, currency, position, maxFra
1035
998
  }
1036
999
  };
1037
1000
  exports.evaluateCurrency = evaluateCurrency;
1038
- var evaluateJSLogic = function (expression, data, user, envConstants) {
1001
+ const evaluateJSLogic = function (expression, data, user, envConstants) {
1039
1002
  expression = expression
1040
1003
  ? (0, exports.getSpecialCharectorReplacedExpression)(expression)
1041
1004
  : " ";
1042
- var replacedExpression = (0, exports.replaceDataValueIntoExpression)(expression, data, user, {}, {}, {}, {}, envConstants, {}, {}, {});
1005
+ const replacedExpression = (0, exports.replaceDataValueIntoExpression)(expression, data, user, {}, {}, {}, {}, envConstants, {}, {}, {});
1043
1006
  try {
1044
- var replacedExpressionFunction = new Function(replacedExpression.toString());
1007
+ const replacedExpressionFunction = new Function(replacedExpression.toString());
1045
1008
  return replacedExpressionFunction();
1046
1009
  }
1047
1010
  catch (err) {
@@ -1049,9 +1012,8 @@ var evaluateJSLogic = function (expression, data, user, envConstants) {
1049
1012
  }
1050
1013
  };
1051
1014
  exports.evaluateJSLogic = evaluateJSLogic;
1052
- var formatDate = function (formatType, datentime, timezone, unixType, offset) {
1053
- if (offset === void 0) { offset = false; }
1054
- var formatDateNTime = unixType && unixType === "SEC"
1015
+ const formatDate = function (formatType, datentime, timezone, unixType, offset = false) {
1016
+ let formatDateNTime = unixType && unixType === "SEC"
1055
1017
  ? (0, moment_1.default)(datentime * 1000)
1056
1018
  : (0, moment_1.default)(datentime);
1057
1019
  if (offset) {
@@ -1063,18 +1025,18 @@ var formatDate = function (formatType, datentime, timezone, unixType, offset) {
1063
1025
  return datentime ? formatDateNTime.format(formatType) : "";
1064
1026
  };
1065
1027
  exports.formatDate = formatDate;
1066
- var dateDifference = function (formatType, datentime1, datentime2, timezone) {
1067
- var result = "";
1068
- var dateExist = !datentime1 || !datentime2;
1069
- var firstDate = datentime1 === "CURRENT_DATE_TIME"
1028
+ const dateDifference = (formatType, datentime1, datentime2, timezone) => {
1029
+ let result = "";
1030
+ const dateExist = !datentime1 || !datentime2;
1031
+ const firstDate = datentime1 === "CURRENT_DATE_TIME"
1070
1032
  ? (0, moment_1.default)().utcOffset(timezone)
1071
1033
  : (0, moment_1.default)(datentime1).utcOffset(timezone);
1072
- var secondDate = datentime2 === "CURRENT_DATE_TIME"
1034
+ const secondDate = datentime2 === "CURRENT_DATE_TIME"
1073
1035
  ? (0, moment_1.default)().utcOffset(timezone)
1074
1036
  : (0, moment_1.default)(datentime2).utcOffset(timezone);
1075
- var patterns = formatType.split(",");
1076
- patterns.forEach(function (format, i) {
1077
- var diff = firstDate.diff(secondDate, format);
1037
+ const patterns = formatType.split(",");
1038
+ patterns.forEach((format, i) => {
1039
+ const diff = firstDate.diff(secondDate, format);
1078
1040
  if (diff < 0) {
1079
1041
  firstDate.subtract(diff, format);
1080
1042
  }
@@ -1083,26 +1045,15 @@ var dateDifference = function (formatType, datentime1, datentime2, timezone) {
1083
1045
  }
1084
1046
  result =
1085
1047
  result +
1086
- "".concat(Math.abs(dateExist ? 0 : diff), " ").concat(format.charAt(0).toUpperCase() + format.slice(1)).concat(i === patterns.length - 1 ? "" : ",", " ");
1048
+ `${Math.abs(dateExist ? 0 : diff)} ${format.charAt(0).toUpperCase() + format.slice(1)}${i === patterns.length - 1 ? "" : ","} `;
1087
1049
  });
1088
1050
  return result;
1089
1051
  };
1090
1052
  exports.dateDifference = dateDifference;
1091
- var mergeObjects = function (arrayOfObjects, data, user, tenant, userSetting, subTenant, sessionValue, envConstants, sessionFormValue, dataTransferObject, localStorageValue, cookiesValue) {
1092
- if (data === void 0) { data = null; }
1093
- if (user === void 0) { user = null; }
1094
- if (tenant === void 0) { tenant = null; }
1095
- if (userSetting === void 0) { userSetting = null; }
1096
- if (subTenant === void 0) { subTenant = null; }
1097
- if (sessionValue === void 0) { sessionValue = null; }
1098
- if (envConstants === void 0) { envConstants = null; }
1099
- if (sessionFormValue === void 0) { sessionFormValue = null; }
1100
- if (dataTransferObject === void 0) { dataTransferObject = {}; }
1101
- if (localStorageValue === void 0) { localStorageValue = {}; }
1102
- if (cookiesValue === void 0) { cookiesValue = {}; }
1103
- var object = {};
1104
- arrayOfObjects.map(function (x) {
1105
- var value = x.value;
1053
+ const mergeObjects = (arrayOfObjects, data = null, user = null, tenant = null, userSetting = null, subTenant = null, sessionValue = null, envConstants = null, sessionFormValue = null, dataTransferObject = {}, localStorageValue = {}, cookiesValue = {}) => {
1054
+ let object = {};
1055
+ arrayOfObjects.map((x) => {
1056
+ let value = x.value;
1106
1057
  value = (0, exports.replaceTransferObjectValueIntoExpression)(value, dataTransferObject);
1107
1058
  value =
1108
1059
  data ||
@@ -1123,63 +1074,56 @@ var mergeObjects = function (arrayOfObjects, data, user, tenant, userSetting, su
1123
1074
  return object;
1124
1075
  };
1125
1076
  exports.mergeObjects = mergeObjects;
1126
- var getFindQuery = function (dataSourceType, item, customKey) {
1127
- var _a, _b;
1128
- if (customKey === void 0) { customKey = ""; }
1077
+ const getFindQuery = (item, customKey = "") => {
1129
1078
  if (customKey) {
1130
- return _a = {}, _a[customKey] = item[customKey], _a;
1079
+ return { [customKey]: item[customKey] };
1131
1080
  }
1132
- return _b = {}, _b[drapcode_constant_1.REST_API_PRIMAREY_KEY] = item[drapcode_constant_1.REST_API_PRIMAREY_KEY], _b;
1133
- // switch (dataSourceType) {
1134
- // default:
1135
- // return {};
1136
- // }
1081
+ return { [drapcode_constant_1.REST_API_PRIMAREY_KEY]: item[drapcode_constant_1.REST_API_PRIMAREY_KEY] };
1137
1082
  };
1138
1083
  exports.getFindQuery = getFindQuery;
1139
- var getFileObjectList = function (fileUrls, projectId) {
1140
- var result = [];
1141
- fileUrls.forEach(function (url) {
1142
- var urlSplits = url.split("?")[0].split("/");
1143
- var fileName = urlSplits[urlSplits.length - 1];
1144
- var extension = fileName.substring(fileName.lastIndexOf("."));
1145
- var mimetype = mime_types_1.default.lookup(extension) || "application/octet-stream";
1084
+ const getFileObjectList = (fileUrls, projectId) => {
1085
+ const result = [];
1086
+ fileUrls.forEach((url) => {
1087
+ const urlSplits = url.split("?")[0].split("/");
1088
+ let fileName = urlSplits[urlSplits.length - 1];
1089
+ const extension = fileName.substring(fileName.lastIndexOf("."));
1090
+ let mimetype = mime_types_1.default.lookup(extension) || "application/octet-stream";
1146
1091
  console.log(mimetype);
1147
- var fileJson = {
1092
+ const fileJson = {
1148
1093
  uuid: (0, uuid_2.v4)(),
1149
1094
  originalName: fileName,
1150
1095
  contentType: mime_types_1.default.contentType(mimetype) || "application/octet-stream",
1151
1096
  mimeType: mimetype,
1152
- projectId: projectId,
1097
+ projectId,
1153
1098
  isExternalUrl: true,
1154
- url: url,
1099
+ url,
1155
1100
  };
1156
1101
  result.push(fileJson);
1157
1102
  });
1158
1103
  return result;
1159
1104
  };
1160
1105
  exports.getFileObjectList = getFileObjectList;
1161
- var getItemDataForArrayFields = function (item, dataSourceItemKey) {
1106
+ const getItemDataForArrayFields = (item, dataSourceItemKey) => {
1162
1107
  if (dataSourceItemKey.indexOf(".") != -1) {
1163
- var parentKey = dataSourceItemKey.substring(0, dataSourceItemKey.lastIndexOf("."));
1164
- var parenteItemData = lodash_1.default.get(item, parentKey);
1108
+ const parentKey = dataSourceItemKey.substring(0, dataSourceItemKey.lastIndexOf("."));
1109
+ const parenteItemData = lodash_1.default.get(item, parentKey);
1165
1110
  if (Array.isArray(parenteItemData)) {
1166
- var lastLevelKey_1 = dataSourceItemKey.substring(dataSourceItemKey.lastIndexOf(".") + 1);
1167
- var itemFieldData = parenteItemData.map(function (e) { return e[lastLevelKey_1]; });
1111
+ const lastLevelKey = dataSourceItemKey.substring(dataSourceItemKey.lastIndexOf(".") + 1);
1112
+ const itemFieldData = parenteItemData.map((e) => e[lastLevelKey]);
1168
1113
  return itemFieldData;
1169
1114
  }
1170
1115
  else {
1171
- var itemFieldData = lodash_1.default.get(item, dataSourceItemKey);
1116
+ const itemFieldData = lodash_1.default.get(item, dataSourceItemKey);
1172
1117
  return itemFieldData ? (0, exports.convertItemToArray)(itemFieldData) : [];
1173
1118
  }
1174
1119
  }
1175
1120
  else {
1176
- var itemFieldData = lodash_1.default.get(item, dataSourceItemKey);
1121
+ const itemFieldData = lodash_1.default.get(item, dataSourceItemKey);
1177
1122
  return itemFieldData ? (0, exports.convertItemToArray)(itemFieldData) : [];
1178
1123
  }
1179
1124
  };
1180
1125
  exports.getItemDataForArrayFields = getItemDataForArrayFields;
1181
- var getMappingObjKey = function (collectionMapping, fieldName) {
1182
- if (collectionMapping === void 0) { collectionMapping = {}; }
1126
+ const getMappingObjKey = (collectionMapping = {}, fieldName) => {
1183
1127
  if (typeof collectionMapping[fieldName] === "object") {
1184
1128
  return collectionMapping[fieldName].dataSourceField;
1185
1129
  }
@@ -1188,15 +1132,13 @@ var getMappingObjKey = function (collectionMapping, fieldName) {
1188
1132
  }
1189
1133
  };
1190
1134
  exports.getMappingObjKey = getMappingObjKey;
1191
- var getFieldSchemaForDataSourcePrimaryId = function (dataSourceType) {
1135
+ const getFieldSchemaForDataSourcePrimaryId = () => {
1192
1136
  return getPrimaryFieldSchema("Data Source Rest API Primary Id", drapcode_constant_1.REST_API_PRIMAREY_KEY);
1193
1137
  };
1194
1138
  exports.getFieldSchemaForDataSourcePrimaryId = getFieldSchemaForDataSourcePrimaryId;
1195
- var getPrimaryFieldNameOfDataSource = function (dataSourceType) {
1196
- return drapcode_constant_1.REST_API_PRIMAREY_KEY;
1197
- };
1139
+ const getPrimaryFieldNameOfDataSource = () => drapcode_constant_1.REST_API_PRIMAREY_KEY;
1198
1140
  exports.getPrimaryFieldNameOfDataSource = getPrimaryFieldNameOfDataSource;
1199
- var getPrimaryFieldSchema = function (fieldTitle, fieldName) { return ({
1141
+ const getPrimaryFieldSchema = (fieldTitle, fieldName) => ({
1200
1142
  required: false,
1201
1143
  staticOptions: [],
1202
1144
  unique: true,
@@ -1228,23 +1170,14 @@ var getPrimaryFieldSchema = function (fieldTitle, fieldName) { return ({
1228
1170
  textareaDisplayType: "text-area",
1229
1171
  },
1230
1172
  fieldName: fieldName,
1231
- }); };
1232
- var checkFieldValueType = function (val) {
1233
- return (val.startsWith(drapcode_constant_1.CURRENT_USER_LOWER) ||
1234
- val.startsWith(drapcode_constant_1.CURRENT_SESSION) ||
1235
- val.startsWith(drapcode_constant_1.SESSION_STORAGE) ||
1236
- val.startsWith(drapcode_constant_1.LOCAL_STORAGE) ||
1237
- val.startsWith(drapcode_constant_1.COOKIES) ||
1238
- val.startsWith(drapcode_constant_1.FORM_DATA_SESSION) ||
1239
- val.startsWith(drapcode_constant_1.ENVIRONMENT_VARIABLE) ||
1240
- val.startsWith(drapcode_constant_1.PROJECT_CONSTANTS_PREFIX));
1241
- };
1173
+ });
1174
+ const checkFieldValueType = (val) => PREFIXES.some((prefix) => val.startsWith(prefix));
1242
1175
  exports.checkFieldValueType = checkFieldValueType;
1243
- var replaceValuesFromObjArr = function (dataArr, mappingArray) {
1244
- return dataArr.map(function (data) {
1245
- mappingArray.map(function (mapping) {
1246
- var dataValue = data.value.replace(/{{(.*?)}}/g, "$1");
1247
- var mappingValue = mapping[dataValue];
1176
+ const replaceValuesFromObjArr = (dataArr, mappingArray) => {
1177
+ return dataArr.map((data) => {
1178
+ mappingArray.map((mapping) => {
1179
+ let dataValue = data.value.replace(/{{(.*?)}}/g, "$1");
1180
+ let mappingValue = mapping[dataValue];
1248
1181
  if (mappingValue) {
1249
1182
  data.value = data.value.replace(data.value, mappingValue);
1250
1183
  }
@@ -1253,9 +1186,9 @@ var replaceValuesFromObjArr = function (dataArr, mappingArray) {
1253
1186
  });
1254
1187
  };
1255
1188
  exports.replaceValuesFromObjArr = replaceValuesFromObjArr;
1256
- var replaceValuesFromRequestMapping = function (dataArr, mappingArray) {
1257
- return dataArr.map(function (data) {
1258
- mappingArray.forEach(function (mapping) {
1189
+ const replaceValuesFromRequestMapping = (dataArr, mappingArray) => {
1190
+ return dataArr.map((data) => {
1191
+ mappingArray.forEach((mapping) => {
1259
1192
  if (data.value.includes(mapping.value))
1260
1193
  data.value = data.value.replace(mapping.value, mapping.key);
1261
1194
  });
@@ -1263,29 +1196,26 @@ var replaceValuesFromRequestMapping = function (dataArr, mappingArray) {
1263
1196
  });
1264
1197
  };
1265
1198
  exports.replaceValuesFromRequestMapping = replaceValuesFromRequestMapping;
1266
- var getAwsSignature = function (axiosConfig, awsSignPluginConfig) { return __awaiter(void 0, void 0, void 0, function () {
1267
- var response, method, headers, url, data, parsedUrl, accessKeyId, secretAccessKey, region, service, signedRequest;
1268
- return __generator(this, function (_a) {
1269
- response = { error: "", data: {} };
1270
- method = axiosConfig.method, headers = axiosConfig.headers, url = axiosConfig.url, data = axiosConfig.data;
1271
- parsedUrl = new URL(url);
1272
- if (awsSignPluginConfig) {
1273
- accessKeyId = awsSignPluginConfig.accessKeyId, secretAccessKey = awsSignPluginConfig.secretAccessKey, region = awsSignPluginConfig.region, service = awsSignPluginConfig.service;
1274
- signedRequest = (0, aws4_1.sign)({
1275
- method: method,
1276
- service: service,
1277
- region: region,
1278
- host: parsedUrl.host,
1279
- headers: headers,
1280
- body: data,
1281
- path: parsedUrl.pathname + parsedUrl.search,
1282
- }, { accessKeyId: accessKeyId, secretAccessKey: secretAccessKey });
1283
- response.data = __assign(__assign({}, signedRequest), { url: url });
1284
- return [2 /*return*/, response];
1285
- }
1286
- else
1287
- response.error = "AWS Signature Plugin is not installed.";
1288
- return [2 /*return*/, response];
1289
- });
1290
- }); };
1199
+ const getAwsSignature = async (axiosConfig, awsSignPluginConfig) => {
1200
+ const response = { error: "", data: {} };
1201
+ const { method, headers, url, data } = axiosConfig;
1202
+ const parsedUrl = new URL(url);
1203
+ if (awsSignPluginConfig) {
1204
+ const { accessKeyId, secretAccessKey, region, service } = awsSignPluginConfig;
1205
+ const signedRequest = (0, aws4_1.sign)({
1206
+ method,
1207
+ service,
1208
+ region,
1209
+ host: parsedUrl.host,
1210
+ headers,
1211
+ body: data,
1212
+ path: parsedUrl.pathname + parsedUrl.search,
1213
+ }, { accessKeyId, secretAccessKey });
1214
+ response.data = { ...signedRequest, url };
1215
+ return response;
1216
+ }
1217
+ else
1218
+ response.error = "AWS Signature Plugin is not installed.";
1219
+ return response;
1220
+ };
1291
1221
  exports.getAwsSignature = getAwsSignature;