@optimiser/common 1.0.346 → 1.0.348
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/dist/lib/connection.js +1 -1
- package/dist/lib/utility.js +48 -33
- package/package.json +2 -2
package/dist/lib/connection.js
CHANGED
|
@@ -435,7 +435,7 @@ var Connection = /** @class */ (function () {
|
|
|
435
435
|
if (!user) {
|
|
436
436
|
return _this.ReturnJsonResponse(req, res, {
|
|
437
437
|
Data: {},
|
|
438
|
-
Message: "
|
|
438
|
+
Message: "Your previous session has expired. Please log in.",
|
|
439
439
|
Status: 401,
|
|
440
440
|
Type: "ERROR",
|
|
441
441
|
OriginalStatus: 401
|
package/dist/lib/utility.js
CHANGED
|
@@ -1842,7 +1842,7 @@ function CheckDataBeforeAdd(updateObj, objectSchema, db) {
|
|
|
1842
1842
|
updateObj[fldName] = val;
|
|
1843
1843
|
return [3 /*break*/, 7];
|
|
1844
1844
|
case 6:
|
|
1845
|
-
if (fieldSchema.UIDataType == 'formula')
|
|
1845
|
+
if (fieldSchema.UIDataType == 'formula' || fieldSchema.UIDataType == 'eformula')
|
|
1846
1846
|
delete updateObj[fldName];
|
|
1847
1847
|
_a.label = 7;
|
|
1848
1848
|
case 7: return [2 /*return*/];
|
|
@@ -1885,7 +1885,7 @@ function CheckDataBeforeUpdate(updateObj, objectData, objectSchema, db) {
|
|
|
1885
1885
|
case 1:
|
|
1886
1886
|
fieldSchema = objectSchema.Fields.find(function (x) { return x.Name == fldName; });
|
|
1887
1887
|
if (!fieldSchema) return [3 /*break*/, 5];
|
|
1888
|
-
if (!(fieldSchema.UIDataType == 'autoincrement' || fieldSchema.UIDataType == 'formula')) return [3 /*break*/, 2];
|
|
1888
|
+
if (!(fieldSchema.UIDataType == 'autoincrement' || fieldSchema.UIDataType == 'formula' || fieldSchema.UIDataType == 'eformula')) return [3 /*break*/, 2];
|
|
1889
1889
|
delete updateObj[fldName];
|
|
1890
1890
|
return [3 /*break*/, 5];
|
|
1891
1891
|
case 2:
|
|
@@ -2224,10 +2224,15 @@ function FilterConditions(condition, match, fields) {
|
|
|
2224
2224
|
else {
|
|
2225
2225
|
var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
|
|
2226
2226
|
if (field) {
|
|
2227
|
+
// uiDataType was added by Shahzaib on 19-10-2023
|
|
2228
|
+
var uiDataType = field.Schema.UIDataType;
|
|
2229
|
+
if (uiDataType == 'eformula' && field.Schema.FormulaOutType) {
|
|
2230
|
+
uiDataType = field.Schema.FormulaOutType;
|
|
2231
|
+
}
|
|
2227
2232
|
var matchValue = void 0;
|
|
2228
2233
|
var fldName = field.UniqueID;
|
|
2229
2234
|
if (obj.Value !== undefined && obj.Value !== null && obj.Value.length > 0) {
|
|
2230
|
-
if (["lookup", "multilookup"].includes(
|
|
2235
|
+
if (["lookup", "multilookup"].includes(uiDataType)) {
|
|
2231
2236
|
fldName += '_SearchValue';
|
|
2232
2237
|
}
|
|
2233
2238
|
//added by nirbhay on 25.04.22 to add dropdown and multiselect in any type of fields for filter
|
|
@@ -2246,7 +2251,7 @@ function FilterConditions(condition, match, fields) {
|
|
|
2246
2251
|
}
|
|
2247
2252
|
}
|
|
2248
2253
|
}
|
|
2249
|
-
switch (
|
|
2254
|
+
switch (uiDataType) {
|
|
2250
2255
|
case "int":
|
|
2251
2256
|
obj.Value = parseInt(obj.Value);
|
|
2252
2257
|
break;
|
|
@@ -2266,7 +2271,7 @@ function FilterConditions(condition, match, fields) {
|
|
|
2266
2271
|
// Or Condition code in NOT_CONTAINS filter was added by Shahzaib for QPC-6368
|
|
2267
2272
|
var orCondInNotContains = void 0;
|
|
2268
2273
|
// Below If condition added by Nidhi - QPC-5338
|
|
2269
|
-
if (
|
|
2274
|
+
if (uiDataType === 'date' || uiDataType === 'datetime') {
|
|
2270
2275
|
var operator = obj.Operator;
|
|
2271
2276
|
var startCompareDate = void 0, endCompareDate = void 0;
|
|
2272
2277
|
// below moment date was converted into utc by Shahzaib on 22/05/2023
|
|
@@ -2286,7 +2291,7 @@ function FilterConditions(condition, match, fields) {
|
|
|
2286
2291
|
case "CONTAINS":
|
|
2287
2292
|
if (obj.Value === '')
|
|
2288
2293
|
matchValue = { '$in': [null, ''] };
|
|
2289
|
-
else if (["dropdown", "multiselect"].includes(
|
|
2294
|
+
else if (["dropdown", "multiselect"].includes(uiDataType) || field.Schema.SearchType == 'multiselect') {
|
|
2290
2295
|
matchValue = { '$in': obj.Value };
|
|
2291
2296
|
}
|
|
2292
2297
|
else
|
|
@@ -2295,7 +2300,7 @@ function FilterConditions(condition, match, fields) {
|
|
|
2295
2300
|
case "NOT_CONTAINS":
|
|
2296
2301
|
if (obj.Value === '')
|
|
2297
2302
|
matchValue = { '$nin': [null, ''] };
|
|
2298
|
-
else if (["dropdown", "multiselect"].includes(
|
|
2303
|
+
else if (["dropdown", "multiselect"].includes(uiDataType) || field.Schema.SearchType == 'multiselect') {
|
|
2299
2304
|
matchValue = { '$nin': obj.Value };
|
|
2300
2305
|
}
|
|
2301
2306
|
else {
|
|
@@ -2313,21 +2318,21 @@ function FilterConditions(condition, match, fields) {
|
|
|
2313
2318
|
else if (field.Schema.SearchType == 'dropdown') {
|
|
2314
2319
|
matchValue = { '$eq': obj.Value };
|
|
2315
2320
|
}
|
|
2316
|
-
// else if (["date", "datetime"].includes(
|
|
2321
|
+
// else if (["date", "datetime"].includes(uiDataType)) {
|
|
2317
2322
|
// matchValue = { '$gte': moment(obj.Value).startOf('day').toDate(), '$lte': moment(obj.Value).endOf('day').toDate() };
|
|
2318
2323
|
// }
|
|
2319
|
-
else if (["int", "decimal", "percent"].includes(
|
|
2324
|
+
else if (["int", "decimal", "percent"].includes(uiDataType)) {
|
|
2320
2325
|
matchValue = { '$eq': obj.Value };
|
|
2321
2326
|
}
|
|
2322
|
-
else if (
|
|
2327
|
+
else if (uiDataType == 'checkbox') {
|
|
2323
2328
|
if (obj.Value == 'true' || obj.Value === true)
|
|
2324
2329
|
matchValue = true;
|
|
2325
2330
|
else
|
|
2326
2331
|
matchValue = { $ne: true };
|
|
2327
2332
|
}
|
|
2328
|
-
else if (["lookup", "multilookup"].includes(
|
|
2333
|
+
else if (["lookup", "multilookup"].includes(uiDataType) && obj.ValueType == 'ObjectID') {
|
|
2329
2334
|
if (obj.Value) {
|
|
2330
|
-
if (
|
|
2335
|
+
if (uiDataType == "lookup")
|
|
2331
2336
|
matchValue = obj.Value;
|
|
2332
2337
|
else {
|
|
2333
2338
|
matchValue = {
|
|
@@ -2345,7 +2350,7 @@ function FilterConditions(condition, match, fields) {
|
|
|
2345
2350
|
else if (field.Schema.SearchType == 'dropdown') {
|
|
2346
2351
|
matchValue = { '$ne': obj.Value };
|
|
2347
2352
|
}
|
|
2348
|
-
else if (["int", "decimal", "percent", "time"].includes(
|
|
2353
|
+
else if (["int", "decimal", "percent", "time"].includes(uiDataType)) {
|
|
2349
2354
|
matchValue = { '$ne': obj.Value };
|
|
2350
2355
|
}
|
|
2351
2356
|
else
|
|
@@ -2353,26 +2358,26 @@ function FilterConditions(condition, match, fields) {
|
|
|
2353
2358
|
break;
|
|
2354
2359
|
case "GREATER_THAN":
|
|
2355
2360
|
if (obj.Value) {
|
|
2356
|
-
// if (["date", "datetime"].includes(
|
|
2361
|
+
// if (["date", "datetime"].includes(uiDataType)) {
|
|
2357
2362
|
// matchValue = { '$gt': moment(obj.Value).endOf('day').toDate() };
|
|
2358
2363
|
// } else
|
|
2359
2364
|
matchValue = { '$gt': obj.Value };
|
|
2360
2365
|
}
|
|
2361
2366
|
break;
|
|
2362
2367
|
case "LESS_THAN":
|
|
2363
|
-
// if (["date", "datetime"].includes(
|
|
2368
|
+
// if (["date", "datetime"].includes(uiDataType)) {
|
|
2364
2369
|
// matchValue = { '$lt': moment(obj.Value).startOf('day').toDate() }
|
|
2365
2370
|
// } else
|
|
2366
2371
|
matchValue = { '$lt': obj.Value };
|
|
2367
2372
|
break;
|
|
2368
2373
|
case "GREATER_OR_EQUAL":
|
|
2369
|
-
// if (["date", "datetime"].includes(
|
|
2374
|
+
// if (["date", "datetime"].includes(uiDataType)) {
|
|
2370
2375
|
// matchValue = { '$gte': moment(obj.Value).startOf('day').toDate() }
|
|
2371
2376
|
// } else
|
|
2372
2377
|
matchValue = { '$gte': obj.Value };
|
|
2373
2378
|
break;
|
|
2374
2379
|
case "LESS_OR_EQUAL":
|
|
2375
|
-
// if (["date", "datetime"].includes(
|
|
2380
|
+
// if (["date", "datetime"].includes(uiDataType)) {
|
|
2376
2381
|
// matchValue = { '$lte': moment(obj.Value).endOf('day').toDate() }
|
|
2377
2382
|
// } else
|
|
2378
2383
|
matchValue = { '$lte': obj.Value };
|
|
@@ -2412,6 +2417,11 @@ function GirdHeaderFilters(filters, fields) {
|
|
|
2412
2417
|
if (field) {
|
|
2413
2418
|
var matchValue = null;
|
|
2414
2419
|
var fldName = field.UniqueID;
|
|
2420
|
+
// uiDataType was added by Shahzaib on 19-10-2023
|
|
2421
|
+
var uiDataType = field.Schema.UIDataType;
|
|
2422
|
+
if (uiDataType == 'eformula' && field.Schema.FormulaOutType) {
|
|
2423
|
+
uiDataType = field.Schema.FormulaOutType;
|
|
2424
|
+
}
|
|
2415
2425
|
//added by nirbhay on 25.04.22 to add dropdown in any type of fields for filter
|
|
2416
2426
|
if (field.Schema.SearchType == 'dropdown') {
|
|
2417
2427
|
matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
|
|
@@ -2419,11 +2429,11 @@ function GirdHeaderFilters(filters, fields) {
|
|
|
2419
2429
|
else if (field.Schema.SearchType == 'multiselect') {
|
|
2420
2430
|
matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
|
|
2421
2431
|
}
|
|
2422
|
-
else if (["lookup", "multilookup"].includes(
|
|
2432
|
+
else if (["lookup", "multilookup"].includes(uiDataType)) {
|
|
2423
2433
|
fldName += '_SearchValue';
|
|
2424
2434
|
matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
|
|
2425
2435
|
}
|
|
2426
|
-
else if (["dropdown", "multiselect"].includes(
|
|
2436
|
+
else if (["dropdown", "multiselect"].includes(uiDataType)) {
|
|
2427
2437
|
if (field.Schema.LookupObject) {
|
|
2428
2438
|
matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
|
|
2429
2439
|
}
|
|
@@ -2431,21 +2441,21 @@ function GirdHeaderFilters(filters, fields) {
|
|
|
2431
2441
|
matchValue = { '$in': obj.Value };
|
|
2432
2442
|
}
|
|
2433
2443
|
}
|
|
2434
|
-
else if (["date", "datetime"].includes(
|
|
2444
|
+
else if (["date", "datetime"].includes(uiDataType))
|
|
2435
2445
|
matchValue = { '$gte': moment_1.default(obj.Value.From).startOf('day').toDate(), '$lte': moment_1.default(obj.Value.To).endOf('day').toDate() };
|
|
2436
|
-
// else if (
|
|
2446
|
+
// else if (uiDataType == 'time')
|
|
2437
2447
|
// matchValue = (obj.Value == 'true');
|
|
2438
|
-
else if (
|
|
2448
|
+
else if (uiDataType == 'checkbox') {
|
|
2439
2449
|
if (obj.Value == 'true')
|
|
2440
2450
|
matchValue = true;
|
|
2441
2451
|
else
|
|
2442
2452
|
matchValue = { $ne: true };
|
|
2443
2453
|
}
|
|
2444
|
-
else if (
|
|
2454
|
+
else if (uiDataType == 'int')
|
|
2445
2455
|
matchValue = { '$eq': parseInt(obj.Value) };
|
|
2446
|
-
else if (["decimal", "percent"].includes(
|
|
2456
|
+
else if (["decimal", "percent"].includes(uiDataType))
|
|
2447
2457
|
matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
|
|
2448
|
-
else if (
|
|
2458
|
+
else if (uiDataType == 'objectid')
|
|
2449
2459
|
matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
|
|
2450
2460
|
else if (field.Schema.IsEqualAndCaseInsensitiveSearch === true)
|
|
2451
2461
|
matchValue = new RegExp('^' + obj.Value + '$', 'i');
|
|
@@ -2478,12 +2488,17 @@ function FieldsGridHeaderFilters(filters, fields) {
|
|
|
2478
2488
|
if (field) {
|
|
2479
2489
|
var matchValue = null;
|
|
2480
2490
|
var fldName = field.UniqueID;
|
|
2481
|
-
|
|
2491
|
+
// uiDataType was added by Shahzaib on 19-10-2023
|
|
2492
|
+
var uiDataType = field.Schema.UIDataType;
|
|
2493
|
+
if (uiDataType == 'eformula' && field.Schema.FormulaOutType) {
|
|
2494
|
+
uiDataType = field.Schema.FormulaOutType;
|
|
2495
|
+
}
|
|
2496
|
+
if (["lookup", "multilookup"].includes(uiDataType)) {
|
|
2482
2497
|
fldName += '_SearchValue';
|
|
2483
2498
|
lookupFieldsSets.push((_a = {}, _a[fldName] = new RegExp(obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), 'i'), _a));
|
|
2484
2499
|
return "continue";
|
|
2485
2500
|
}
|
|
2486
|
-
if (["dropdown", "multiselect"].includes(
|
|
2501
|
+
if (["dropdown", "multiselect"].includes(uiDataType)) {
|
|
2487
2502
|
if (field.Schema.LookupObject) {
|
|
2488
2503
|
matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
|
|
2489
2504
|
}
|
|
@@ -2491,21 +2506,21 @@ function FieldsGridHeaderFilters(filters, fields) {
|
|
|
2491
2506
|
matchValue = { '$in': obj.Value };
|
|
2492
2507
|
}
|
|
2493
2508
|
}
|
|
2494
|
-
else if (["date", "datetime"].includes(
|
|
2509
|
+
else if (["date", "datetime"].includes(uiDataType))
|
|
2495
2510
|
matchValue = { '$gte': moment_1.default(obj.Value.From).startOf('day').toDate(), '$lte': moment_1.default(obj.Value.To).endOf('day').toDate() };
|
|
2496
|
-
// else if (
|
|
2511
|
+
// else if (uiDataType == 'time')
|
|
2497
2512
|
// matchValue = (obj.Value == 'true');
|
|
2498
|
-
else if (
|
|
2513
|
+
else if (uiDataType == 'checkbox') {
|
|
2499
2514
|
if (obj.Value == 'true')
|
|
2500
2515
|
matchValue = true;
|
|
2501
2516
|
else
|
|
2502
2517
|
matchValue = { $ne: true };
|
|
2503
2518
|
}
|
|
2504
|
-
else if (
|
|
2519
|
+
else if (uiDataType == 'int')
|
|
2505
2520
|
matchValue = { '$eq': parseInt(obj.Value) };
|
|
2506
|
-
else if (["decimal", "percent"].includes(
|
|
2521
|
+
else if (["decimal", "percent"].includes(uiDataType))
|
|
2507
2522
|
matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
|
|
2508
|
-
else if (
|
|
2523
|
+
else if (uiDataType == 'objectid')
|
|
2509
2524
|
matchValue = { '$eq': obj.Value };
|
|
2510
2525
|
else
|
|
2511
2526
|
matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optimiser/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.348",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@types/unzipper": "^0.10.3",
|
|
21
21
|
"@types/uuid": "^8.3.0",
|
|
22
22
|
"aws-sdk": "^2.786.0",
|
|
23
|
-
"axios": "^0.21.
|
|
23
|
+
"axios": "^0.21.4",
|
|
24
24
|
"bson": "^4.2.0",
|
|
25
25
|
"exceljs": "^4.3.0",
|
|
26
26
|
"express": "^4.17.1",
|