drapcode-utility 2.4.2 → 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.
@@ -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 {};
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
4
  "description": "DrapCode Utility",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -42,9 +42,9 @@
42
42
  "axios": "^1.1.2",
43
43
  "date-fns": "^4.1.0",
44
44
  "dompurify": "^3.1.7",
45
- "drapcode-constant": "^1.9.9",
45
+ "drapcode-constant": "^2.0.0",
46
46
  "drapcode-logger": "^1.3.5",
47
- "drapcode-redis": "^1.4.5",
47
+ "drapcode-redis": "^1.4.7",
48
48
  "exiftool-vendored": "^28.2.1",
49
49
  "express": "^4.17.1",
50
50
  "gm": "^1.25.0",