drapcode-utility 2.7.3 → 2.7.4-preview.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.
- package/build/aws/aws-util.d.ts +6 -0
- package/build/aws/aws-util.d.ts.map +1 -0
- package/build/aws/aws-util.js +34 -0
- package/build/aws/aws-util.js.map +1 -0
- package/build/aws/encryption/KMS.d.ts +9 -0
- package/build/aws/encryption/KMS.d.ts.map +1 -0
- package/build/aws/encryption/KMS.js +65 -0
- package/build/aws/encryption/KMS.js.map +1 -0
- package/build/{encryption → aws/encryption}/crypt.d.ts +1 -0
- package/build/aws/encryption/crypt.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/crypt.js +25 -36
- package/build/aws/encryption/crypt.js.map +1 -0
- package/build/{encryption → aws/encryption}/file.d.ts +2 -1
- package/build/aws/encryption/file.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/file.js +2 -3
- package/build/aws/encryption/file.js.map +1 -0
- package/build/{encryption → aws/encryption}/index.d.ts +4 -3
- package/build/aws/encryption/index.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/index.js +41 -41
- package/build/aws/encryption/index.js.map +1 -0
- package/build/{encryption → aws/encryption}/utility.d.ts +1 -0
- package/build/aws/encryption/utility.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/utility.js +3 -2
- package/build/aws/encryption/utility.js.map +1 -0
- package/build/aws/model.d.ts +30 -0
- package/build/aws/model.d.ts.map +1 -0
- package/build/{encryption → aws}/model.js +1 -0
- package/build/aws/model.js.map +1 -0
- package/build/aws/s3-util.d.ts +36 -0
- package/build/aws/s3-util.d.ts.map +1 -0
- package/build/aws/s3-util.js +198 -0
- package/build/aws/s3-util.js.map +1 -0
- package/build/errors/app-error.d.ts +17 -4
- package/build/errors/app-error.d.ts.map +1 -0
- package/build/errors/app-error.js +184 -6
- package/build/errors/app-error.js.map +1 -0
- package/build/errors/async-handler.d.ts +3 -0
- package/build/errors/async-handler.d.ts.map +1 -0
- package/build/errors/async-handler.js +9 -0
- package/build/errors/async-handler.js.map +1 -0
- package/build/errors/axios-error.d.ts +2 -1
- package/build/errors/axios-error.d.ts.map +1 -0
- package/build/errors/axios-error.js +12 -8
- package/build/errors/axios-error.js.map +1 -0
- package/build/errors/bad-request-error.d.ts +2 -1
- package/build/errors/bad-request-error.d.ts.map +1 -0
- package/build/errors/bad-request-error.js +1 -0
- package/build/errors/bad-request-error.js.map +1 -0
- package/build/errors/custom-error.d.ts +1 -0
- package/build/errors/custom-error.d.ts.map +1 -0
- package/build/errors/custom-error.js +1 -0
- package/build/errors/custom-error.js.map +1 -0
- package/build/errors/error-classes.d.ts +23 -0
- package/build/errors/error-classes.d.ts.map +1 -0
- package/build/errors/error-classes.js +87 -0
- package/build/errors/error-classes.js.map +1 -0
- package/build/errors/error-codes.d.ts +47 -0
- package/build/errors/error-codes.d.ts.map +1 -0
- package/build/errors/error-codes.js +78 -0
- package/build/errors/error-codes.js.map +1 -0
- package/build/errors/error-obj.d.ts +10 -0
- package/build/errors/error-obj.d.ts.map +1 -0
- package/build/errors/error-obj.js +55 -0
- package/build/errors/error-obj.js.map +1 -0
- package/build/errors/get-error-details.d.ts +11 -0
- package/build/errors/get-error-details.d.ts.map +1 -0
- package/build/errors/get-error-details.js +28 -0
- package/build/errors/get-error-details.js.map +1 -0
- package/build/errors/not-found.d.ts +2 -1
- package/build/errors/not-found.d.ts.map +1 -0
- package/build/errors/not-found.js +3 -2
- package/build/errors/not-found.js.map +1 -0
- package/build/errors/wrap-error.d.ts +9 -0
- package/build/errors/wrap-error.d.ts.map +1 -0
- package/build/errors/wrap-error.js +17 -0
- package/build/errors/wrap-error.js.map +1 -0
- package/build/format-fields/index.d.ts +1 -0
- package/build/format-fields/index.d.ts.map +1 -0
- package/build/format-fields/index.js +13 -13
- package/build/format-fields/index.js.map +1 -0
- package/build/index.d.ts +25 -21
- package/build/index.d.ts.map +1 -0
- package/build/index.js +13 -7
- package/build/index.js.map +1 -0
- package/build/middlewares/redis/request-log.d.ts +1 -0
- package/build/middlewares/redis/request-log.d.ts.map +1 -0
- package/build/middlewares/redis/request-log.js +3 -2
- package/build/middlewares/redis/request-log.js.map +1 -0
- package/build/query/queryBuilder.d.ts +1 -0
- package/build/query/queryBuilder.d.ts.map +1 -0
- package/build/query/queryBuilder.js +66 -129
- package/build/query/queryBuilder.js.map +1 -0
- package/build/utils/check-error.d.ts +1 -0
- package/build/utils/check-error.d.ts.map +1 -0
- package/build/utils/check-error.js +14 -15
- package/build/utils/check-error.js.map +1 -0
- package/build/utils/common-util.d.ts +2 -1
- package/build/utils/common-util.d.ts.map +1 -0
- package/build/utils/common-util.js +46 -47
- package/build/utils/common-util.js.map +1 -0
- package/build/utils/date-util.d.ts +1 -0
- package/build/utils/date-util.d.ts.map +1 -0
- package/build/utils/date-util.js +59 -60
- package/build/utils/date-util.js.map +1 -0
- package/build/utils/file-util.d.ts +9 -0
- package/build/utils/file-util.d.ts.map +1 -0
- package/build/utils/file-util.js +120 -9
- package/build/utils/file-util.js.map +1 -0
- package/build/utils/prepare-query.d.ts +1 -0
- package/build/utils/prepare-query.d.ts.map +1 -0
- package/build/utils/prepare-query.js +15 -17
- package/build/utils/prepare-query.js.map +1 -0
- package/build/utils/project-util.d.ts +2 -1
- package/build/utils/project-util.d.ts.map +1 -0
- package/build/utils/project-util.js +45 -50
- package/build/utils/project-util.js.map +1 -0
- package/build/utils/query-parser.d.ts +1 -1
- package/build/utils/query-parser.d.ts.map +1 -0
- package/build/utils/query-parser.js +6 -568
- package/build/utils/query-parser.js.map +1 -0
- package/build/utils/query-utils.d.ts +1 -0
- package/build/utils/query-utils.d.ts.map +1 -0
- package/build/utils/query-utils.js +46 -50
- package/build/utils/query-utils.js.map +1 -0
- package/build/utils/rest-client.d.ts +1 -0
- package/build/utils/rest-client.d.ts.map +1 -0
- package/build/utils/rest-client.js +88 -122
- package/build/utils/rest-client.js.map +1 -0
- package/build/utils/token.d.ts +1 -0
- package/build/utils/token.d.ts.map +1 -0
- package/build/utils/token.js +4 -3
- package/build/utils/token.js.map +1 -0
- package/build/utils/util.d.ts +2 -1
- package/build/utils/util.d.ts.map +1 -0
- package/build/utils/util.js +338 -392
- package/build/utils/util.js.map +1 -0
- package/build/utils/uuid-generator.d.ts +1 -0
- package/build/utils/uuid-generator.d.ts.map +1 -0
- package/build/utils/uuid-generator.js +9 -8
- package/build/utils/uuid-generator.js.map +1 -0
- package/package.json +7 -6
- package/build/encryption/KMS.d.ts +0 -8
- package/build/encryption/KMS.js +0 -67
- package/build/encryption/model.d.ts +0 -17
- package/build/middlewares/error-logger.d.ts +0 -3
- package/build/middlewares/error-logger.js +0 -74
- package/build/utils/s3-util.d.ts +0 -36
- package/build/utils/s3-util.js +0 -275
package/build/utils/util.js
CHANGED
|
@@ -36,8 +36,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
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.
|
|
40
|
-
exports.getArgsFromKey = exports.masking = exports.getLastUpdatedId = exports.getTotalRecords = exports.buildLimitOffsetClause = exports.buildOrderByClause = exports.buildWhereClause = exports.createMySqlConnection = 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 =
|
|
39
|
+
exports.divide = 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.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;
|
|
40
|
+
exports.slugifyFileName = exports.getArgsFromKey = exports.masking = exports.getLastUpdatedId = exports.getTotalRecords = exports.buildLimitOffsetClause = exports.buildOrderByClause = exports.buildWhereClause = exports.createMySqlConnection = 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 = void 0;
|
|
41
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
42
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
41
43
|
const drapcode_constant_1 = require("drapcode-constant");
|
|
42
44
|
const lodash_1 = __importDefault(require("lodash"));
|
|
43
45
|
const showdown_1 = __importDefault(require("showdown"));
|
|
@@ -51,39 +53,40 @@ const mime_types_1 = __importDefault(require("mime-types"));
|
|
|
51
53
|
const uuid_2 = require("uuid");
|
|
52
54
|
const aws4_1 = require("aws4");
|
|
53
55
|
const fs_1 = __importDefault(require("fs"));
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
+
const drapcode_logger_1 = require("drapcode-logger");
|
|
57
|
+
const mysql = require('mysql2/promise');
|
|
58
|
+
exports.nonFindQuery = ['COUNT', 'SUM', 'AVG', 'MIN', 'MAX'];
|
|
56
59
|
// Constants
|
|
57
60
|
const DERIVED_FIELD_EXCLUDES = [
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
61
|
+
'formatType',
|
|
62
|
+
'restToLower',
|
|
63
|
+
'whitespace',
|
|
64
|
+
'type',
|
|
65
|
+
'noSplitopt',
|
|
66
|
+
'length',
|
|
67
|
+
'endopt',
|
|
68
|
+
'startLength',
|
|
69
|
+
'endLength',
|
|
70
|
+
'startString',
|
|
71
|
+
'endString',
|
|
72
|
+
'separator',
|
|
73
|
+
'expression',
|
|
74
|
+
'unixType',
|
|
75
|
+
'currency',
|
|
76
|
+
'maxFraction',
|
|
77
|
+
'position',
|
|
78
|
+
'refField',
|
|
79
|
+
'condition',
|
|
80
|
+
'match',
|
|
81
|
+
'refFieldType',
|
|
82
|
+
'index',
|
|
83
|
+
'positionOfRecords',
|
|
84
|
+
'numberOfRecords',
|
|
85
|
+
'elementToRender',
|
|
86
|
+
'indexNum',
|
|
84
87
|
];
|
|
85
|
-
const ENVIRONMENT_FIX_KEY =
|
|
86
|
-
const TENANT_FIX_KEY =
|
|
88
|
+
const ENVIRONMENT_FIX_KEY = 'environment_variable.';
|
|
89
|
+
const TENANT_FIX_KEY = 'current_tenant.';
|
|
87
90
|
const PREFIXES = [
|
|
88
91
|
drapcode_constant_1.CURRENT_USER_LOWER,
|
|
89
92
|
drapcode_constant_1.CURRENT_SESSION,
|
|
@@ -94,25 +97,17 @@ const PREFIXES = [
|
|
|
94
97
|
drapcode_constant_1.ENVIRONMENT_VARIABLE,
|
|
95
98
|
drapcode_constant_1.PROJECT_CONSTANTS_PREFIX,
|
|
96
99
|
];
|
|
97
|
-
// State
|
|
98
|
-
const consoleState = {
|
|
99
|
-
isModified: false,
|
|
100
|
-
oldConsoleLog: null,
|
|
101
|
-
oldConsoleInfo: null,
|
|
102
|
-
};
|
|
103
100
|
/**
|
|
104
101
|
* Validates a string for special characters and numbers
|
|
105
102
|
* @param str - The string to validate
|
|
106
103
|
* @returns Error message if invalid, false if valid
|
|
107
104
|
*/
|
|
108
105
|
const validateString = (str) => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (specialChar.test(str)) {
|
|
112
|
-
return "String should not contain special characters";
|
|
106
|
+
if (/[`!@#$%^&*()_+=[\]{};':"\\|,.<>/?~-]/.test(str)) {
|
|
107
|
+
return 'String should not contain special characters';
|
|
113
108
|
}
|
|
114
|
-
if (
|
|
115
|
-
return
|
|
109
|
+
if (/\d/.test(str)) {
|
|
110
|
+
return 'String should not contain numbers';
|
|
116
111
|
}
|
|
117
112
|
return false;
|
|
118
113
|
};
|
|
@@ -137,12 +132,12 @@ exports.camelize = camelize;
|
|
|
137
132
|
*/
|
|
138
133
|
const clearSpaceAndReformat = (text, separator) => {
|
|
139
134
|
if (!text) {
|
|
140
|
-
return
|
|
135
|
+
return '';
|
|
141
136
|
}
|
|
142
137
|
return text
|
|
143
138
|
.toString()
|
|
144
139
|
.toLowerCase()
|
|
145
|
-
.replace(/\s+/g, separator ??
|
|
140
|
+
.replace(/\s+/g, separator ?? '');
|
|
146
141
|
};
|
|
147
142
|
exports.clearSpaceAndReformat = clearSpaceAndReformat;
|
|
148
143
|
/**
|
|
@@ -169,7 +164,7 @@ exports.isEmptyObject = isEmptyObject;
|
|
|
169
164
|
* @returns True if the value is an object
|
|
170
165
|
*/
|
|
171
166
|
const isObject = (item) => {
|
|
172
|
-
return item !== null && typeof item ===
|
|
167
|
+
return item !== null && typeof item === 'object' && !Array.isArray(item);
|
|
173
168
|
};
|
|
174
169
|
exports.isObject = isObject;
|
|
175
170
|
/**
|
|
@@ -183,13 +178,13 @@ const dynamicSort = (property) => {
|
|
|
183
178
|
const bValue = b[property];
|
|
184
179
|
if (!aValue ||
|
|
185
180
|
!bValue ||
|
|
186
|
-
aValue ===
|
|
187
|
-
bValue ===
|
|
188
|
-
typeof aValue ===
|
|
189
|
-
typeof bValue ===
|
|
181
|
+
aValue === 'undefined' ||
|
|
182
|
+
bValue === 'undefined' ||
|
|
183
|
+
typeof aValue === 'undefined' ||
|
|
184
|
+
typeof bValue === 'undefined') {
|
|
190
185
|
return 0;
|
|
191
186
|
}
|
|
192
|
-
if (typeof aValue ===
|
|
187
|
+
if (typeof aValue === 'number' || typeof bValue === 'number') {
|
|
193
188
|
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
|
|
194
189
|
}
|
|
195
190
|
const aStr = String(aValue).toLowerCase();
|
|
@@ -223,35 +218,35 @@ const validateUuidString = (uuid) => {
|
|
|
223
218
|
};
|
|
224
219
|
exports.validateUuidString = validateUuidString;
|
|
225
220
|
const expressionMap = {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
'"':
|
|
231
|
-
"'":
|
|
221
|
+
' ': '##@@##@@##',
|
|
222
|
+
'>': '##@@##@@@@',
|
|
223
|
+
'<': '@@@@##@@@@',
|
|
224
|
+
'\n': 'U+000A',
|
|
225
|
+
'"': 'U+0022',
|
|
226
|
+
"'": 'U+0027',
|
|
232
227
|
};
|
|
233
228
|
// Helper to escape special regex characters
|
|
234
229
|
const escapeRegExp = (string) => {
|
|
235
|
-
return string.replace(/[.*+?^${}()|[\]\\]/g,
|
|
230
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
236
231
|
};
|
|
237
232
|
// If you want to render HTML line breaks only (like in JSX innerHTML or a browser)
|
|
238
233
|
const getSpecialCharectorReplacedExpression = (expression) => {
|
|
239
|
-
return expressionToString(expression).replace(/\n/g,
|
|
234
|
+
return expressionToString(expression).replace(/\n/g, '<br/>');
|
|
240
235
|
};
|
|
241
236
|
exports.getSpecialCharectorReplacedExpression = getSpecialCharectorReplacedExpression;
|
|
242
237
|
const expressionToString = (ex) => {
|
|
243
238
|
return Object.entries(expressionMap).reduce((acc, [char, token]) => {
|
|
244
|
-
return acc.replace(new RegExp(escapeRegExp(token),
|
|
239
|
+
return acc.replace(new RegExp(escapeRegExp(token), 'g'), char);
|
|
245
240
|
}, ex);
|
|
246
241
|
};
|
|
247
242
|
const cleanCollectionAndFieldName = (str) => {
|
|
248
|
-
str = str.replace(/[^A-Za-z0-9\s_]/,
|
|
243
|
+
str = str.replace(/[^A-Za-z0-9\s_]/, '');
|
|
249
244
|
return str;
|
|
250
245
|
};
|
|
251
246
|
exports.cleanCollectionAndFieldName = cleanCollectionAndFieldName;
|
|
252
247
|
const formatCollectionAndFieldName = (str) => {
|
|
253
|
-
|
|
254
|
-
return (0, exports.clearSpaceAndReformat)(updateString.trim(),
|
|
248
|
+
const updateString = (0, exports.cleanCollectionAndFieldName)(str);
|
|
249
|
+
return (0, exports.clearSpaceAndReformat)(updateString.trim(), '_');
|
|
255
250
|
};
|
|
256
251
|
exports.formatCollectionAndFieldName = formatCollectionAndFieldName;
|
|
257
252
|
const restructureData = (data) => {
|
|
@@ -260,16 +255,14 @@ const restructureData = (data) => {
|
|
|
260
255
|
if (Array.isArray(data)) {
|
|
261
256
|
if (!data.length)
|
|
262
257
|
return [];
|
|
263
|
-
|
|
264
|
-
if (typeof firstEle ===
|
|
265
|
-
return data.map((el) =>
|
|
266
|
-
value: el;
|
|
267
|
-
});
|
|
258
|
+
const firstEle = data[0];
|
|
259
|
+
if (typeof firstEle === 'string' || typeof firstEle === 'number') {
|
|
260
|
+
return data.map((el) => el);
|
|
268
261
|
}
|
|
269
262
|
return data;
|
|
270
263
|
}
|
|
271
264
|
else {
|
|
272
|
-
if (typeof data ===
|
|
265
|
+
if (typeof data === 'string' || typeof data === 'number') {
|
|
273
266
|
return [{ value: data }];
|
|
274
267
|
}
|
|
275
268
|
return [data];
|
|
@@ -306,88 +299,85 @@ const convertItemToArray = (itemValue) => {
|
|
|
306
299
|
exports.convertItemToArray = convertItemToArray;
|
|
307
300
|
const validateAlphanumericString = (str) => {
|
|
308
301
|
if (/[^A-Za-z0-9\s_]/.test(str)) {
|
|
309
|
-
return
|
|
302
|
+
return 'String should contain only numbers and letters';
|
|
310
303
|
}
|
|
311
304
|
return false;
|
|
312
305
|
};
|
|
313
306
|
exports.validateAlphanumericString = validateAlphanumericString;
|
|
314
307
|
const formatCustomCSSClasses = (customClasses) => {
|
|
315
308
|
if (!customClasses || !Array.isArray(customClasses)) {
|
|
316
|
-
return
|
|
309
|
+
return '';
|
|
317
310
|
}
|
|
318
|
-
let projectCustomCSSClassesData =
|
|
311
|
+
let projectCustomCSSClassesData = '';
|
|
319
312
|
customClasses.forEach((element) => {
|
|
320
313
|
if (element.classProperty) {
|
|
321
314
|
const classWithProp = JSON.stringify(element.classProperty);
|
|
322
315
|
const unquotedClassWithProp = classWithProp
|
|
323
|
-
.replace(/"([^"]+)"/g,
|
|
324
|
-
.split(
|
|
325
|
-
.join(
|
|
326
|
-
projectCustomCSSClassesData += `${element.class.startsWith(
|
|
316
|
+
.replace(/"([^"]+)"/g, '$1')
|
|
317
|
+
.split(',')
|
|
318
|
+
.join(';');
|
|
319
|
+
projectCustomCSSClassesData += `${element.class.startsWith('.') ? element.class : '.' + element.class}${element.pseudoClass ? ':' + element.pseudoClass : ''}${unquotedClassWithProp} `;
|
|
327
320
|
}
|
|
328
321
|
});
|
|
329
322
|
return projectCustomCSSClassesData;
|
|
330
323
|
};
|
|
331
324
|
exports.formatCustomCSSClasses = formatCustomCSSClasses;
|
|
332
325
|
const replaceDataValueIntoExpression = (expression, data, user, tenant, userSetting, subTenant, sessionValue, envConstants, sessionFormValue, localStorageValue, cookiesValue) => {
|
|
333
|
-
const contentList = expression
|
|
334
|
-
.match(/{{(.*?)}}/g)
|
|
335
|
-
?.map((b) => b.replace(/{{(.*?)}}/g, "$1"));
|
|
336
|
-
console.log("1 replaceDataValueIntoExpression");
|
|
326
|
+
const contentList = expression.match(/{{(.*?)}}/g)?.map((b) => b.replace(/{{(.*?)}}/g, '$1'));
|
|
337
327
|
contentList?.forEach((prop) => {
|
|
338
328
|
const needle = `{{${prop}}}`;
|
|
339
329
|
prop = voca_1.default.trim(prop);
|
|
340
|
-
let dataOfItem =
|
|
330
|
+
let dataOfItem = '';
|
|
341
331
|
const isDynamicField = [
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
332
|
+
'RF::',
|
|
333
|
+
'PC::',
|
|
334
|
+
'CC::',
|
|
335
|
+
'current_user_reference_field.',
|
|
336
|
+
'createdBy.',
|
|
337
|
+
'environment_variable.',
|
|
338
|
+
'current_session.',
|
|
339
|
+
'form_data_session.',
|
|
350
340
|
].some((str) => prop.includes(str));
|
|
351
|
-
if (prop.includes(
|
|
352
|
-
prop = prop.replace(
|
|
341
|
+
if (prop.includes('current_user') && user) {
|
|
342
|
+
prop = prop.replace('current_user.', '');
|
|
353
343
|
if (Object.keys(user).length > 0) {
|
|
354
344
|
dataOfItem = (0, exports.parseValueFromData)(user, prop);
|
|
355
345
|
}
|
|
356
346
|
}
|
|
357
|
-
else if (prop.includes(
|
|
358
|
-
prop = prop.replace(
|
|
347
|
+
else if (prop.includes('current_tenant') && tenant) {
|
|
348
|
+
prop = prop.replace('current_tenant.', '');
|
|
359
349
|
if (Object.keys(tenant).length > 0) {
|
|
360
350
|
dataOfItem = (0, exports.parseValueFromData)(tenant, prop);
|
|
361
351
|
}
|
|
362
352
|
}
|
|
363
|
-
else if (prop.includes(
|
|
364
|
-
prop = prop.replace(
|
|
353
|
+
else if (prop.includes('current_settings') && userSetting) {
|
|
354
|
+
prop = prop.replace('current_settings.', '');
|
|
365
355
|
if (Object.keys(userSetting).length > 0) {
|
|
366
356
|
dataOfItem = (0, exports.parseValueFromData)(userSetting, prop);
|
|
367
357
|
}
|
|
368
358
|
}
|
|
369
|
-
else if (prop.includes(
|
|
370
|
-
prop = prop.replace(
|
|
359
|
+
else if (prop.includes('current_sub_tenant') && subTenant) {
|
|
360
|
+
prop = prop.replace('current_sub_tenant.', '');
|
|
371
361
|
if (Object.keys(userSetting).length > 0) {
|
|
372
362
|
dataOfItem = (0, exports.parseValueFromData)(subTenant, prop);
|
|
373
363
|
}
|
|
374
364
|
}
|
|
375
|
-
else if (prop.includes(
|
|
376
|
-
prop = prop.replace(
|
|
365
|
+
else if (prop.includes('SESSION_STORAGE')) {
|
|
366
|
+
prop = prop.replace('SESSION_STORAGE.', '');
|
|
377
367
|
if (Object.keys(sessionValue).length > 0) {
|
|
378
368
|
//Session will contain multi level data
|
|
379
369
|
dataOfItem = lodash_1.default.get(sessionValue, prop);
|
|
380
370
|
}
|
|
381
371
|
}
|
|
382
|
-
else if (prop.includes(
|
|
383
|
-
prop = prop.replace(
|
|
372
|
+
else if (prop.includes('LOCAL_STORAGE')) {
|
|
373
|
+
prop = prop.replace('LOCAL_STORAGE.', '');
|
|
384
374
|
if (Object.keys(localStorageValue).length > 0) {
|
|
385
375
|
//Session will contain multi level data
|
|
386
376
|
dataOfItem = lodash_1.default.get(localStorageValue, prop);
|
|
387
377
|
}
|
|
388
378
|
}
|
|
389
|
-
else if (prop.includes(
|
|
390
|
-
prop = prop.replace(
|
|
379
|
+
else if (prop.includes('COOKIES')) {
|
|
380
|
+
prop = prop.replace('COOKIES.', '');
|
|
391
381
|
if (Object.keys(cookiesValue).length > 0) {
|
|
392
382
|
//Session will contain multi level data
|
|
393
383
|
dataOfItem = lodash_1.default.get(cookiesValue, prop);
|
|
@@ -413,39 +403,39 @@ const replaceDataValueIntoExpression = (expression, data, user, tenant, userSett
|
|
|
413
403
|
};
|
|
414
404
|
exports.replaceDataValueIntoExpression = replaceDataValueIntoExpression;
|
|
415
405
|
const replaceValueInExpression = (needle, replacement, expression) => {
|
|
416
|
-
const match = new RegExp(needle,
|
|
417
|
-
replacement = replacement ? replacement :
|
|
406
|
+
const match = new RegExp(needle, 'ig');
|
|
407
|
+
replacement = replacement ? replacement : '';
|
|
418
408
|
return expression.replace(match, replacement);
|
|
419
409
|
};
|
|
420
410
|
const parseJsonString = (str) => {
|
|
421
411
|
try {
|
|
422
412
|
str = str
|
|
423
|
-
.replace(/\\n/g,
|
|
413
|
+
.replace(/\\n/g, '\\n')
|
|
424
414
|
.replace(/\\'/g, "\\'")
|
|
425
415
|
.replace(/\\"/g, '\\"')
|
|
426
|
-
.replace(/\\&/g,
|
|
427
|
-
.replace(/\\r/g,
|
|
428
|
-
.replace(/\\t/g,
|
|
429
|
-
.replace(/\\b/g,
|
|
430
|
-
.replace(/\\f/g,
|
|
416
|
+
.replace(/\\&/g, '\\&')
|
|
417
|
+
.replace(/\\r/g, '\\r')
|
|
418
|
+
.replace(/\\t/g, '\\t')
|
|
419
|
+
.replace(/\\b/g, '\\b')
|
|
420
|
+
.replace(/\\f/g, '\\f');
|
|
431
421
|
// Remove non-printable and other non-valid JSON characters
|
|
432
422
|
// eslint-disable-next-line no-control-regex
|
|
433
|
-
str = str.replace(/[\u0000-\u0019]+/g,
|
|
423
|
+
str = str.replace(/[\u0000-\u0019]+/g, '');
|
|
434
424
|
return JSON.parse(str);
|
|
435
425
|
}
|
|
436
426
|
catch (e) {
|
|
437
|
-
|
|
427
|
+
drapcode_logger_1.logger.error(e);
|
|
438
428
|
return {};
|
|
439
429
|
}
|
|
440
430
|
};
|
|
441
431
|
exports.parseJsonString = parseJsonString;
|
|
442
432
|
const parseValueFromData = (data, fieldName) => {
|
|
443
|
-
let value =
|
|
444
|
-
let valueIndex =
|
|
445
|
-
let valueIndexFieldName =
|
|
446
|
-
if (fieldName && fieldName.includes(
|
|
447
|
-
|
|
448
|
-
let prefix =
|
|
433
|
+
let value = '';
|
|
434
|
+
let valueIndex = '';
|
|
435
|
+
let valueIndexFieldName = '';
|
|
436
|
+
if (fieldName && fieldName.includes('.')) {
|
|
437
|
+
const fullNameParts = fieldName.split('.');
|
|
438
|
+
let prefix = '';
|
|
449
439
|
let stack = data || {};
|
|
450
440
|
for (let k = 0; k < fullNameParts.length; k++) {
|
|
451
441
|
prefix = fullNameParts[k];
|
|
@@ -456,29 +446,25 @@ const parseValueFromData = (data, fieldName) => {
|
|
|
456
446
|
});
|
|
457
447
|
}
|
|
458
448
|
if (stack && !stack[prefix]) {
|
|
459
|
-
stack[prefix] =
|
|
449
|
+
stack[prefix] = '';
|
|
460
450
|
}
|
|
461
451
|
stack = stack[prefix];
|
|
462
452
|
}
|
|
463
|
-
value = stack ? stack :
|
|
453
|
+
value = stack ? stack : '';
|
|
464
454
|
if (Array.isArray(value)) {
|
|
465
455
|
value = value.filter(() => true);
|
|
466
456
|
}
|
|
467
457
|
}
|
|
468
|
-
else if (fieldName && fieldName.includes(
|
|
458
|
+
else if (fieldName && fieldName.includes('[')) {
|
|
469
459
|
//Todo: Need to Refactor
|
|
470
|
-
|
|
471
|
-
let prefix =
|
|
460
|
+
const fullNameParts = fieldName.split('[');
|
|
461
|
+
let prefix = '';
|
|
472
462
|
let stack = data || {};
|
|
473
463
|
for (let k = 0; k < fullNameParts.length - 1; k++) {
|
|
474
464
|
const cValue = fullNameParts[k];
|
|
475
465
|
const nValue = fullNameParts[k + 1];
|
|
476
|
-
prefix = cValue ? (!cValue.includes(
|
|
477
|
-
valueIndex = nValue
|
|
478
|
-
? nValue.includes("]")
|
|
479
|
-
? nValue.split("]")[0]
|
|
480
|
-
: nValue
|
|
481
|
-
: "";
|
|
466
|
+
prefix = cValue ? (!cValue.includes(']') ? cValue : '') : '';
|
|
467
|
+
valueIndex = nValue ? (nValue.includes(']') ? nValue.split(']')[0] : nValue) : '';
|
|
482
468
|
if (stack && Array.isArray(stack)) {
|
|
483
469
|
stack[prefix] = stack.map((item) => {
|
|
484
470
|
if (item[prefix])
|
|
@@ -486,44 +472,45 @@ const parseValueFromData = (data, fieldName) => {
|
|
|
486
472
|
});
|
|
487
473
|
}
|
|
488
474
|
if (stack && !stack[prefix]) {
|
|
489
|
-
stack[prefix] =
|
|
475
|
+
stack[prefix] = '';
|
|
490
476
|
}
|
|
491
477
|
stack = valueIndex ? stack[prefix][valueIndex] : stack[prefix];
|
|
492
|
-
if (fieldName.includes(
|
|
493
|
-
valueIndexFieldName = nValue.split(
|
|
478
|
+
if (fieldName.includes(']:')) {
|
|
479
|
+
valueIndexFieldName = nValue.split(']:')[1];
|
|
494
480
|
if (valueIndexFieldName) {
|
|
495
481
|
stack = stack[valueIndexFieldName];
|
|
496
482
|
}
|
|
497
483
|
}
|
|
498
484
|
}
|
|
499
|
-
value = stack ? stack :
|
|
485
|
+
value = stack ? stack : '';
|
|
500
486
|
if (Array.isArray(value)) {
|
|
501
487
|
value = value.filter(() => true);
|
|
502
488
|
}
|
|
503
489
|
}
|
|
504
490
|
else {
|
|
505
|
-
value = data ? data[fieldName] :
|
|
491
|
+
value = data ? data[fieldName] : '';
|
|
506
492
|
}
|
|
507
493
|
if (value && Array.isArray(value) && value.length === 1)
|
|
508
494
|
return value[0];
|
|
509
|
-
if (value && Array.isArray(value) && typeof value[0] ===
|
|
510
|
-
return value.join(
|
|
495
|
+
if (value && Array.isArray(value) && typeof value[0] === 'string') {
|
|
496
|
+
return value.join(',');
|
|
511
497
|
}
|
|
512
|
-
if (!value || value ==
|
|
498
|
+
if (!value || value == 'undefined' || value === 'undefined') {
|
|
513
499
|
if (value === 0) {
|
|
514
|
-
value =
|
|
500
|
+
value = '0';
|
|
515
501
|
}
|
|
516
502
|
else {
|
|
517
|
-
value =
|
|
503
|
+
value = '';
|
|
518
504
|
}
|
|
519
505
|
}
|
|
520
506
|
return value;
|
|
521
507
|
};
|
|
522
508
|
exports.parseValueFromData = parseValueFromData;
|
|
523
509
|
const unflattenObject = (obj) => {
|
|
524
|
-
|
|
510
|
+
const result = {};
|
|
511
|
+
let temp, substrings, property, i;
|
|
525
512
|
for (property in obj) {
|
|
526
|
-
substrings = property.split(
|
|
513
|
+
substrings = property.split('.');
|
|
527
514
|
temp = result;
|
|
528
515
|
for (i = 0; i < substrings.length - 1; i++) {
|
|
529
516
|
if (!(substrings[i] in temp)) {
|
|
@@ -543,13 +530,11 @@ const unflattenObject = (obj) => {
|
|
|
543
530
|
exports.unflattenObject = unflattenObject;
|
|
544
531
|
const replaceTransferObjectValueIntoExpression = (expression, transferObject) => {
|
|
545
532
|
if (transferObject && Object.keys(transferObject).length > 0) {
|
|
546
|
-
const contentList = expression
|
|
547
|
-
.match(/{{(.*?)}}/g)
|
|
548
|
-
?.map((b) => b.replace(/{{(.*?)}}/g, "$1"));
|
|
533
|
+
const contentList = expression.match(/{{(.*?)}}/g)?.map((b) => b.replace(/{{(.*?)}}/g, '$1'));
|
|
549
534
|
contentList?.forEach((prop) => {
|
|
550
535
|
const needle = `{{${prop}}}`;
|
|
551
|
-
let dataOfItem =
|
|
552
|
-
dataOfItem = transferObject[prop] ? transferObject[prop] :
|
|
536
|
+
let dataOfItem = '';
|
|
537
|
+
dataOfItem = transferObject[prop] ? transferObject[prop] : '';
|
|
553
538
|
expression = dataOfItem
|
|
554
539
|
? replaceValueInExpression(needle, dataOfItem, expression)
|
|
555
540
|
: expression;
|
|
@@ -563,9 +548,9 @@ const removeMongoDbId = function (result) {
|
|
|
563
548
|
if (Array.isArray(obj)) {
|
|
564
549
|
return obj.map(removeIdRecursively);
|
|
565
550
|
}
|
|
566
|
-
if (typeof obj ===
|
|
567
|
-
for (
|
|
568
|
-
if (key ===
|
|
551
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
552
|
+
for (const key in obj) {
|
|
553
|
+
if (key === '_id') {
|
|
569
554
|
delete obj[key];
|
|
570
555
|
}
|
|
571
556
|
else {
|
|
@@ -584,9 +569,9 @@ const removeMongoDbId = function (result) {
|
|
|
584
569
|
exports.removeMongoDbId = removeMongoDbId;
|
|
585
570
|
const processFieldsInclude = (fieldsInclude) => {
|
|
586
571
|
let result = fieldsInclude;
|
|
587
|
-
const refFieldsInclude = fieldsInclude.filter((field) => field.startsWith(
|
|
588
|
-
const derivedFieldsInclude = fieldsInclude.filter((field) => field.startsWith(
|
|
589
|
-
fieldsInclude = fieldsInclude.filter((field) => !(field.startsWith(
|
|
572
|
+
const refFieldsInclude = fieldsInclude.filter((field) => field.startsWith('RF::'));
|
|
573
|
+
const derivedFieldsInclude = fieldsInclude.filter((field) => field.startsWith('DF::'));
|
|
574
|
+
fieldsInclude = fieldsInclude.filter((field) => !(field.startsWith('RF::') || field.startsWith('DF::')));
|
|
590
575
|
const refFields = processReferenceFieldInclude(refFieldsInclude);
|
|
591
576
|
const derivedFields = processDerivedFieldInclude(derivedFieldsInclude);
|
|
592
577
|
const extraField = [...refFields, ...derivedFields].filter((value, index, array) => array.indexOf(value) === index);
|
|
@@ -595,10 +580,10 @@ const processFieldsInclude = (fieldsInclude) => {
|
|
|
595
580
|
};
|
|
596
581
|
exports.processFieldsInclude = processFieldsInclude;
|
|
597
582
|
const processReferenceFieldInclude = (refFieldsInclude) => {
|
|
598
|
-
|
|
583
|
+
const refFields = [];
|
|
599
584
|
refFieldsInclude.forEach((exField) => {
|
|
600
|
-
let field = exField.replace(
|
|
601
|
-
field = field.split(
|
|
585
|
+
let field = exField.replace('RF::', '');
|
|
586
|
+
field = field.split('.')[0];
|
|
602
587
|
refFields.push(field);
|
|
603
588
|
});
|
|
604
589
|
return refFields;
|
|
@@ -606,15 +591,15 @@ const processReferenceFieldInclude = (refFieldsInclude) => {
|
|
|
606
591
|
const processDerivedFieldInclude = (derivedFieldsInclude) => {
|
|
607
592
|
let derivedFields = [];
|
|
608
593
|
derivedFieldsInclude.forEach((exField) => {
|
|
609
|
-
let derivedFieldStr = exField.replace(
|
|
610
|
-
derivedFieldStr = derivedFieldStr.replaceAll(
|
|
594
|
+
let derivedFieldStr = exField.replace('DF::', '');
|
|
595
|
+
derivedFieldStr = derivedFieldStr.replaceAll('*#*#', '"');
|
|
611
596
|
const derivedFieldObj = JSON.parse(derivedFieldStr);
|
|
612
597
|
let fields = [];
|
|
613
598
|
derivedFieldObj.args.forEach((arg) => {
|
|
614
|
-
if (arg.name ===
|
|
599
|
+
if (arg.name === 'expression') {
|
|
615
600
|
const needleList = arg.key
|
|
616
601
|
.match(/{{(.*?)}}/g)
|
|
617
|
-
?.map((b) => b.replace(/{{(.*?)}}/g,
|
|
602
|
+
?.map((b) => b.replace(/{{(.*?)}}/g, '$1'));
|
|
618
603
|
const tempFields = (0, exports.processFieldsInclude)(needleList);
|
|
619
604
|
fields = [...fields, ...tempFields];
|
|
620
605
|
}
|
|
@@ -629,7 +614,7 @@ const processDerivedFieldInclude = (derivedFieldsInclude) => {
|
|
|
629
614
|
return derivedFields;
|
|
630
615
|
};
|
|
631
616
|
const replaceValueFromSource = (variableName, environment, tenant) => {
|
|
632
|
-
if (variableName && typeof variableName ===
|
|
617
|
+
if (variableName && typeof variableName === 'string') {
|
|
633
618
|
if (variableName.startsWith(ENVIRONMENT_FIX_KEY)) {
|
|
634
619
|
return replaceValueFromEnvironment(variableName, environment);
|
|
635
620
|
}
|
|
@@ -647,11 +632,11 @@ const replaceValueFromSource = (variableName, environment, tenant) => {
|
|
|
647
632
|
exports.replaceValueFromSource = replaceValueFromSource;
|
|
648
633
|
const replaceValueFromEnvironment = (variableName, environment) => {
|
|
649
634
|
if (variableName &&
|
|
650
|
-
typeof variableName ===
|
|
635
|
+
typeof variableName === 'string' &&
|
|
651
636
|
variableName.startsWith(ENVIRONMENT_FIX_KEY) &&
|
|
652
637
|
environment &&
|
|
653
638
|
environment.constants) {
|
|
654
|
-
const envConstant = environment.constants.find((env) => env.name === variableName.replace(ENVIRONMENT_FIX_KEY,
|
|
639
|
+
const envConstant = environment.constants.find((env) => env.name === variableName.replace(ENVIRONMENT_FIX_KEY, ''));
|
|
655
640
|
return envConstant.value;
|
|
656
641
|
}
|
|
657
642
|
else {
|
|
@@ -662,7 +647,7 @@ const replaceValueFromTenant = (variableName, tenant) => {
|
|
|
662
647
|
if (!tenant) {
|
|
663
648
|
return variableName;
|
|
664
649
|
}
|
|
665
|
-
variableName = variableName.replace(TENANT_FIX_KEY,
|
|
650
|
+
variableName = variableName.replace(TENANT_FIX_KEY, '');
|
|
666
651
|
return lodash_1.default.get(tenant, variableName);
|
|
667
652
|
};
|
|
668
653
|
const fillDefaultValues = (collection, itemdata) => {
|
|
@@ -677,20 +662,18 @@ const fillDefaultValues = (collection, itemdata) => {
|
|
|
677
662
|
const isBooleanField = field.type === drapcode_constant_1.FieldTypes.boolean.id;
|
|
678
663
|
const isInvalidBoolean = isBooleanField && ![true, false].includes(currentValue);
|
|
679
664
|
if (!(fieldName in filledItemData) ||
|
|
680
|
-
currentValue ===
|
|
665
|
+
currentValue === '' ||
|
|
681
666
|
currentValue === 0 ||
|
|
682
667
|
(!isBooleanField && currentValue === false) ||
|
|
683
668
|
isEmptyArray ||
|
|
684
669
|
isInvalidBoolean) {
|
|
685
670
|
const formattedField = JSON.parse(JSON.stringify(field));
|
|
686
|
-
if (field.type ===
|
|
671
|
+
if (field.type === 'static_option') {
|
|
687
672
|
if (formattedField.extraFieldSetting?.staticDefaultValue?.length > 0) {
|
|
688
|
-
filledItemData[fieldName] =
|
|
689
|
-
formattedField.extraFieldSetting.staticDefaultValue[0];
|
|
673
|
+
filledItemData[fieldName] = formattedField.extraFieldSetting.staticDefaultValue[0];
|
|
690
674
|
}
|
|
691
675
|
}
|
|
692
|
-
else if (field.extraFieldSetting &&
|
|
693
|
-
"defaultValue" in formattedField.extraFieldSetting) {
|
|
676
|
+
else if (field.extraFieldSetting && 'defaultValue' in formattedField.extraFieldSetting) {
|
|
694
677
|
filledItemData[fieldName] = assignFieldValue(formattedField, field, fieldName, filledItemData);
|
|
695
678
|
}
|
|
696
679
|
}
|
|
@@ -699,13 +682,11 @@ const fillDefaultValues = (collection, itemdata) => {
|
|
|
699
682
|
};
|
|
700
683
|
exports.fillDefaultValues = fillDefaultValues;
|
|
701
684
|
const assignFieldValue = (formattedField, field, fieldName, filledItemData) => {
|
|
702
|
-
let value =
|
|
685
|
+
let value = '';
|
|
703
686
|
value = formattedField.extraFieldSetting
|
|
704
687
|
? formattedField.extraFieldSetting.defaultValue
|
|
705
688
|
: filledItemData[fieldName];
|
|
706
|
-
console.log("\n +==+ value 1:", value);
|
|
707
689
|
value = (0, format_fields_1.getFormatFieldData)(value, field.type);
|
|
708
|
-
console.log("\n +==+ value 2:", value);
|
|
709
690
|
return value;
|
|
710
691
|
};
|
|
711
692
|
const validateData = (fields, data) => {
|
|
@@ -717,8 +698,8 @@ const validateData = (fields, data) => {
|
|
|
717
698
|
if (fieldValue == null || fieldValue.length <= 0) {
|
|
718
699
|
return;
|
|
719
700
|
}
|
|
720
|
-
const fieldTitle = field.fieldTitle.en || field.fieldTitle.get(
|
|
721
|
-
if (field.type ===
|
|
701
|
+
const fieldTitle = field.fieldTitle.en || field.fieldTitle.get('en');
|
|
702
|
+
if (field.type === 'file' && typeof fieldValue === 'string') {
|
|
722
703
|
try {
|
|
723
704
|
fieldValue = JSON.parse(fieldValue);
|
|
724
705
|
}
|
|
@@ -728,31 +709,31 @@ const validateData = (fields, data) => {
|
|
|
728
709
|
}
|
|
729
710
|
}
|
|
730
711
|
switch (field.type) {
|
|
731
|
-
case
|
|
732
|
-
if (typeof fieldValue !==
|
|
733
|
-
typeof fieldValue !==
|
|
734
|
-
Object.prototype.toString.call(fieldValue) !==
|
|
712
|
+
case 'text':
|
|
713
|
+
if (typeof fieldValue !== 'string' &&
|
|
714
|
+
typeof fieldValue !== 'number' &&
|
|
715
|
+
Object.prototype.toString.call(fieldValue) !== '[object Date]') {
|
|
735
716
|
errors.push(`${fieldTitle} must be a string`);
|
|
736
717
|
}
|
|
737
718
|
break;
|
|
738
|
-
case
|
|
739
|
-
case
|
|
740
|
-
if (typeof fieldValue !==
|
|
719
|
+
case 'large_text':
|
|
720
|
+
case 'color':
|
|
721
|
+
if (typeof fieldValue !== 'string') {
|
|
741
722
|
errors.push(`${fieldTitle} must be a string`);
|
|
742
723
|
}
|
|
743
724
|
break;
|
|
744
|
-
case
|
|
745
|
-
if (typeof fieldValue !==
|
|
725
|
+
case 'uuid':
|
|
726
|
+
if (typeof fieldValue !== 'string' || !(0, uuid_1.validate)(fieldValue)) {
|
|
746
727
|
errors.push(`${fieldTitle} must be a valid UUID string`);
|
|
747
728
|
}
|
|
748
729
|
break;
|
|
749
|
-
case
|
|
750
|
-
case
|
|
730
|
+
case 'reference':
|
|
731
|
+
case 'belongsTo':
|
|
751
732
|
if (Array.isArray(fieldValue)) {
|
|
752
733
|
const invalid = fieldValue.some((item) => {
|
|
753
|
-
if (typeof item ===
|
|
734
|
+
if (typeof item === 'string')
|
|
754
735
|
return false;
|
|
755
|
-
if (typeof item ===
|
|
736
|
+
if (typeof item === 'object' && typeof item.uuid === 'string')
|
|
756
737
|
return false;
|
|
757
738
|
return true;
|
|
758
739
|
});
|
|
@@ -761,47 +742,46 @@ const validateData = (fields, data) => {
|
|
|
761
742
|
}
|
|
762
743
|
}
|
|
763
744
|
else {
|
|
764
|
-
if (!(typeof fieldValue ===
|
|
765
|
-
(typeof fieldValue ===
|
|
766
|
-
typeof fieldValue?.uuid === "string"))) {
|
|
745
|
+
if (!(typeof fieldValue === 'string' ||
|
|
746
|
+
(typeof fieldValue === 'object' && typeof fieldValue?.uuid === 'string'))) {
|
|
767
747
|
errors.push(`${fieldTitle} must be a UUID string or an object with a uuid`);
|
|
768
748
|
}
|
|
769
749
|
}
|
|
770
750
|
break;
|
|
771
|
-
case
|
|
772
|
-
case
|
|
773
|
-
case
|
|
751
|
+
case 'createdAt':
|
|
752
|
+
case 'updatedAt':
|
|
753
|
+
case 'date':
|
|
774
754
|
if (fieldValue && isNaN(Date.parse(fieldValue))) {
|
|
775
755
|
errors.push(`${fieldTitle} must be a valid date`);
|
|
776
756
|
}
|
|
777
757
|
break;
|
|
778
|
-
case
|
|
779
|
-
if (typeof fieldValue !==
|
|
758
|
+
case 'boolean':
|
|
759
|
+
if (typeof fieldValue !== 'boolean') {
|
|
780
760
|
errors.push(`${fieldTitle} must be a boolean`);
|
|
781
761
|
}
|
|
782
762
|
break;
|
|
783
|
-
case
|
|
784
|
-
if (typeof fieldValue !==
|
|
785
|
-
!/\S+@\S+\.\S+/.test(fieldValue)) {
|
|
763
|
+
case 'email':
|
|
764
|
+
if (typeof fieldValue !== 'string' || !/\S+@\S+\.\S+/.test(fieldValue)) {
|
|
786
765
|
errors.push(`${fieldTitle} must be a valid email address`);
|
|
787
766
|
break;
|
|
788
767
|
}
|
|
789
768
|
break;
|
|
790
|
-
case
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
!telPattern.test(removedSpace)) {
|
|
795
|
-
|
|
769
|
+
case 'tel':
|
|
770
|
+
{
|
|
771
|
+
const removedSpace = fieldValue.replace(/\s+/g, '');
|
|
772
|
+
const telPattern = /^\+?(\d{1,3})?[-]?(\(\d{1,4}\)|\d{1,4})[-]?(\d{1,4}[-]?\d{1,4}|\d{7,10})$/;
|
|
773
|
+
if (typeof removedSpace !== 'string' || !telPattern.test(removedSpace)) {
|
|
774
|
+
errors.push(`${fieldTitle} must be a valid phone number`);
|
|
775
|
+
}
|
|
796
776
|
}
|
|
797
777
|
break;
|
|
798
|
-
case
|
|
799
|
-
case
|
|
800
|
-
if (typeof fieldValue ===
|
|
778
|
+
case 'static_option':
|
|
779
|
+
case 'dynamic_option':
|
|
780
|
+
if (typeof fieldValue === 'string') {
|
|
801
781
|
break;
|
|
802
782
|
}
|
|
803
783
|
else if (Array.isArray(fieldValue)) {
|
|
804
|
-
if (fieldValue.some((item) => typeof item !==
|
|
784
|
+
if (fieldValue.some((item) => typeof item !== 'string')) {
|
|
805
785
|
errors.push(`${fieldTitle} must be an array of strings`);
|
|
806
786
|
}
|
|
807
787
|
}
|
|
@@ -809,26 +789,24 @@ const validateData = (fields, data) => {
|
|
|
809
789
|
errors.push(`${fieldTitle} must be a string or an array of strings`);
|
|
810
790
|
}
|
|
811
791
|
break;
|
|
812
|
-
case
|
|
813
|
-
if (typeof fieldValue !==
|
|
792
|
+
case 'url':
|
|
793
|
+
if (typeof fieldValue !== 'string' || !(0, exports.validateUrl)(fieldValue)) {
|
|
814
794
|
errors.push(`${fieldTitle} must be a valid URL`);
|
|
815
795
|
}
|
|
816
796
|
break;
|
|
817
|
-
case
|
|
797
|
+
case 'file':
|
|
818
798
|
if (Array.isArray(fieldValue)) {
|
|
819
|
-
if (fieldValue.some((item) => typeof item !==
|
|
820
|
-
!item.key ||
|
|
821
|
-
typeof item.key !== "string")) {
|
|
799
|
+
if (fieldValue.some((item) => typeof item !== 'object' || !item.key || typeof item.key !== 'string')) {
|
|
822
800
|
errors.push(`${fieldTitle} must be an array of objects with 'key' property as string`);
|
|
823
801
|
}
|
|
824
802
|
}
|
|
825
|
-
else if (typeof fieldValue !==
|
|
803
|
+
else if (typeof fieldValue !== 'object' ||
|
|
826
804
|
!fieldValue.key ||
|
|
827
|
-
typeof fieldValue.key !==
|
|
805
|
+
typeof fieldValue.key !== 'string') {
|
|
828
806
|
errors.push(`${fieldTitle} must be an object with 'key' property as string`);
|
|
829
807
|
}
|
|
830
808
|
break;
|
|
831
|
-
case
|
|
809
|
+
case 'number':
|
|
832
810
|
if (isNaN(Number(fieldValue))) {
|
|
833
811
|
errors.push(`${fieldTitle} must be a valid number.`);
|
|
834
812
|
}
|
|
@@ -846,52 +824,31 @@ const validateData = (fields, data) => {
|
|
|
846
824
|
};
|
|
847
825
|
exports.validateData = validateData;
|
|
848
826
|
const validateUrl = (url) => {
|
|
849
|
-
const pattern = new RegExp(
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
827
|
+
const pattern = new RegExp('^((ft|htt)ps?:\\/\\/)?' +
|
|
828
|
+
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' +
|
|
829
|
+
'((\\d{1,3}\\.){3}\\d{1,3}))' +
|
|
830
|
+
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' +
|
|
831
|
+
'(\\?[;&a-z\\d%_.~+=-]*)?' +
|
|
832
|
+
'(\\#[-a-z\\d_]*)?$', 'i');
|
|
855
833
|
return !!pattern.test(url);
|
|
856
834
|
};
|
|
857
835
|
exports.validateUrl = validateUrl;
|
|
858
|
-
const toggleConsoleLogs = (enable) => {
|
|
859
|
-
if (enable && consoleState.isModified) {
|
|
860
|
-
console.log("==> Enabling console log|info...");
|
|
861
|
-
if (consoleState.oldConsoleLog && consoleState.oldConsoleInfo) {
|
|
862
|
-
console.log = consoleState.oldConsoleLog;
|
|
863
|
-
console.info = consoleState.oldConsoleInfo;
|
|
864
|
-
consoleState.isModified = false;
|
|
865
|
-
console.log(`==> Enabling Console log modified: ${consoleState.isModified}`);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
else if (!enable && !consoleState.isModified) {
|
|
869
|
-
consoleState.oldConsoleLog = console.log;
|
|
870
|
-
consoleState.oldConsoleInfo = console.info;
|
|
871
|
-
console.log("==> Disabling console log|info...");
|
|
872
|
-
console.log = function () { };
|
|
873
|
-
console.info = function () { };
|
|
874
|
-
consoleState.isModified = true;
|
|
875
|
-
console.log(`==> Disabling Console log modified: ${consoleState.isModified}`);
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
exports.toggleConsoleLogs = toggleConsoleLogs;
|
|
879
836
|
// Utility function to replace '/' with '____'
|
|
880
837
|
const replaceSlashWithUnderscore = (value) => {
|
|
881
|
-
return value && typeof value ===
|
|
882
|
-
? value.replace(/\//g,
|
|
838
|
+
return value && typeof value === 'string' && value.includes('/')
|
|
839
|
+
? value.replace(/\//g, '____')
|
|
883
840
|
: value;
|
|
884
841
|
};
|
|
885
842
|
exports.replaceSlashWithUnderscore = replaceSlashWithUnderscore;
|
|
886
843
|
// Utility function to replace '____' with '/'
|
|
887
844
|
const replaceUnderscoreWithSlash = (value) => {
|
|
888
|
-
return value && typeof value ===
|
|
889
|
-
? value.replace(/____/g,
|
|
845
|
+
return value && typeof value === 'string' && value.includes('____')
|
|
846
|
+
? value.replace(/____/g, '/')
|
|
890
847
|
: value;
|
|
891
848
|
};
|
|
892
849
|
exports.replaceUnderscoreWithSlash = replaceUnderscoreWithSlash;
|
|
893
850
|
const capitalize = function (str, restToLower) {
|
|
894
|
-
return voca_1.default.capitalize(str, restToLower ===
|
|
851
|
+
return voca_1.default.capitalize(str, restToLower === 'TRUE');
|
|
895
852
|
};
|
|
896
853
|
exports.capitalize = capitalize;
|
|
897
854
|
const lowerCase = function (subject) {
|
|
@@ -907,10 +864,10 @@ const slugify = function (subject) {
|
|
|
907
864
|
};
|
|
908
865
|
exports.slugify = slugify;
|
|
909
866
|
const trim = function (subject, whitespace, type) {
|
|
910
|
-
if (type ===
|
|
867
|
+
if (type === 'LEFT') {
|
|
911
868
|
return voca_1.default.trimLeft(subject, whitespace);
|
|
912
869
|
}
|
|
913
|
-
else if (type ===
|
|
870
|
+
else if (type === 'RIGHT') {
|
|
914
871
|
return voca_1.default.trimRight(subject, whitespace);
|
|
915
872
|
}
|
|
916
873
|
else {
|
|
@@ -937,16 +894,14 @@ const markdownToHtml = function (subject) {
|
|
|
937
894
|
};
|
|
938
895
|
exports.markdownToHtml = markdownToHtml;
|
|
939
896
|
const strJoin = function (dataArr, separator, startString, endString) {
|
|
940
|
-
separator = separator ? separator.replace(/##@@##@@##/g,
|
|
897
|
+
separator = separator ? separator.replace(/##@@##@@##/g, ' ') : ' ';
|
|
941
898
|
dataArr = Array.isArray(dataArr) ? dataArr : [dataArr];
|
|
942
899
|
dataArr = dataArr.filter(Boolean);
|
|
943
|
-
return `${startString ? startString.replace(/##@@##@@##/g,
|
|
900
|
+
return `${startString ? startString.replace(/##@@##@@##/g, ' ') + separator : ''}${dataArr.join(separator)}${endString ? separator + endString.replace(/##@@##@@##/g, ' ') : ''}`;
|
|
944
901
|
};
|
|
945
902
|
exports.strJoin = strJoin;
|
|
946
903
|
const evaluateCustomSentence = function (expression, data, user, envConstants) {
|
|
947
|
-
expression = expression
|
|
948
|
-
? (0, exports.getSpecialCharectorReplacedExpression)(expression)
|
|
949
|
-
: " ";
|
|
904
|
+
expression = expression ? (0, exports.getSpecialCharectorReplacedExpression)(expression) : ' ';
|
|
950
905
|
return (0, exports.replaceDataValueIntoExpression)(expression, data, user, {}, {}, {}, {}, envConstants, {}, {}, {});
|
|
951
906
|
};
|
|
952
907
|
exports.evaluateCustomSentence = evaluateCustomSentence;
|
|
@@ -967,27 +922,23 @@ const addition = function (formatType, { numbers }) {
|
|
|
967
922
|
}
|
|
968
923
|
numbers = numbers.map((number) => (isNaN(number) ? 0 : number));
|
|
969
924
|
const allNumbers = (0, exports.validateNumbers)(numbers);
|
|
970
|
-
return (0, numeral_1.default)(math.sum(allNumbers)).format(formatType ? formatType :
|
|
925
|
+
return (0, numeral_1.default)(math.sum(allNumbers)).format(formatType ? formatType : '00.00');
|
|
971
926
|
}
|
|
972
927
|
catch (err) {
|
|
973
|
-
|
|
974
|
-
return
|
|
928
|
+
drapcode_logger_1.logger.error(`🚀 ~ file: util.js:89 ~ addition ~ error: ${err}`);
|
|
929
|
+
return '';
|
|
975
930
|
}
|
|
976
931
|
};
|
|
977
932
|
exports.addition = addition;
|
|
978
933
|
const substraction = function (formatType, { numbers1, numbers2 }) {
|
|
979
934
|
try {
|
|
980
|
-
const actNumber1 = Array.isArray(numbers1)
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
const actNumber2 = Array.isArray(numbers2)
|
|
984
|
-
? math.sum(...numbers2)
|
|
985
|
-
: numbers2;
|
|
986
|
-
return (0, numeral_1.default)(math.subtract(actNumber1, actNumber2)).format(formatType ? formatType : "00.00");
|
|
935
|
+
const actNumber1 = Array.isArray(numbers1) ? math.sum(...numbers1) : numbers1;
|
|
936
|
+
const actNumber2 = Array.isArray(numbers2) ? math.sum(...numbers2) : numbers2;
|
|
937
|
+
return (0, numeral_1.default)(math.subtract(actNumber1, actNumber2)).format(formatType ? formatType : '00.00');
|
|
987
938
|
}
|
|
988
939
|
catch (err) {
|
|
989
|
-
|
|
990
|
-
return
|
|
940
|
+
drapcode_logger_1.logger.error(`🚀 ~ file: util.js:202 ~ substraction ~ error: ${err}`);
|
|
941
|
+
return '';
|
|
991
942
|
}
|
|
992
943
|
};
|
|
993
944
|
exports.substraction = substraction;
|
|
@@ -998,11 +949,11 @@ const average = function (formatType, { numbers }) {
|
|
|
998
949
|
}
|
|
999
950
|
numbers = numbers.map((number) => (isNaN(number) ? 0 : number));
|
|
1000
951
|
const allNumbers = (0, exports.validateNumbers)(numbers);
|
|
1001
|
-
return (0, numeral_1.default)(math.mean(...allNumbers)).format(formatType ? formatType :
|
|
952
|
+
return (0, numeral_1.default)(math.mean(...allNumbers)).format(formatType ? formatType : '00.00');
|
|
1002
953
|
}
|
|
1003
954
|
catch (err) {
|
|
1004
|
-
|
|
1005
|
-
return
|
|
955
|
+
drapcode_logger_1.logger.error(`🚀 ~ file: util.js:98 ~ average ~ error: ${err}`);
|
|
956
|
+
return '';
|
|
1006
957
|
}
|
|
1007
958
|
};
|
|
1008
959
|
exports.average = average;
|
|
@@ -1013,11 +964,11 @@ const multiply = function (formatType, { numbers }) {
|
|
|
1013
964
|
}
|
|
1014
965
|
numbers = numbers.map((number) => (isNaN(number) ? 1 : number));
|
|
1015
966
|
const allNumbers = (0, exports.validateNumbers)(numbers);
|
|
1016
|
-
return (0, numeral_1.default)(math.prod(...allNumbers)).format(formatType ? formatType :
|
|
967
|
+
return (0, numeral_1.default)(math.prod(...allNumbers)).format(formatType ? formatType : '00.00');
|
|
1017
968
|
}
|
|
1018
969
|
catch (err) {
|
|
1019
|
-
|
|
1020
|
-
return
|
|
970
|
+
drapcode_logger_1.logger.error(`🚀 ~ file: util.js:106 ~ multiply ~ error: ${err}`);
|
|
971
|
+
return '';
|
|
1021
972
|
}
|
|
1022
973
|
};
|
|
1023
974
|
exports.multiply = multiply;
|
|
@@ -1025,24 +976,23 @@ const divide = function (formatType, { number1, number2 }) {
|
|
|
1025
976
|
try {
|
|
1026
977
|
const num1 = (0, exports.checkAndConvertNumber)(number1);
|
|
1027
978
|
const num2 = (0, exports.checkAndConvertNumber)(number2);
|
|
1028
|
-
return (0, numeral_1.default)(math.divide(num1, num2)).format(formatType ? formatType :
|
|
979
|
+
return (0, numeral_1.default)(math.divide(num1, num2)).format(formatType ? formatType : '00.00');
|
|
1029
980
|
}
|
|
1030
981
|
catch (err) {
|
|
1031
|
-
|
|
1032
|
-
return
|
|
982
|
+
drapcode_logger_1.logger.error(`🚀 ~ file: util.js:114 ~ divide ~ error: ${err}`);
|
|
983
|
+
return '';
|
|
1033
984
|
}
|
|
1034
985
|
};
|
|
1035
986
|
exports.divide = divide;
|
|
1036
987
|
const evaluateExpression = function (expression, data, user, formatType, envConstants) {
|
|
1037
|
-
expression = expression
|
|
1038
|
-
? (0, exports.getSpecialCharectorReplacedExpression)(expression)
|
|
1039
|
-
: " ";
|
|
988
|
+
expression = expression ? (0, exports.getSpecialCharectorReplacedExpression)(expression) : ' ';
|
|
1040
989
|
const replacedExpression = (0, exports.replaceDataValueIntoExpression)(expression, data, user, {}, {}, {}, {}, envConstants, {}, {}, {});
|
|
1041
990
|
try {
|
|
1042
|
-
return (0, numeral_1.default)(math.evaluate(replacedExpression)).format(formatType ? formatType :
|
|
991
|
+
return (0, numeral_1.default)(math.evaluate(replacedExpression)).format(formatType ? formatType : '00.00');
|
|
1043
992
|
}
|
|
1044
993
|
catch (err) {
|
|
1045
|
-
|
|
994
|
+
drapcode_logger_1.logger.error(err);
|
|
995
|
+
return '';
|
|
1046
996
|
}
|
|
1047
997
|
};
|
|
1048
998
|
exports.evaluateExpression = evaluateExpression;
|
|
@@ -1057,74 +1007,71 @@ const evaluateCurrency = function (formatType, subject, currency, position, maxF
|
|
|
1057
1007
|
subject = new Intl.NumberFormat(formatType, {
|
|
1058
1008
|
minimumFractionDigits: maxFraction,
|
|
1059
1009
|
}).format(digit);
|
|
1060
|
-
if (currency ===
|
|
1010
|
+
if (currency === 'NONE')
|
|
1061
1011
|
return `${subject}`;
|
|
1062
|
-
if (currency.startsWith(
|
|
1063
|
-
currency = currency.replace(
|
|
1012
|
+
if (currency.startsWith('current_user.')) {
|
|
1013
|
+
currency = currency.replace('current_user.', '');
|
|
1064
1014
|
currency = (0, exports.parseValueFromData)(user, currency);
|
|
1065
1015
|
}
|
|
1066
|
-
else if (currency.startsWith(
|
|
1067
|
-
currency = currency.replace(
|
|
1016
|
+
else if (currency.startsWith('current_tenant.')) {
|
|
1017
|
+
currency = currency.replace('current_tenant.', '');
|
|
1068
1018
|
currency = (0, exports.parseValueFromData)(tenant, currency);
|
|
1069
1019
|
}
|
|
1070
1020
|
switch (position) {
|
|
1071
|
-
case
|
|
1021
|
+
case 'FRONT':
|
|
1072
1022
|
return `${currency}${subject}`;
|
|
1073
|
-
case
|
|
1023
|
+
case 'FRONT_WITH_SPACE':
|
|
1074
1024
|
return `${currency} ${subject}`;
|
|
1075
|
-
case
|
|
1025
|
+
case 'BACK':
|
|
1076
1026
|
return `${subject}${currency}`;
|
|
1077
|
-
case
|
|
1027
|
+
case 'BACK_WITH_SPACE':
|
|
1078
1028
|
return `${subject} ${currency}`;
|
|
1079
1029
|
default:
|
|
1080
|
-
return
|
|
1030
|
+
return '';
|
|
1081
1031
|
}
|
|
1082
1032
|
}
|
|
1083
1033
|
catch (error) {
|
|
1084
|
-
|
|
1085
|
-
return
|
|
1034
|
+
drapcode_logger_1.logger.error(error);
|
|
1035
|
+
return '';
|
|
1086
1036
|
}
|
|
1087
1037
|
};
|
|
1088
1038
|
exports.evaluateCurrency = evaluateCurrency;
|
|
1089
1039
|
const evaluateJSLogic = function (expression, data, user, envConstants) {
|
|
1090
|
-
expression = expression
|
|
1091
|
-
? (0, exports.getSpecialCharectorReplacedExpression)(expression)
|
|
1092
|
-
: " ";
|
|
1040
|
+
expression = expression ? (0, exports.getSpecialCharectorReplacedExpression)(expression) : ' ';
|
|
1093
1041
|
// Changing <br/> to /n for js code
|
|
1094
|
-
expression = expression.replace(/<br\s*\/?>/g,
|
|
1042
|
+
expression = expression.replace(/<br\s*\/?>/g, '\n');
|
|
1095
1043
|
const replacedExpression = (0, exports.replaceDataValueIntoExpression)(expression, data, user, {}, {}, {}, {}, envConstants, {}, {}, {});
|
|
1096
1044
|
try {
|
|
1097
1045
|
const replacedExpressionFunction = new Function(replacedExpression.toString());
|
|
1098
1046
|
return replacedExpressionFunction();
|
|
1099
1047
|
}
|
|
1100
1048
|
catch (err) {
|
|
1101
|
-
|
|
1049
|
+
drapcode_logger_1.logger.error(err);
|
|
1050
|
+
return '';
|
|
1102
1051
|
}
|
|
1103
1052
|
};
|
|
1104
1053
|
exports.evaluateJSLogic = evaluateJSLogic;
|
|
1105
1054
|
const formatDate = function (formatType, datentime, timezone, unixType, offset = false) {
|
|
1106
|
-
let formatDateNTime = unixType && unixType ===
|
|
1107
|
-
? moment_1.default.utc(datentime * 1000)
|
|
1108
|
-
: moment_1.default.utc(datentime);
|
|
1055
|
+
let formatDateNTime = unixType && unixType === 'SEC' ? moment_1.default.utc(datentime * 1000) : moment_1.default.utc(datentime);
|
|
1109
1056
|
if (offset) {
|
|
1110
1057
|
formatDateNTime = formatDateNTime.utcOffset(timezone);
|
|
1111
1058
|
}
|
|
1112
|
-
if (formatType ===
|
|
1113
|
-
return datentime ? formatDateNTime.fromNow() :
|
|
1059
|
+
if (formatType === 'FROM_NOW') {
|
|
1060
|
+
return datentime ? formatDateNTime.fromNow() : '';
|
|
1114
1061
|
}
|
|
1115
|
-
return datentime ? formatDateNTime.format(formatType) :
|
|
1062
|
+
return datentime ? formatDateNTime.format(formatType) : '';
|
|
1116
1063
|
};
|
|
1117
1064
|
exports.formatDate = formatDate;
|
|
1118
1065
|
const dateDifference = (formatType, datentime1, datentime2, timezone, dateFormat) => {
|
|
1119
|
-
let result =
|
|
1066
|
+
let result = '';
|
|
1120
1067
|
const dateExist = !datentime1 || !datentime2;
|
|
1121
|
-
const firstDate = datentime1 ===
|
|
1068
|
+
const firstDate = datentime1 === 'CURRENT_DATE_TIME'
|
|
1122
1069
|
? (0, moment_1.default)().utcOffset(timezone)
|
|
1123
1070
|
: (0, moment_1.default)(datentime1, dateFormat).utcOffset(timezone);
|
|
1124
|
-
const secondDate = datentime2 ===
|
|
1071
|
+
const secondDate = datentime2 === 'CURRENT_DATE_TIME'
|
|
1125
1072
|
? (0, moment_1.default)().utcOffset(timezone)
|
|
1126
1073
|
: (0, moment_1.default)(datentime2, dateFormat).utcOffset(timezone);
|
|
1127
|
-
const patterns = formatType.split(
|
|
1074
|
+
const patterns = formatType.split(',');
|
|
1128
1075
|
patterns.forEach((format, i) => {
|
|
1129
1076
|
const diff = firstDate.diff(secondDate, format);
|
|
1130
1077
|
if (diff < 0) {
|
|
@@ -1135,13 +1082,13 @@ const dateDifference = (formatType, datentime1, datentime2, timezone, dateFormat
|
|
|
1135
1082
|
}
|
|
1136
1083
|
result =
|
|
1137
1084
|
result +
|
|
1138
|
-
`${Math.abs(dateExist ? 0 : diff)} ${format.charAt(0).toUpperCase() + format.slice(1)}${i === patterns.length - 1 ?
|
|
1085
|
+
`${Math.abs(dateExist ? 0 : diff)} ${format.charAt(0).toUpperCase() + format.slice(1)}${i === patterns.length - 1 ? '' : ','} `;
|
|
1139
1086
|
});
|
|
1140
1087
|
return result;
|
|
1141
1088
|
};
|
|
1142
1089
|
exports.dateDifference = dateDifference;
|
|
1143
1090
|
const mergeObjects = (arrayOfObjects, data = null, user = null, tenant = null, userSetting = null, subTenant = null, sessionValue = null, envConstants = null, sessionFormValue = null, dataTransferObject = {}, localStorageValue = {}, cookiesValue = {}) => {
|
|
1144
|
-
|
|
1091
|
+
const object = {};
|
|
1145
1092
|
arrayOfObjects.map((x) => {
|
|
1146
1093
|
let value = x.value;
|
|
1147
1094
|
value = (0, exports.replaceTransferObjectValueIntoExpression)(value, dataTransferObject);
|
|
@@ -1160,11 +1107,10 @@ const mergeObjects = (arrayOfObjects, data = null, user = null, tenant = null, u
|
|
|
1160
1107
|
: value;
|
|
1161
1108
|
object[x.key] = value;
|
|
1162
1109
|
});
|
|
1163
|
-
console.log("object", object);
|
|
1164
1110
|
return object;
|
|
1165
1111
|
};
|
|
1166
1112
|
exports.mergeObjects = mergeObjects;
|
|
1167
|
-
const getFindQuery = (item, customKey =
|
|
1113
|
+
const getFindQuery = (item, customKey = '') => {
|
|
1168
1114
|
if (customKey) {
|
|
1169
1115
|
return { [customKey]: item[customKey] };
|
|
1170
1116
|
}
|
|
@@ -1174,15 +1120,14 @@ exports.getFindQuery = getFindQuery;
|
|
|
1174
1120
|
const getFileObjectList = (fileUrls, projectId) => {
|
|
1175
1121
|
const result = [];
|
|
1176
1122
|
fileUrls.forEach((url) => {
|
|
1177
|
-
const urlSplits = url.split(
|
|
1178
|
-
|
|
1179
|
-
const extension = fileName.substring(fileName.lastIndexOf(
|
|
1180
|
-
|
|
1181
|
-
console.log(mimetype);
|
|
1123
|
+
const urlSplits = url.split('?')[0].split('/');
|
|
1124
|
+
const fileName = urlSplits[urlSplits.length - 1];
|
|
1125
|
+
const extension = fileName.substring(fileName.lastIndexOf('.'));
|
|
1126
|
+
const mimetype = mime_types_1.default.lookup(extension) || 'application/octet-stream';
|
|
1182
1127
|
const fileJson = {
|
|
1183
1128
|
uuid: (0, uuid_2.v4)(),
|
|
1184
1129
|
originalName: fileName,
|
|
1185
|
-
contentType: mime_types_1.default.contentType(mimetype) ||
|
|
1130
|
+
contentType: mime_types_1.default.contentType(mimetype) || 'application/octet-stream',
|
|
1186
1131
|
mimeType: mimetype,
|
|
1187
1132
|
projectId,
|
|
1188
1133
|
isExternalUrl: true,
|
|
@@ -1194,11 +1139,11 @@ const getFileObjectList = (fileUrls, projectId) => {
|
|
|
1194
1139
|
};
|
|
1195
1140
|
exports.getFileObjectList = getFileObjectList;
|
|
1196
1141
|
const getItemDataForArrayFields = (item, dataSourceItemKey) => {
|
|
1197
|
-
if (dataSourceItemKey.indexOf(
|
|
1198
|
-
const parentKey = dataSourceItemKey.substring(0, dataSourceItemKey.lastIndexOf(
|
|
1142
|
+
if (dataSourceItemKey.indexOf('.') != -1) {
|
|
1143
|
+
const parentKey = dataSourceItemKey.substring(0, dataSourceItemKey.lastIndexOf('.'));
|
|
1199
1144
|
const parenteItemData = lodash_1.default.get(item, parentKey);
|
|
1200
1145
|
if (Array.isArray(parenteItemData)) {
|
|
1201
|
-
const lastLevelKey = dataSourceItemKey.substring(dataSourceItemKey.lastIndexOf(
|
|
1146
|
+
const lastLevelKey = dataSourceItemKey.substring(dataSourceItemKey.lastIndexOf('.') + 1);
|
|
1202
1147
|
const itemFieldData = parenteItemData.map((e) => e[lastLevelKey]);
|
|
1203
1148
|
return itemFieldData;
|
|
1204
1149
|
}
|
|
@@ -1214,7 +1159,7 @@ const getItemDataForArrayFields = (item, dataSourceItemKey) => {
|
|
|
1214
1159
|
};
|
|
1215
1160
|
exports.getItemDataForArrayFields = getItemDataForArrayFields;
|
|
1216
1161
|
const getMappingObjKey = (collectionMapping = {}, fieldName) => {
|
|
1217
|
-
if (typeof collectionMapping[fieldName] ===
|
|
1162
|
+
if (typeof collectionMapping[fieldName] === 'object') {
|
|
1218
1163
|
return collectionMapping[fieldName].dataSourceField;
|
|
1219
1164
|
}
|
|
1220
1165
|
else {
|
|
@@ -1223,7 +1168,7 @@ const getMappingObjKey = (collectionMapping = {}, fieldName) => {
|
|
|
1223
1168
|
};
|
|
1224
1169
|
exports.getMappingObjKey = getMappingObjKey;
|
|
1225
1170
|
const getFieldSchemaForDataSourcePrimaryId = () => {
|
|
1226
|
-
return getPrimaryFieldSchema(
|
|
1171
|
+
return getPrimaryFieldSchema('Data Source Rest API Primary Id', drapcode_constant_1.REST_API_PRIMAREY_KEY);
|
|
1227
1172
|
};
|
|
1228
1173
|
exports.getFieldSchemaForDataSourcePrimaryId = getFieldSchemaForDataSourcePrimaryId;
|
|
1229
1174
|
const getPrimaryFieldNameOfDataSource = () => drapcode_constant_1.REST_API_PRIMAREY_KEY;
|
|
@@ -1237,27 +1182,27 @@ const getPrimaryFieldSchema = (fieldTitle, fieldName) => ({
|
|
|
1237
1182
|
fieldTitle: {
|
|
1238
1183
|
en: fieldTitle,
|
|
1239
1184
|
},
|
|
1240
|
-
type:
|
|
1185
|
+
type: 'text',
|
|
1241
1186
|
placeholder: {
|
|
1242
1187
|
en: fieldTitle,
|
|
1243
1188
|
},
|
|
1244
1189
|
validation: {
|
|
1245
1190
|
min: null,
|
|
1246
1191
|
max: null,
|
|
1247
|
-
regex:
|
|
1192
|
+
regex: '',
|
|
1248
1193
|
allowedFileTypes: [],
|
|
1249
1194
|
noAllowedFiles: 1,
|
|
1250
1195
|
},
|
|
1251
1196
|
refCollection: {
|
|
1252
|
-
collectionName:
|
|
1253
|
-
collectionField:
|
|
1254
|
-
displayType:
|
|
1255
|
-
parentCollectionField:
|
|
1197
|
+
collectionName: '',
|
|
1198
|
+
collectionField: '',
|
|
1199
|
+
displayType: 'dropdown',
|
|
1200
|
+
parentCollectionField: '',
|
|
1256
1201
|
isShowAsText: false,
|
|
1257
1202
|
},
|
|
1258
1203
|
extraFieldSetting: {
|
|
1259
|
-
dateDisplayType:
|
|
1260
|
-
textareaDisplayType:
|
|
1204
|
+
dateDisplayType: 'date',
|
|
1205
|
+
textareaDisplayType: 'text-area',
|
|
1261
1206
|
},
|
|
1262
1207
|
fieldName: fieldName,
|
|
1263
1208
|
});
|
|
@@ -1266,8 +1211,8 @@ exports.checkFieldValueType = checkFieldValueType;
|
|
|
1266
1211
|
const replaceValuesFromObjArr = (dataArr, mappingArray) => {
|
|
1267
1212
|
return dataArr.map((data) => {
|
|
1268
1213
|
mappingArray.map((mapping) => {
|
|
1269
|
-
|
|
1270
|
-
|
|
1214
|
+
const dataValue = data.value.replace(/{{(.*?)}}/g, '$1');
|
|
1215
|
+
const mappingValue = mapping[dataValue];
|
|
1271
1216
|
if (mappingValue) {
|
|
1272
1217
|
data.value = data.value.replace(data.value, mappingValue);
|
|
1273
1218
|
}
|
|
@@ -1287,7 +1232,7 @@ const replaceValuesFromRequestMapping = (dataArr, mappingArray) => {
|
|
|
1287
1232
|
};
|
|
1288
1233
|
exports.replaceValuesFromRequestMapping = replaceValuesFromRequestMapping;
|
|
1289
1234
|
const getAwsSignature = async (axiosConfig, awsSignPluginConfig) => {
|
|
1290
|
-
const response = { error:
|
|
1235
|
+
const response = { error: '', data: {} };
|
|
1291
1236
|
const { method, headers, url, data } = axiosConfig;
|
|
1292
1237
|
const parsedUrl = new URL(url);
|
|
1293
1238
|
if (awsSignPluginConfig) {
|
|
@@ -1305,7 +1250,7 @@ const getAwsSignature = async (axiosConfig, awsSignPluginConfig) => {
|
|
|
1305
1250
|
return response;
|
|
1306
1251
|
}
|
|
1307
1252
|
else
|
|
1308
|
-
response.error =
|
|
1253
|
+
response.error = 'AWS Signature Plugin is not installed.';
|
|
1309
1254
|
return response;
|
|
1310
1255
|
};
|
|
1311
1256
|
exports.getAwsSignature = getAwsSignature;
|
|
@@ -1314,11 +1259,8 @@ exports.getAwsSignature = getAwsSignature;
|
|
|
1314
1259
|
*/
|
|
1315
1260
|
const createMySqlConnection = async (config) => {
|
|
1316
1261
|
try {
|
|
1317
|
-
const { host, user, password, database, port, sslEnabled, sslCa, sslCert, sslKey
|
|
1318
|
-
|
|
1319
|
-
console.log("🚀 ~ createMySqlConnection ~ process.env.MYSQL_SSL_CERT_PATH:", process.env.MYSQL_SSL_CERT_PATH);
|
|
1320
|
-
const sslCertsPath = process.env.MYSQL_SSL_CERT_PATH || "./";
|
|
1321
|
-
console.log("🚀 ~ createMySqlConnection ~ sslCertsPath:", sslCertsPath);
|
|
1262
|
+
const { host, user, password, database, port, sslEnabled, sslCa, sslCert, sslKey } = config || {};
|
|
1263
|
+
const sslCertsPath = process.env.MYSQL_SSL_CERT_PATH || './';
|
|
1322
1264
|
let connection = null;
|
|
1323
1265
|
if (sslEnabled) {
|
|
1324
1266
|
const connectionOptions = {
|
|
@@ -1349,12 +1291,12 @@ const createMySqlConnection = async (config) => {
|
|
|
1349
1291
|
port,
|
|
1350
1292
|
});
|
|
1351
1293
|
}
|
|
1352
|
-
const [rows] = await connection.execute(
|
|
1353
|
-
|
|
1294
|
+
const [rows] = await connection.execute('select ?+? as sum', [2, 2]);
|
|
1295
|
+
drapcode_logger_1.logger.info(rows, '==> MySQL createMySqlConnection ~ Testing connection...');
|
|
1354
1296
|
return connection;
|
|
1355
1297
|
}
|
|
1356
1298
|
catch (error) {
|
|
1357
|
-
|
|
1299
|
+
drapcode_logger_1.logger.error(`==> MySQL createMySqlConnection ~ error: ${error}`);
|
|
1358
1300
|
throw error;
|
|
1359
1301
|
}
|
|
1360
1302
|
};
|
|
@@ -1364,12 +1306,12 @@ exports.createMySqlConnection = createMySqlConnection;
|
|
|
1364
1306
|
*/
|
|
1365
1307
|
const buildWhereClause = (searchQuery) => {
|
|
1366
1308
|
if (!searchQuery)
|
|
1367
|
-
return
|
|
1368
|
-
const params = searchQuery.split(
|
|
1369
|
-
const [key, value] = pair.split(
|
|
1309
|
+
return '';
|
|
1310
|
+
const params = searchQuery.split('&').map((pair) => {
|
|
1311
|
+
const [key, value] = pair.split('=');
|
|
1370
1312
|
return `${decodeURIComponent(key)}="${decodeURIComponent(value)}"`;
|
|
1371
1313
|
});
|
|
1372
|
-
return params.length ? ` WHERE ${params.join(
|
|
1314
|
+
return params.length ? ` WHERE ${params.join(' AND ')}` : '';
|
|
1373
1315
|
};
|
|
1374
1316
|
exports.buildWhereClause = buildWhereClause;
|
|
1375
1317
|
/**
|
|
@@ -1377,10 +1319,10 @@ exports.buildWhereClause = buildWhereClause;
|
|
|
1377
1319
|
*/
|
|
1378
1320
|
const buildOrderByClause = (sqlSort) => {
|
|
1379
1321
|
if (sqlSort?.column && sqlSort?.order) {
|
|
1380
|
-
const order = sqlSort.order.toUpperCase() ===
|
|
1322
|
+
const order = sqlSort.order.toUpperCase() === 'DESC' ? 'DESC' : 'ASC';
|
|
1381
1323
|
return ` ORDER BY \`${sqlSort.column}\` ${order}`;
|
|
1382
1324
|
}
|
|
1383
|
-
return
|
|
1325
|
+
return '';
|
|
1384
1326
|
};
|
|
1385
1327
|
exports.buildOrderByClause = buildOrderByClause;
|
|
1386
1328
|
/**
|
|
@@ -1393,7 +1335,7 @@ const buildLimitOffsetClause = (sqlPagination, values) => {
|
|
|
1393
1335
|
values.push(parseInt(sqlPagination.limit), parseInt(sqlPagination.offset));
|
|
1394
1336
|
return ` LIMIT ${limit} OFFSET ${offset}`;
|
|
1395
1337
|
}
|
|
1396
|
-
return
|
|
1338
|
+
return '';
|
|
1397
1339
|
};
|
|
1398
1340
|
exports.buildLimitOffsetClause = buildLimitOffsetClause;
|
|
1399
1341
|
/**
|
|
@@ -1414,95 +1356,99 @@ const getLastUpdatedId = async (connection, sqlParams) => {
|
|
|
1414
1356
|
return lastUpdatedIdRows[0]?.lastId ?? null;
|
|
1415
1357
|
};
|
|
1416
1358
|
exports.getLastUpdatedId = getLastUpdatedId;
|
|
1417
|
-
const masking = (subject, visibleCharCount = 2, maskPosition =
|
|
1359
|
+
const masking = (subject, visibleCharCount = 2, maskPosition = 'END', maskCharacter = '*') => {
|
|
1418
1360
|
if (subject === null || subject === undefined)
|
|
1419
|
-
return
|
|
1361
|
+
return '';
|
|
1420
1362
|
if (subject === 0)
|
|
1421
|
-
return
|
|
1363
|
+
return '0';
|
|
1422
1364
|
const str = String(subject);
|
|
1423
1365
|
const visibleCount = parseInt(visibleCharCount, 10);
|
|
1424
1366
|
if (isNaN(visibleCount) || visibleCount <= 0)
|
|
1425
1367
|
return str;
|
|
1426
|
-
const maskChar = maskCharacter ||
|
|
1368
|
+
const maskChar = maskCharacter || '*';
|
|
1427
1369
|
const length = str.length;
|
|
1428
1370
|
if (visibleCount >= length)
|
|
1429
1371
|
return str;
|
|
1430
1372
|
const maskedPart = maskChar.repeat(length - visibleCount);
|
|
1431
|
-
if (maskPosition ===
|
|
1373
|
+
if (maskPosition === 'START') {
|
|
1432
1374
|
return str.slice(0, visibleCount) + maskedPart;
|
|
1433
1375
|
}
|
|
1434
|
-
else if (maskPosition ===
|
|
1376
|
+
else if (maskPosition === 'END') {
|
|
1435
1377
|
return maskedPart + str.slice(-visibleCount);
|
|
1436
1378
|
}
|
|
1437
1379
|
else {
|
|
1438
1380
|
const start = Math.floor((length - visibleCount) / 2);
|
|
1439
1381
|
const end = start + visibleCount;
|
|
1440
|
-
return
|
|
1441
|
-
maskChar.repeat(length - visibleCount) +
|
|
1442
|
-
str.slice(end));
|
|
1382
|
+
return str.slice(0, start) + maskChar.repeat(length - visibleCount) + str.slice(end);
|
|
1443
1383
|
}
|
|
1444
1384
|
};
|
|
1445
1385
|
exports.masking = masking;
|
|
1446
1386
|
const getArgsFromKey = (key, field, loggedInUserData, projectConstant = {}, envConstants, collectionConstant = {}, browserStorageData) => {
|
|
1447
|
-
const { sessionValue, sessionFormValue, sessionStorageData, localStorageData, cookiesData
|
|
1448
|
-
let value =
|
|
1449
|
-
if (key.includes(
|
|
1450
|
-
const userKey = key.split(
|
|
1387
|
+
const { sessionValue, sessionFormValue, sessionStorageData, localStorageData, cookiesData } = browserStorageData || {};
|
|
1388
|
+
let value = '';
|
|
1389
|
+
if (key.includes('current_user.')) {
|
|
1390
|
+
const userKey = key.split('.')[1];
|
|
1451
1391
|
value = (0, exports.parseValueFromData)(loggedInUserData, userKey);
|
|
1452
1392
|
}
|
|
1453
|
-
else if (key.includes(
|
|
1454
|
-
const [userRefFieldName, newKey] = key
|
|
1455
|
-
.replace("current_user_reference_field.", "")
|
|
1456
|
-
.split(".");
|
|
1393
|
+
else if (key.includes('current_user_reference_field.')) {
|
|
1394
|
+
const [userRefFieldName, newKey] = key.replace('current_user_reference_field.', '').split('.');
|
|
1457
1395
|
const userRefField = loggedInUserData?.[userRefFieldName];
|
|
1458
|
-
value = userRefField ? userRefField[0]?.[newKey] :
|
|
1396
|
+
value = userRefField ? userRefField[0]?.[newKey] : '';
|
|
1459
1397
|
}
|
|
1460
|
-
else if (key.includes(
|
|
1461
|
-
const newKey = key.split(
|
|
1398
|
+
else if (key.includes('createdBy.')) {
|
|
1399
|
+
const newKey = key.split('.')[1];
|
|
1462
1400
|
const createdBy = field?.createdBy;
|
|
1463
1401
|
value = createdBy[0]?.[newKey];
|
|
1464
1402
|
}
|
|
1465
|
-
else if (key.includes(
|
|
1466
|
-
const envConstantName = key.split(
|
|
1403
|
+
else if (key.includes('environment_variable.')) {
|
|
1404
|
+
const envConstantName = key.split('environment_variable.')[1];
|
|
1467
1405
|
value = envConstants.find((constant) => constant.name === envConstantName).value;
|
|
1468
1406
|
}
|
|
1469
|
-
else if (key.includes(
|
|
1470
|
-
const refName = key.replace(
|
|
1407
|
+
else if (key.includes('RF::')) {
|
|
1408
|
+
const refName = key.replace('RF::', '');
|
|
1471
1409
|
value = (0, exports.parseValueFromData)(field, refName);
|
|
1472
1410
|
}
|
|
1473
|
-
else if (key.includes(
|
|
1474
|
-
const projectConstantName = key.split(
|
|
1411
|
+
else if (key.includes('PC::')) {
|
|
1412
|
+
const projectConstantName = key.split('PC::')[1];
|
|
1475
1413
|
const projectConst = projectConstant.find((constant) => constant.name === projectConstantName);
|
|
1476
1414
|
value = projectConst?.value;
|
|
1477
1415
|
}
|
|
1478
|
-
else if (key.includes(
|
|
1479
|
-
const collectionConstantName = key.split(
|
|
1416
|
+
else if (key.includes('CC::')) {
|
|
1417
|
+
const collectionConstantName = key.split('CC::')[1];
|
|
1480
1418
|
const collectionConst = collectionConstant.find((constant) => constant.name === collectionConstantName);
|
|
1481
1419
|
value = collectionConst?.value;
|
|
1482
1420
|
}
|
|
1483
|
-
else if (key.includes(
|
|
1484
|
-
const sessionKey = key.replace(
|
|
1421
|
+
else if (key.includes('current_session.')) {
|
|
1422
|
+
const sessionKey = key.replace('current_session.', '');
|
|
1485
1423
|
value = (0, exports.parseValueFromData)(sessionValue, sessionKey);
|
|
1486
1424
|
}
|
|
1487
|
-
else if (key.includes(
|
|
1488
|
-
const sessionKey = key.replace(
|
|
1425
|
+
else if (key.includes('form_data_session.')) {
|
|
1426
|
+
const sessionKey = key.replace('form_data_session.', '');
|
|
1489
1427
|
value = (0, exports.parseValueFromData)(sessionFormValue, sessionKey);
|
|
1490
1428
|
}
|
|
1491
|
-
else if (key.includes(
|
|
1492
|
-
const sessionKey = key.replace(
|
|
1429
|
+
else if (key.includes('SESSION_STORAGE.')) {
|
|
1430
|
+
const sessionKey = key.replace('SESSION_STORAGE.', '');
|
|
1493
1431
|
value = (0, exports.parseValueFromData)(sessionStorageData, sessionKey);
|
|
1494
1432
|
}
|
|
1495
|
-
else if (key.includes(
|
|
1496
|
-
const sessionKey = key.replace(
|
|
1433
|
+
else if (key.includes('LOCAL_STORAGE.')) {
|
|
1434
|
+
const sessionKey = key.replace('LOCAL_STORAGE.', '');
|
|
1497
1435
|
value = (0, exports.parseValueFromData)(localStorageData, sessionKey);
|
|
1498
1436
|
}
|
|
1499
|
-
else if (key.includes(
|
|
1500
|
-
const sessionKey = key.replace(
|
|
1437
|
+
else if (key.includes('COOKIES.')) {
|
|
1438
|
+
const sessionKey = key.replace('COOKIES.', '');
|
|
1501
1439
|
value = (0, exports.parseValueFromData)(cookiesData, sessionKey);
|
|
1502
1440
|
}
|
|
1503
1441
|
else {
|
|
1504
|
-
value =
|
|
1442
|
+
value = '';
|
|
1505
1443
|
}
|
|
1506
1444
|
return value;
|
|
1507
1445
|
};
|
|
1508
1446
|
exports.getArgsFromKey = getArgsFromKey;
|
|
1447
|
+
const slugifyFileName = (fileName) => {
|
|
1448
|
+
return fileName
|
|
1449
|
+
.replace(/\s+/g, '_') // Replace spaces with underscores
|
|
1450
|
+
.replace(/[^a-zA-Z0-9._]/g, '') // Remove anything that's not a letter, number, dot, or underscore
|
|
1451
|
+
.toLowerCase(); // Convert to lowercase
|
|
1452
|
+
};
|
|
1453
|
+
exports.slugifyFileName = slugifyFileName;
|
|
1454
|
+
//# sourceMappingURL=util.js.map
|