drapcode-utility 1.7.8 → 1.8.0
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.
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export declare const queryParser: (collectionName: string, query: any, constants: any[], externalParams: any, currentUser: any, timezone: string, searchObj: any, refCollectionFieldsInItems: any, searchQueryTypeObj: any, currentTenant: any, currentUserSetting: any, lookupConfig: any, rowLevelSecurityFilter: any) => Promise<string>;
|
|
2
2
|
export declare const isEntityInCondition: (value: any) => boolean;
|
|
3
|
+
export declare const isFixedValueQuery: (value: any) => boolean;
|
|
3
4
|
export declare const getMinMaxValue: (value: any) => {
|
|
4
5
|
startValue: any;
|
|
5
6
|
endValue: any;
|
|
6
7
|
isInteger: any;
|
|
8
|
+
isFixedValue: boolean;
|
|
7
9
|
} | {
|
|
8
10
|
startValue: string;
|
|
9
11
|
endValue: string;
|
|
12
|
+
isFixedValue: boolean;
|
|
10
13
|
isInteger?: undefined;
|
|
11
14
|
};
|
|
@@ -48,7 +48,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
49
|
};
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.getMinMaxValue = exports.isEntityInCondition = exports.queryParser = void 0;
|
|
51
|
+
exports.getMinMaxValue = exports.isFixedValueQuery = exports.isEntityInCondition = exports.queryParser = void 0;
|
|
52
52
|
var moment_1 = __importDefault(require("moment"));
|
|
53
53
|
var drapcode_constant_1 = require("drapcode-constant");
|
|
54
54
|
var date_util_1 = require("./date-util");
|
|
@@ -272,7 +272,7 @@ var modifyQuery = function (obj, hasAndQueryConjunction) {
|
|
|
272
272
|
return arr;
|
|
273
273
|
};
|
|
274
274
|
var queryToMongo = function (query, requiredExternal, externalParams, constants, currentUser, currentTenant, currentUserSetting, timezone) {
|
|
275
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
275
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
276
276
|
if (currentUser === void 0) { currentUser = {}; }
|
|
277
277
|
if (currentTenant === void 0) { currentTenant = {}; }
|
|
278
278
|
if (currentUserSetting === void 0) { currentUserSetting = {}; }
|
|
@@ -407,21 +407,25 @@ var queryToMongo = function (query, requiredExternal, externalParams, constants,
|
|
|
407
407
|
return _z = {}, _z[field] = "".concat(fieldValue), _z;
|
|
408
408
|
}
|
|
409
409
|
if (key == drapcode_constant_1.NOT_EQUAL)
|
|
410
|
-
|
|
411
|
-
_0[field] = {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
410
|
+
if (fieldType === "number") {
|
|
411
|
+
return _0 = {}, _0[field] = { $ne: +fieldValue }, _0;
|
|
412
|
+
}
|
|
413
|
+
else
|
|
414
|
+
return _1 = {},
|
|
415
|
+
_1[field] = {
|
|
416
|
+
$ne: fieldType === "boolean" && fieldValue
|
|
417
|
+
? JSON.parse(fieldValue)
|
|
418
|
+
: fieldValue,
|
|
419
|
+
},
|
|
420
|
+
_1;
|
|
417
421
|
if (key == drapcode_constant_1.BETWEEN) {
|
|
418
|
-
var
|
|
419
|
-
return
|
|
420
|
-
|
|
422
|
+
var _3 = (0, exports.getMinMaxValue)(fieldValue), startValue = _3.startValue, endValue = _3.endValue, isInteger = _3.isInteger;
|
|
423
|
+
return _2 = {},
|
|
424
|
+
_2[field] = {
|
|
421
425
|
$gte: isInteger ? +startValue : startValue,
|
|
422
426
|
$lte: isInteger ? +endValue : endValue,
|
|
423
427
|
},
|
|
424
|
-
|
|
428
|
+
_2;
|
|
425
429
|
}
|
|
426
430
|
};
|
|
427
431
|
var isEntityInCondition = function (value) {
|
|
@@ -439,6 +443,22 @@ var isEntityInCondition = function (value) {
|
|
|
439
443
|
return isEntity;
|
|
440
444
|
};
|
|
441
445
|
exports.isEntityInCondition = isEntityInCondition;
|
|
446
|
+
// TODO: can be refactor with entity condition
|
|
447
|
+
var isFixedValueQuery = function (value) {
|
|
448
|
+
var isFixeValue = false;
|
|
449
|
+
if (value && Array.isArray(value)) {
|
|
450
|
+
value.forEach(function (val) {
|
|
451
|
+
if (typeof val === "string" || val instanceof String)
|
|
452
|
+
isFixeValue = val.startsWith("FIXED_VALUE::");
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
if (value && (typeof value === "string" || value instanceof String))
|
|
457
|
+
isFixeValue = value.startsWith("FIXED_VALUE::");
|
|
458
|
+
}
|
|
459
|
+
return isFixeValue;
|
|
460
|
+
};
|
|
461
|
+
exports.isFixedValueQuery = isFixedValueQuery;
|
|
442
462
|
var replaceExternalParams = function (query, requiredExternal, externalParams, constants, currentUser, currentTenant, currentUserSetting, timezone) {
|
|
443
463
|
var key = query.key, value = query.value, fieldType = query.fieldType;
|
|
444
464
|
if (fieldType &&
|
|
@@ -503,7 +523,7 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
503
523
|
return valueList_1;
|
|
504
524
|
}
|
|
505
525
|
if (key === drapcode_constant_1.BETWEEN) {
|
|
506
|
-
var _a = (0, exports.getMinMaxValue)(value), startValue_1 = _a.startValue, endValue_1 = _a.endValue, isInteger = _a.isInteger;
|
|
526
|
+
var _a = (0, exports.getMinMaxValue)(value), startValue_1 = _a.startValue, endValue_1 = _a.endValue, isInteger = _a.isInteger, isFixedValue = _a.isFixedValue;
|
|
507
527
|
if (requiredExternal) {
|
|
508
528
|
startValue_1 = "".concat(externalParams[startValue_1]);
|
|
509
529
|
endValue_1 = "".concat(externalParams[endValue_1]);
|
|
@@ -514,13 +534,13 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
514
534
|
})) {
|
|
515
535
|
startValue_1 = getValueOfProjectConstant(startValue_1, currentUser, timezone);
|
|
516
536
|
}
|
|
517
|
-
else {
|
|
537
|
+
else if (!isFixedValue) {
|
|
518
538
|
startValue_1 = constants.filter(function (constant) { return constant.name == startValue_1; });
|
|
519
539
|
}
|
|
520
540
|
if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant, true).some(function (cnst) { return endValue_1.includes(cnst); })) {
|
|
521
541
|
endValue_1 = getValueOfProjectConstant(endValue_1, currentUser, timezone);
|
|
522
542
|
}
|
|
523
|
-
else {
|
|
543
|
+
else if (!isFixedValue) {
|
|
524
544
|
endValue_1 = constants.filter(function (constant) { return constant.name == endValue_1; });
|
|
525
545
|
}
|
|
526
546
|
}
|
|
@@ -557,6 +577,8 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
557
577
|
var key_1 = value.replace("ENTITY::", "");
|
|
558
578
|
return externalParams[key_1] ? externalParams[key_1] : "";
|
|
559
579
|
}
|
|
580
|
+
if ((0, exports.isFixedValueQuery)(value))
|
|
581
|
+
return value.replace("FIXED_VALUE::", "");
|
|
560
582
|
//TODO: This is just to confirm if external then it should be get from externalParams
|
|
561
583
|
if (requiredExternal) {
|
|
562
584
|
//TODO: Value returns from here undefined.
|
|
@@ -573,6 +595,9 @@ var checkDate = function (queryValue) {
|
|
|
573
595
|
return ("" + queryValue).match(date_util_1.DATE_REGEX);
|
|
574
596
|
};
|
|
575
597
|
var getMinMaxValue = function (value) {
|
|
598
|
+
var isFixedValue = (0, exports.isFixedValueQuery)(value);
|
|
599
|
+
if (isFixedValue)
|
|
600
|
+
value = value.replace("FIXED_VALUE::", "");
|
|
576
601
|
var isValid = value && value.includes("---");
|
|
577
602
|
if (isValid) {
|
|
578
603
|
var isInteger = value.includes("^");
|
|
@@ -580,10 +605,10 @@ var getMinMaxValue = function (value) {
|
|
|
580
605
|
var endValue = result[1];
|
|
581
606
|
if (isInteger && result.length)
|
|
582
607
|
endValue = endValue.slice(0, -1);
|
|
583
|
-
return { startValue: result[0], endValue: endValue, isInteger: isInteger };
|
|
608
|
+
return { startValue: result[0], endValue: endValue, isInteger: isInteger, isFixedValue: isFixedValue };
|
|
584
609
|
}
|
|
585
610
|
else {
|
|
586
|
-
return { startValue: "", endValue: "" };
|
|
611
|
+
return { startValue: "", endValue: "", isFixedValue: isFixedValue };
|
|
587
612
|
}
|
|
588
613
|
};
|
|
589
614
|
exports.getMinMaxValue = getMinMaxValue;
|
package/build/utils/s3-util.js
CHANGED
|
@@ -213,7 +213,14 @@ var processFileUploadToS3 = function (file, s3Client, s3Config, publicS3Client,
|
|
|
213
213
|
});
|
|
214
214
|
});
|
|
215
215
|
};
|
|
216
|
-
var imageTypeFiles = [
|
|
216
|
+
var imageTypeFiles = [
|
|
217
|
+
"image/png",
|
|
218
|
+
"image/jpeg",
|
|
219
|
+
"image/jpg",
|
|
220
|
+
"image/heic",
|
|
221
|
+
"image/webp",
|
|
222
|
+
"image/heif",
|
|
223
|
+
];
|
|
217
224
|
var processAndRemoveExifDataFromImg = function (files) { return __awaiter(void 0, void 0, void 0, function () {
|
|
218
225
|
var promises, error_2;
|
|
219
226
|
return __generator(this, function (_a) {
|
|
@@ -333,7 +340,15 @@ var handleIconUpload = function (file, contentType, publicS3Client, publicS3Conf
|
|
|
333
340
|
_b.trys.push([1, 6, , 7]);
|
|
334
341
|
if (!(isGenerateIcons &&
|
|
335
342
|
fileSize < 157286400 && //150mb
|
|
336
|
-
[
|
|
343
|
+
[
|
|
344
|
+
"image/png",
|
|
345
|
+
"image/jpeg",
|
|
346
|
+
"image/gif",
|
|
347
|
+
"image/webp",
|
|
348
|
+
"image/heif",
|
|
349
|
+
"image/heic",
|
|
350
|
+
"application/pdf",
|
|
351
|
+
].includes(contentType))) return [3 /*break*/, 4];
|
|
337
352
|
return [4 /*yield*/, generateDynamicIcons(filePath, iconSizes, contentType)];
|
|
338
353
|
case 2:
|
|
339
354
|
iconFiles = _b.sent();
|
|
@@ -410,6 +425,9 @@ var generateStaticIcons = function (type) {
|
|
|
410
425
|
case "image/png":
|
|
411
426
|
case "image/jpeg":
|
|
412
427
|
case "image/gif":
|
|
428
|
+
case "image/heif":
|
|
429
|
+
case "image/webp":
|
|
430
|
+
case "image/heic":
|
|
413
431
|
smallIcon =
|
|
414
432
|
"https://drapcode-static.s3.amazonaws.com/img/placeholder-img.png";
|
|
415
433
|
mediumIcon =
|