drapcode-utility 1.0.4 → 1.0.6
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/encryption/index.js +19 -17
- package/build/format-fields/index.js +2 -1
- package/build/utils/date-util.js +17 -15
- package/package.json +2 -2
|
@@ -83,23 +83,25 @@ var crypt = function (data, fields, encryption, decrypt) { return __awaiter(void
|
|
|
83
83
|
exports.crypt = crypt;
|
|
84
84
|
var cryptItem = function (item, fields, encryption, decrypt) { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
85
|
return __generator(this, function (_a) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
86
|
+
if (item && typeof item === "object") {
|
|
87
|
+
Object.keys(item).forEach(function (fieldName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
+
var field, _a, _b;
|
|
89
|
+
return __generator(this, function (_c) {
|
|
90
|
+
switch (_c.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
field = fields.find(function (field) { return field.fieldName === fieldName; });
|
|
93
|
+
if (!(field && field.encrypted)) return [3 /*break*/, 2];
|
|
94
|
+
_a = item;
|
|
95
|
+
_b = fieldName;
|
|
96
|
+
return [4 /*yield*/, cryptData(item[fieldName], encryption, decrypt)];
|
|
97
|
+
case 1:
|
|
98
|
+
_a[_b] = _c.sent();
|
|
99
|
+
_c.label = 2;
|
|
100
|
+
case 2: return [2 /*return*/];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}); });
|
|
104
|
+
}
|
|
103
105
|
return [2 /*return*/, item];
|
|
104
106
|
});
|
|
105
107
|
}); };
|
|
@@ -26,7 +26,7 @@ var formatField = function (itemData, fields) {
|
|
|
26
26
|
return newItemData;
|
|
27
27
|
};
|
|
28
28
|
var getFormatFieldData = function (fieldData, fieldType) {
|
|
29
|
-
var createdAt = drapcode_constant_1.FieldTypes.createdAt, text = drapcode_constant_1.FieldTypes.text, large_text = drapcode_constant_1.FieldTypes.large_text, date = drapcode_constant_1.FieldTypes.date, password = drapcode_constant_1.FieldTypes.password, uuid = drapcode_constant_1.FieldTypes.uuid, custom_uuid = drapcode_constant_1.FieldTypes.custom_uuid, email = drapcode_constant_1.FieldTypes.email, url = drapcode_constant_1.FieldTypes.url, number = drapcode_constant_1.FieldTypes.number, unix_timestamp = drapcode_constant_1.FieldTypes.unix_timestamp, reference = drapcode_constant_1.FieldTypes.reference, belongsTo = drapcode_constant_1.FieldTypes.belongsTo, multi_reference = drapcode_constant_1.FieldTypes.multi_reference, dynamic_option = drapcode_constant_1.FieldTypes.dynamic_option, static_option = drapcode_constant_1.FieldTypes.static_option, boolean = drapcode_constant_1.FieldTypes.boolean, time_slot = drapcode_constant_1.FieldTypes.time_slot;
|
|
29
|
+
var createdAt = drapcode_constant_1.FieldTypes.createdAt, text = drapcode_constant_1.FieldTypes.text, large_text = drapcode_constant_1.FieldTypes.large_text, date = drapcode_constant_1.FieldTypes.date, password = drapcode_constant_1.FieldTypes.password, uuid = drapcode_constant_1.FieldTypes.uuid, custom_uuid = drapcode_constant_1.FieldTypes.custom_uuid, email = drapcode_constant_1.FieldTypes.email, url = drapcode_constant_1.FieldTypes.url, number = drapcode_constant_1.FieldTypes.number, unix_timestamp = drapcode_constant_1.FieldTypes.unix_timestamp, reference = drapcode_constant_1.FieldTypes.reference, belongsTo = drapcode_constant_1.FieldTypes.belongsTo, multi_reference = drapcode_constant_1.FieldTypes.multi_reference, dynamic_option = drapcode_constant_1.FieldTypes.dynamic_option, static_option = drapcode_constant_1.FieldTypes.static_option, boolean = drapcode_constant_1.FieldTypes.boolean, time_slot = drapcode_constant_1.FieldTypes.time_slot, slug = drapcode_constant_1.FieldTypes.slug;
|
|
30
30
|
var stringType = [
|
|
31
31
|
createdAt.id,
|
|
32
32
|
text.id,
|
|
@@ -38,6 +38,7 @@ var getFormatFieldData = function (fieldData, fieldType) {
|
|
|
38
38
|
email.id,
|
|
39
39
|
url.id,
|
|
40
40
|
time_slot.id,
|
|
41
|
+
slug.id
|
|
41
42
|
];
|
|
42
43
|
var numberType = [number.id, unix_timestamp.id];
|
|
43
44
|
var arrayType = [
|
package/build/utils/date-util.js
CHANGED
|
@@ -87,22 +87,24 @@ var timezoneDateParse = function (value, nextDay, prevDay) {
|
|
|
87
87
|
};
|
|
88
88
|
exports.timezoneDateParse = timezoneDateParse;
|
|
89
89
|
var formatItemDates = function (item, fields, dateFormat, reverse) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
item[fieldName]
|
|
98
|
-
|
|
99
|
-
?
|
|
100
|
-
|
|
90
|
+
if (item && typeof item === "object") {
|
|
91
|
+
var dateFormat1_1 = reverse ? dateFormat : "YYYY-MM-DD";
|
|
92
|
+
var dateFormat2_1 = reverse ? "YYYY-MM-DD" : dateFormat;
|
|
93
|
+
Object.keys(item).forEach(function (fieldName) {
|
|
94
|
+
var _a;
|
|
95
|
+
var field = fields.find(function (field) { return field.fieldName === fieldName; });
|
|
96
|
+
if (field && (field === null || field === void 0 ? void 0 : field.type) === "date") {
|
|
97
|
+
if (moment(item[fieldName]).isValid()) {
|
|
98
|
+
item[fieldName] =
|
|
99
|
+
((_a = field === null || field === void 0 ? void 0 : field.extraFieldSetting) === null || _a === void 0 ? void 0 : _a.dateDisplayType) === "datetime-local"
|
|
100
|
+
? item[fieldName]
|
|
101
|
+
: moment(item[fieldName], dateFormat1_1).format(dateFormat2_1);
|
|
102
|
+
}
|
|
103
|
+
else
|
|
104
|
+
item[fieldName] = "";
|
|
101
105
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
106
108
|
return item;
|
|
107
109
|
};
|
|
108
110
|
var formatProjectDates = function (item, dateFormat, fields, reverse) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drapcode-utility",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@types/voca": "^1.4.2",
|
|
32
32
|
"aws-sdk": "^2.1324.0",
|
|
33
33
|
"axios": "^1.1.2",
|
|
34
|
-
"drapcode-constant": "^1.
|
|
34
|
+
"drapcode-constant": "^1.1.3",
|
|
35
35
|
"drapcode-logger": "^1.0.0",
|
|
36
36
|
"drapcode-redis": "^1.0.0",
|
|
37
37
|
"express": "^4.17.1",
|