drapcode-utility 1.0.3 → 1.0.5
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/errors/app-error.js +0 -2
- package/build/errors/bad-request-error.js +0 -2
- package/build/errors/custom-error.js +0 -2
- package/build/errors/not-found.js +0 -2
- package/build/format-fields/index.js +2 -1
- package/build/utils/check-error.js +7 -5
- package/build/utils/query-parser.js +11 -9
- package/build/utils/query-paser-new.js +8 -6
- package/package.json +2 -2
|
@@ -7,8 +7,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -7,8 +7,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -7,8 +7,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -7,8 +7,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -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 = [
|
|
@@ -35,10 +35,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var
|
|
39
|
-
for (var
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
39
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
40
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
41
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
42
|
+
r[k] = a[j];
|
|
43
|
+
return r;
|
|
42
44
|
};
|
|
43
45
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
44
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -181,7 +183,7 @@ var nestedValue = function (data, messages) {
|
|
|
181
183
|
messages.push(value);
|
|
182
184
|
}
|
|
183
185
|
else if (Array.isArray(value)) {
|
|
184
|
-
messages =
|
|
186
|
+
messages = __spreadArrays(messages, value);
|
|
185
187
|
}
|
|
186
188
|
else {
|
|
187
189
|
if (Object.keys(value).length) {
|
|
@@ -35,10 +35,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var
|
|
39
|
-
for (var
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
39
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
40
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
41
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
42
|
+
r[k] = a[j];
|
|
43
|
+
return r;
|
|
42
44
|
};
|
|
43
45
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
44
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -85,7 +87,7 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
85
87
|
searchQueryObj = null;
|
|
86
88
|
if (searchObj) {
|
|
87
89
|
_a = getSearchObjQuery(searchObj, searchQueryTypeObj, timezone), searchAggregateQuery = _a.searchAggregateQuery, likeQuery = _a.likeQuery;
|
|
88
|
-
aggregateQuery =
|
|
90
|
+
aggregateQuery = __spreadArrays(aggregateQuery, searchAggregateQuery);
|
|
89
91
|
console.log("likeQuery after getSearchObjQuery", JSON.stringify(likeQuery));
|
|
90
92
|
if (likeQuery && likeQuery.length > 0) {
|
|
91
93
|
searchQueryObj = likeQuery;
|
|
@@ -103,7 +105,7 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
103
105
|
else if (searchObj) {
|
|
104
106
|
console.log("I donot have filter query");
|
|
105
107
|
_b = getSearchObjQuery(searchObj, searchQueryTypeObj, timezone), searchAggregateQuery = _b.searchAggregateQuery, likeQuery = _b.likeQuery;
|
|
106
|
-
aggregateQuery =
|
|
108
|
+
aggregateQuery = __spreadArrays(aggregateQuery, searchAggregateQuery);
|
|
107
109
|
if (likeQuery.length) {
|
|
108
110
|
// aggregateQuery.push({ $match: { $or: likeQuery } });
|
|
109
111
|
aggregateQuery.push({ $match: { $and: likeQuery } });
|
|
@@ -508,7 +510,7 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
508
510
|
endValue_1 = "" + externalParams[endValue_1];
|
|
509
511
|
}
|
|
510
512
|
else {
|
|
511
|
-
if (
|
|
513
|
+
if (__spreadArrays([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant).some(function (cnst) {
|
|
512
514
|
return startValue_1.includes(cnst);
|
|
513
515
|
})) {
|
|
514
516
|
startValue_1 = getValueOfProjectConstant(startValue_1, currentUser, timezone);
|
|
@@ -516,7 +518,7 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
516
518
|
else {
|
|
517
519
|
startValue_1 = constants.filter(function (constant) { return constant.name == startValue_1; });
|
|
518
520
|
}
|
|
519
|
-
if (
|
|
521
|
+
if (__spreadArrays([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant).some(function (cnst) { return endValue_1.includes(cnst); })) {
|
|
520
522
|
endValue_1 = getValueOfProjectConstant(endValue_1, currentUser, timezone);
|
|
521
523
|
}
|
|
522
524
|
else {
|
|
@@ -744,7 +746,7 @@ var getSearchObjQuery = function (searchObj, searchQueryTypeObj, timezone) {
|
|
|
744
746
|
},
|
|
745
747
|
_j));
|
|
746
748
|
}
|
|
747
|
-
else if (["date", "createdAt"].includes(searchQueryTypeKey)) {
|
|
749
|
+
else if (["date", "createdAt", "time_slot"].includes(searchQueryTypeKey)) {
|
|
748
750
|
if (key.startsWith("start_") || key.startsWith("end_")) {
|
|
749
751
|
var fieldKey = key.replace("start_", "");
|
|
750
752
|
fieldKey = fieldKey.replace("end_", "");
|
|
@@ -35,10 +35,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var
|
|
39
|
-
for (var
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
39
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
40
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
41
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
42
|
+
r[k] = a[j];
|
|
43
|
+
return r;
|
|
42
44
|
};
|
|
43
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
46
|
exports.queryParserNew = void 0;
|
|
@@ -567,7 +569,7 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
567
569
|
endValue_1 = "" + externalParams[endValue_1];
|
|
568
570
|
}
|
|
569
571
|
else {
|
|
570
|
-
if (
|
|
572
|
+
if (__spreadArrays([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant).some(function (cnst) {
|
|
571
573
|
return startValue_1.includes(cnst);
|
|
572
574
|
})) {
|
|
573
575
|
startValue_1 = getValueOfProjectConstant(startValue_1, currentUser);
|
|
@@ -575,7 +577,7 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
575
577
|
else {
|
|
576
578
|
startValue_1 = constants.filter(function (constant) { return constant.name == startValue_1; });
|
|
577
579
|
}
|
|
578
|
-
if (
|
|
580
|
+
if (__spreadArrays([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant).some(function (cnst) { return endValue_1.includes(cnst); })) {
|
|
579
581
|
endValue_1 = getValueOfProjectConstant(endValue_1, currentUser);
|
|
580
582
|
}
|
|
581
583
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drapcode-utility",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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.2",
|
|
35
35
|
"drapcode-logger": "^1.0.0",
|
|
36
36
|
"drapcode-redis": "^1.0.0",
|
|
37
37
|
"express": "^4.17.1",
|