drapcode-utility 1.0.6 → 1.0.7
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 +47 -1
- package/package.json +1 -1
package/build/utils/util.d.ts
CHANGED
|
@@ -25,3 +25,4 @@ export declare const parseJsonString: (str: string) => any;
|
|
|
25
25
|
export declare const parseValueFromData: (data: any, fieldName: string) => any;
|
|
26
26
|
export declare const unflattenObject: (obj: any) => {};
|
|
27
27
|
export declare const replaceTransferObjectValueIntoExpression: (expression: string, transferObject: any) => string;
|
|
28
|
+
export declare const removeMongoDbId: (result: any[]) => any[];
|
package/build/utils/util.js
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
2
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
26
|
};
|
|
5
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
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.snakeCaseToTitleCase = exports.dynamicSort = exports.checkValidArray = exports.isObject = exports.isEmptyObject = exports.isEmpty = exports.clearSpaceAndReformat = exports.camelize = exports.validateString = void 0;
|
|
28
|
+
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.snakeCaseToTitleCase = exports.dynamicSort = exports.checkValidArray = exports.isObject = exports.isEmptyObject = exports.isEmpty = exports.clearSpaceAndReformat = exports.camelize = exports.validateString = void 0;
|
|
7
29
|
var lodash_1 = __importDefault(require("lodash"));
|
|
8
30
|
var validateString = function (str) {
|
|
9
31
|
var specialChar = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
|
|
@@ -373,3 +395,27 @@ var replaceTransferObjectValueIntoExpression = function (expression, transferObj
|
|
|
373
395
|
return expression;
|
|
374
396
|
};
|
|
375
397
|
exports.replaceTransferObjectValueIntoExpression = replaceTransferObjectValueIntoExpression;
|
|
398
|
+
var removeMongoDbId = function (result) {
|
|
399
|
+
var removeIdRecursively = function (obj) {
|
|
400
|
+
if (Array.isArray(obj)) {
|
|
401
|
+
return obj.map(removeIdRecursively);
|
|
402
|
+
}
|
|
403
|
+
if (typeof obj === "object" && obj !== null) {
|
|
404
|
+
for (var key in obj) {
|
|
405
|
+
if (key === "_id") {
|
|
406
|
+
delete obj[key];
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
obj[key] = removeIdRecursively(obj[key]);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return obj;
|
|
414
|
+
};
|
|
415
|
+
var moveUuidToTopLevel = function (obj) {
|
|
416
|
+
var uuid = obj.uuid, rest = __rest(obj, ["uuid"]);
|
|
417
|
+
return __assign({ uuid: uuid }, removeIdRecursively(rest));
|
|
418
|
+
};
|
|
419
|
+
return result.map(moveUuidToTopLevel);
|
|
420
|
+
};
|
|
421
|
+
exports.removeMongoDbId = removeMongoDbId;
|