@izara_project/izara-shared-search-and-sort 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/index.js CHANGED
@@ -19,9 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
  import SearchSortSharedLib from './src/SearchSortSharedLib.js';
20
20
  import FiltersSharedLib from './src/FiltersSharedLib.js'
21
21
  import DataFieldsSharedLib from './src/DataFieldsSharedLib.js'
22
+ import LogicalStructureSharedLib from './src/LogicalStructureSharedLib.js';
22
23
 
23
24
  export {
24
25
  SearchSortSharedLib,
25
26
  FiltersSharedLib,
26
- DataFieldsSharedLib
27
+ DataFieldsSharedLib,
28
+ LogicalStructureSharedLib
27
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-shared-search-and-sort",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Shared Libraries frontend/backend for Search and Sort stack",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,7 +25,9 @@
25
25
  "@izara_project/izara-core-library-core": "^1.0.13",
26
26
  "@izara_project/izara-core-library-external-request": "^1.0.13",
27
27
  "@izara_project/izara-core-library-search-result": "^1.0.6",
28
+ "@izara_project/izara-core-library-service-schemas": "^1.0.105",
28
29
  "@izara_project/izara-shared": "^1.0.109",
30
+ "@izara_project/izara-shared-service-schemas": "^1.0.35",
29
31
  "object-hash": "^3.0.0"
30
32
  }
31
33
  }
@@ -967,7 +967,7 @@ function checkConditionsLinkStep(
967
967
  canCombine: canCombine,
968
968
  canPerParent: canPerParent,
969
969
  canFilters: canFilters,
970
- requestProperties: requestProperties //use when linkConfig has request but set no set perParent : false, use requestPropertyType: value
970
+ // requestProperties: requestProperties //use when linkConfig has request but set no set perParent : false, use requestPropertyType: value
971
971
  }
972
972
  }
973
973
 
@@ -1131,410 +1131,6 @@ function filterLogicalElements(
1131
1131
 
1132
1132
  };
1133
1133
 
1134
-
1135
-
1136
- function combineLogicalStructure(
1137
- objType,
1138
- initialLogicalElementId,
1139
- logicalElements,
1140
- ) {
1141
- console.log('combineLogicalStructure: ', {
1142
- objType,
1143
- initialLogicalElementId,
1144
- logicalElements,
1145
- });
1146
-
1147
- let returnInitialElementId = null;
1148
- let initialLogicalElementObject = logicalElements[initialLogicalElementId]
1149
- if (initialLogicalElementObject.logicalElementType !== 'logicalStructure') {
1150
- returnInitialElementId = initialLogicalElementId;
1151
- } else {
1152
- returnInitialElementId = logicalElements[initialLogicalElementId].initialLogicalElementId;
1153
- };
1154
- console.log('returnInitialElementId', returnInitialElementId);
1155
-
1156
- let previousLogicalElementId = null;
1157
- let previousLogicalElementObject = null;
1158
-
1159
- let operationLogicalElementId = null;
1160
- let operationLogicalElementObject = null;
1161
-
1162
- let nextLogicalElementId = null;
1163
- let nextLogicalElementObject = null;
1164
-
1165
- let returnLogicalElements = {};
1166
-
1167
- let errorsObject = {};
1168
- let errorsFound = [];
1169
-
1170
- for (const [logicalElementId, logicalElementObject] of Object.entries(logicalElements)) {
1171
- console.log('extract logicalELements: ', { initialLogicalElementId, logicalElementId, logicalElementObject });
1172
-
1173
- if (initialLogicalElementId !== logicalElementId) {
1174
- continue;
1175
- };
1176
-
1177
- let logicalElementType = logicalElementObject.logicalElementType;
1178
- console.log('logicalElementType: ', logicalElementType);
1179
-
1180
- if (logicalElementType === 'openBracket') {
1181
- console.log('----------type: openBracket ----------');
1182
- if (!logicalElementObject.hasOwnProperty('previousLogicalElementId')) {
1183
- errorsObject[logicalElementId] = `this logical structure is not set previousLogicalElementId`;
1184
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set previousLogicalElementId`);
1185
- };
1186
- if (!logicalElementObject.hasOwnProperty('nextLogicalElementId')) {
1187
- errorsObject[logicalElementId] = `this logical structure is not set nextLogicalElementId`;
1188
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set nextLogicalElementId`);
1189
- };
1190
-
1191
- nextLogicalElementId = logicalElementId;
1192
- nextLogicalElementObject = { [nextLogicalElementId]: logicalElementObject };
1193
- initialLogicalElementId = logicalElementObject.nextLogicalElementId;
1194
-
1195
- } else if (logicalElementType === 'logicalStructure') {
1196
- console.log('----------type: logicalStructure ----------');
1197
-
1198
- if (!logicalElementObject.hasOwnProperty('objType')) {
1199
- errorsObject[logicalElementId] = `this logical structure is not set objType`;
1200
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set objType`);
1201
- };
1202
- if (!logicalElementObject.hasOwnProperty('initialLogicalElementId')) {
1203
- errorsObject[logicalElementId] = `this logical structure is not set initialLogicalElementId`;
1204
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set initialLogicalElementId`);
1205
- };
1206
- if (!logicalElementObject.hasOwnProperty('previousLogicalElementId')) {
1207
- errorsObject[logicalElementId] = `this logical structure is not set previousLogicalElementId`;
1208
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set previousLogicalElementId`);
1209
- };
1210
- if (!logicalElementObject.hasOwnProperty('nextLogicalElementId')) {
1211
- errorsObject[logicalElementId] = `this logical structure is not set nextLogicalElementId`;
1212
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set nextLogicalElementId`);
1213
- };
1214
- if (!logicalElementObject.hasOwnProperty('logicalElements')) {
1215
- errorsObject[logicalElementId] = `this logical structure is not set logicalElements`;
1216
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set logicalElements`);
1217
- };
1218
-
1219
- nextLogicalElementId = logicalElementObject.initialLogicalElementId;
1220
- nextLogicalElementObject = logicalElementObject.logicalElements;
1221
-
1222
- if (logicalElementObject.nextLogicalElementId !== null) {
1223
- initialLogicalElementId = logicalElementObject.nextLogicalElementId;
1224
- };
1225
-
1226
- } else if (logicalElementType === 'operation') {
1227
- console.log('----------type: operation ----------');
1228
- if (!logicalElementObject.hasOwnProperty('previousLogicalElementId')) {
1229
- errorsObject[logicalElementId] = `this logical structure is not set previousLogicalElementId`;
1230
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set previousLogicalElementId`);
1231
- };
1232
- if (!logicalElementObject.hasOwnProperty('nextLogicalElementId')) {
1233
- errorsObject[logicalElementId] = `this logical structure is not set nextLogicalElementId`;
1234
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set nextLogicalElementId`);
1235
- };
1236
- if (!logicalElementObject.hasOwnProperty('operation')) {
1237
- errorsObject[logicalElementId] = `this logical structure is not set operation`;
1238
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set operation`);
1239
- };
1240
-
1241
- operationLogicalElementId = logicalElementId;
1242
- operationLogicalElementObject = logicalElementObject;
1243
- initialLogicalElementId = logicalElementObject.nextLogicalElementId;
1244
- continue;
1245
-
1246
- } else if (logicalElementType === 'closeBracket') {
1247
- console.log('----------type: closeBracket ----------');
1248
- if (!logicalElementObject.hasOwnProperty('previousLogicalElementId')) {
1249
- errorsObject[logicalElementId] = `this logical structure is not set previousLogicalElementId`;
1250
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set previousLogicalElementId`);
1251
- };
1252
- if (!logicalElementObject.hasOwnProperty('nextLogicalElementId')) {
1253
- errorsObject[logicalElementId] = `this logical structure is not set nextLogicalElementId`;
1254
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set nextLogicalElementId`);
1255
- };
1256
-
1257
- nextLogicalElementId = logicalElementId;
1258
- nextLogicalElementObject = { [nextLogicalElementId]: logicalElementObject };
1259
- initialLogicalElementId = logicalElementObject.nextLogicalElementId;
1260
-
1261
- } else {
1262
- //* error
1263
- errorsObject[logicalElementId] = `has error on logicalElementType: ${logicalElementType}`;
1264
- errorsFound.push(`has error on logicalElementType in logicalElementId: ${logicalElementId}`);
1265
- };
1266
-
1267
- if (errorsFound.length > 0) {
1268
- return [null, errorsObject, errorsFound];
1269
- };
1270
-
1271
- let operations = null;
1272
- let operationErrorObjects = {};
1273
- let operationErrors = [];
1274
-
1275
- [
1276
- previousLogicalElementId,
1277
- previousLogicalElementObject,
1278
- operations,
1279
- operationErrorObjects,
1280
- operationErrors
1281
- ] = combineOperation(
1282
- previousLogicalElementId,
1283
- previousLogicalElementObject,
1284
- operationLogicalElementId,
1285
- operationLogicalElementObject,
1286
- nextLogicalElementId,
1287
- nextLogicalElementObject
1288
- );
1289
- console.log('return combineOperation: ', {
1290
- previousLogicalElementId,
1291
- previousLogicalElementObject,
1292
- operations,
1293
- operationErrors
1294
- });
1295
-
1296
- if (operationErrors.length > 0) {
1297
- Object.assign(errorsObject, operationErrorObjects);
1298
- };
1299
-
1300
- if (operations !== null) {
1301
- Object.assign(returnLogicalElements, operations);
1302
- operationLogicalElementId = null;
1303
- operationLogicalElementObject = null;
1304
- } else {
1305
- Object.assign(returnLogicalElements, previousLogicalElementObject);
1306
- };
1307
-
1308
- } //end iterate logicalElements
1309
-
1310
- console.log('returnLogicalElements: ', { returnLogicalElements });
1311
-
1312
- let returnComplexLogicalStructure = {
1313
- objType: objType,
1314
- initialLogicalElementId: returnInitialElementId,
1315
- logicalElements: returnLogicalElements
1316
- };
1317
-
1318
- return [returnComplexLogicalStructure, errorsObject, errorsFound];
1319
-
1320
- };
1321
-
1322
- function combineOperation(
1323
- previousLogicalElementId,
1324
- previousLogicalElementObject,
1325
- operationLogicalElementId,
1326
- operationLogicalElementObject,
1327
- nextLogicalElementId,
1328
- nextLogicalElementObject
1329
- ) {
1330
- console.log('combineOperation: ', {
1331
- previousLogicalElementId,
1332
- previousLogicalElementObject,
1333
- operationLogicalElementId,
1334
- operationLogicalElementObject,
1335
- nextLogicalElementId,
1336
- nextLogicalElementObject
1337
- });
1338
-
1339
- let errorsObject = {};
1340
- let errorsFound = []
1341
-
1342
- if (!nextLogicalElementObject) {
1343
- errorsFound.push('cannot found current filterElement object')
1344
- return [null, null, null, errorsObject, errorsFound];
1345
- };
1346
-
1347
- if (!previousLogicalElementObject) {
1348
- return [nextLogicalElementId, nextLogicalElementObject, null, errorsObject, errorsFound];
1349
- };
1350
-
1351
- if (!operationLogicalElementObject) {
1352
- console.log('------------ previous & current ------------', {
1353
- previousLogicalElementId,
1354
- previousLogicalElementObject,
1355
- operationLogicalElementId,
1356
- operationLogicalElementObject,
1357
- nextLogicalElementId,
1358
- nextLogicalElementObject
1359
- });
1360
-
1361
- let operations = {};
1362
- let returnnextElementId = null;
1363
- let returnNextElementObject = null;
1364
-
1365
- if (previousLogicalElementObject[previousLogicalElementId].logicalElementType === 'openBracket') {
1366
- if (nextLogicalElementObject[nextLogicalElementId].logicalElementType === 'closeBracket') {
1367
-
1368
- if (Object.entries(previousLogicalElementObject).length <= 2) {
1369
-
1370
- previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId = nextLogicalElementId;
1371
- nextLogicalElementObject[nextLogicalElementId].previousLogicalElementId = previousLogicalElementId;
1372
-
1373
- } else {
1374
-
1375
- if (previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId === null) {
1376
- previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId = nextLogicalElementId;
1377
- nextLogicalElementObject[nextLogicalElementId].previousLogicalElementId = previousLogicalElementId;
1378
-
1379
- } else {
1380
-
1381
- let checkNextLogicalElementId = previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId;
1382
- console.log('checkNextLogicalElementId:', checkNextLogicalElementId);
1383
-
1384
- for (let i = 0; i < Object.entries(previousLogicalElementObject).length; i++) {
1385
- let [logicalElementId, logicalObject] = Object.entries(previousLogicalElementObject)[i];
1386
- console.log('extract logical element: ', { logicalElementId, logicalObject });
1387
-
1388
- if (logicalElementId !== checkNextLogicalElementId) {
1389
- continue;
1390
- };
1391
-
1392
- console.log('------------- has next logicalElemet to continue -------------');
1393
-
1394
- if (logicalObject.nextLogicalElementId !== null) {
1395
- checkNextLogicalElementId = logicalObject.nextLogicalElementId;
1396
- continue;
1397
- } else {
1398
- previousLogicalElementObject[logicalElementId].nextLogicalElementId = nextLogicalElementId;
1399
- nextLogicalElementObject[nextLogicalElementId].previousLogicalElementId = logicalElementId;
1400
- };
1401
- };
1402
- };
1403
- };
1404
-
1405
- operations = Object.assign(previousLogicalElementObject, nextLogicalElementObject);
1406
- console.log('operations: ', operations);
1407
-
1408
- returnnextElementId = nextLogicalElementId;
1409
- returnNextElementObject = nextLogicalElementObject;
1410
-
1411
- } else {
1412
-
1413
- previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId = nextLogicalElementId;
1414
- nextLogicalElementObject[nextLogicalElementId].previousLogicalElementId = previousLogicalElementId;
1415
-
1416
- operations = Object.assign(previousLogicalElementObject, nextLogicalElementObject);
1417
-
1418
- console.log('operations: ', operations);
1419
- returnnextElementId = nextLogicalElementId;
1420
- returnNextElementObject = nextLogicalElementObject;
1421
-
1422
- };
1423
-
1424
- } else if (previousLogicalElementObject[previousLogicalElementId].logicalElementType === 'closeBracket') {
1425
-
1426
- if (nextLogicalElementObject[nextLogicalElementId].logicalElementType === 'closeBracket') {
1427
-
1428
- previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId = nextLogicalElementId;
1429
- nextLogicalElementObject[nextLogicalElementId].previousLogicalElementId = previousLogicalElementId;
1430
-
1431
- operations = Object.assign(previousLogicalElementObject, nextLogicalElementObject);
1432
- console.log('operations: ', operations);
1433
-
1434
- returnnextElementId = nextLogicalElementId;
1435
- returnNextElementObject = nextLogicalElementObject;
1436
-
1437
- } else {
1438
- errorsObject[nextLogicalElementId] = 'this path has logical structure error';
1439
- errorsFound.push(`${nextLogicalElementId}: this path has logical structure error`);
1440
- };
1441
-
1442
- } else {
1443
-
1444
- if (nextLogicalElementObject[nextLogicalElementId].logicalElementType === 'closeBracket') {
1445
-
1446
- console.log('previousLogicalElementObject: ', previousLogicalElementObject);
1447
-
1448
- if (Object.entries(previousLogicalElementObject).length <= 2) {
1449
-
1450
- previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId = nextLogicalElementId;
1451
- nextLogicalElementObject[nextLogicalElementId].previousLogicalElementId = previousLogicalElementId;
1452
-
1453
- } else {
1454
-
1455
- if (previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId === null) {
1456
- previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId = nextLogicalElementId;
1457
- nextLogicalElementObject[nextLogicalElementId].previousLogicalElementId = previousLogicalElementId;
1458
-
1459
- } else {
1460
-
1461
- let checkNextLogicalElementId = previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId;
1462
- console.log('checkNextLogicalElementId:', checkNextLogicalElementId);
1463
-
1464
- for (let i = 0; i < Object.entries(previousLogicalElementObject).length; i++) {
1465
- let [logicalElementId, logicalObject] = Object.entries(previousLogicalElementObject)[i];
1466
- console.log('extract logical element: ', { logicalElementId, logicalObject });
1467
-
1468
- if (logicalElementId !== checkNextLogicalElementId) {
1469
- continue;
1470
- };
1471
-
1472
- console.log('------------- has next logicalElemet to continue -------------');
1473
-
1474
- if (logicalObject.nextLogicalElementId !== null) {
1475
- checkNextLogicalElementId = logicalObject.nextLogicalElementId;
1476
- continue;
1477
- } else {
1478
- previousLogicalElementObject[logicalElementId].nextLogicalElementId = nextLogicalElementId;
1479
- nextLogicalElementObject[nextLogicalElementId].previousLogicalElementId = logicalElementId;
1480
- };
1481
- };
1482
- };
1483
- };
1484
-
1485
- operations = Object.assign(previousLogicalElementObject, nextLogicalElementObject);
1486
- console.log("operations: ", operations);
1487
-
1488
- returnnextElementId = nextLogicalElementId;
1489
- returnNextElementObject = nextLogicalElementObject;
1490
-
1491
- } else {
1492
- errorsObject[nextLogicalElementId] = 'this path has logical structure error';
1493
- errorsFound.push(`${nextLogicalElementId}: this path has logical structure error`);
1494
- };
1495
- };
1496
- return [returnnextElementId, returnNextElementObject, operations, errorsObject, errorsFound];
1497
- };
1498
-
1499
- if (previousLogicalElementObject && operationLogicalElementObject && nextLogicalElementObject) {
1500
- console.log('------------ previous & operation & current ------------', {
1501
- previousLogicalElementId,
1502
- previousLogicalElementObject,
1503
- operationLogicalElementId,
1504
- operationLogicalElementObject,
1505
- nextLogicalElementId,
1506
- nextLogicalElementObject
1507
- });
1508
-
1509
- let operations = {};
1510
-
1511
- previousLogicalElementObject[previousLogicalElementId].nextLogicalElementId = operationLogicalElementId;
1512
- nextLogicalElementObject[nextLogicalElementId].previousLogicalElementId = operationLogicalElementId;
1513
-
1514
- operationLogicalElementObject.previousLogicalElementId = previousLogicalElementId;
1515
- operationLogicalElementObject.nextLogicalElementId = nextLogicalElementId;
1516
-
1517
- console.log('after set previous and next: ', {
1518
- previousLogicalElementObject,
1519
- operationLogicalElementObject,
1520
- nextLogicalElementObject
1521
- });
1522
-
1523
- operations = Object.assign(previousLogicalElementObject, { [operationLogicalElementId]: operationLogicalElementObject }, nextLogicalElementObject);
1524
-
1525
- return [nextLogicalElementId, nextLogicalElementObject, operations, errorsObject, errorsFound];
1526
-
1527
- } else {
1528
- errorsObject[previousLogicalElementId] = 'found error that incorrect of logical structure';
1529
- errorsObject[currentLogicalElementId] = 'found error that incorrect of logical structure';
1530
- errorsObject[operationLogicalElementId] = 'found error that incorrect of logical structure';
1531
- errorsFound.push('found error that incorrect of logical structure');
1532
-
1533
- return [null, null, null, errorsObject, errorsFound];
1534
- };
1535
-
1536
- };
1537
-
1538
1134
  function splitFilterElements(
1539
1135
  runningFilterMainId,
1540
1136
  runningFilterObject,
@@ -1610,8 +1206,4 @@ export default {
1610
1206
  // validateOperation,
1611
1207
  filterLogicalElements,
1612
1208
  // splitFilterElements,
1613
-
1614
- combineLogicalStructure,
1615
- // combineOperation,
1616
-
1617
1209
  }