drapcode-utility 2.4.3 → 2.4.4
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/utils/util.d.ts +1 -0
- package/build/utils/util.js +30 -1
- package/package.json +1 -1
package/build/utils/util.d.ts
CHANGED
|
@@ -179,4 +179,5 @@ export declare const getTotalRecords: (connection: any, sqlQuery: string, sqlPar
|
|
|
179
179
|
* MySQL Helper to get last updated ID
|
|
180
180
|
*/
|
|
181
181
|
export declare const getLastUpdatedId: (connection: any, sqlParams: any[]) => Promise<number | null>;
|
|
182
|
+
export declare const masking: (subject: string | number, visibleCharCount?: number | string, maskPosition?: "START" | "END" | "MIDDLE", maskCharacter?: string) => string;
|
|
182
183
|
export {};
|
package/build/utils/util.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
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.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 = exports.divide = void 0;
|
|
7
|
+
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 = exports.divide = void 0;
|
|
8
8
|
const drapcode_constant_1 = require("drapcode-constant");
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
10
|
const showdown_1 = __importDefault(require("showdown"));
|
|
@@ -1286,3 +1286,32 @@ const getLastUpdatedId = async (connection, sqlParams) => {
|
|
|
1286
1286
|
return lastUpdatedIdRows[0]?.lastId ?? null;
|
|
1287
1287
|
};
|
|
1288
1288
|
exports.getLastUpdatedId = getLastUpdatedId;
|
|
1289
|
+
const masking = (subject, visibleCharCount = 2, maskPosition = "END", maskCharacter = "*") => {
|
|
1290
|
+
if (subject === null || subject === undefined)
|
|
1291
|
+
return "";
|
|
1292
|
+
if (subject === 0)
|
|
1293
|
+
return "0";
|
|
1294
|
+
const str = String(subject);
|
|
1295
|
+
const visibleCount = parseInt(visibleCharCount, 10);
|
|
1296
|
+
if (isNaN(visibleCount) || visibleCount <= 0)
|
|
1297
|
+
return str;
|
|
1298
|
+
const maskChar = maskCharacter || "*";
|
|
1299
|
+
const length = str.length;
|
|
1300
|
+
if (visibleCount >= length)
|
|
1301
|
+
return str;
|
|
1302
|
+
const maskedPart = maskChar.repeat(length - visibleCount);
|
|
1303
|
+
if (maskPosition === "START") {
|
|
1304
|
+
return str.slice(0, visibleCount) + maskedPart;
|
|
1305
|
+
}
|
|
1306
|
+
else if (maskPosition === "END") {
|
|
1307
|
+
return maskedPart + str.slice(-visibleCount);
|
|
1308
|
+
}
|
|
1309
|
+
else {
|
|
1310
|
+
const start = Math.floor((length - visibleCount) / 2);
|
|
1311
|
+
const end = start + visibleCount;
|
|
1312
|
+
return (str.slice(0, start) +
|
|
1313
|
+
maskChar.repeat(length - visibleCount) +
|
|
1314
|
+
str.slice(end));
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
exports.masking = masking;
|