@fibery/views 10.6.1 → 10.7.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.
- package/lib/views.js +190 -35
- package/package.json +2 -2
package/lib/views.js
CHANGED
|
@@ -11,6 +11,37 @@ var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
|
11
11
|
// Return this symbol from a visitor callback to remove the node from the
|
|
12
12
|
// output. Not supported in all places, add support as needed.
|
|
13
13
|
const REMOVE = Symbol("remove");
|
|
14
|
+
function visitDeleteExpressionInFilterGroup(filter, visitExpression) {
|
|
15
|
+
if (filter.kind !== "group") {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const value = filter.value.map(nestedFilter => {
|
|
19
|
+
if (nestedFilter.kind === "group") {
|
|
20
|
+
return visitFilterGroup(nestedFilter, visitExpression);
|
|
21
|
+
}
|
|
22
|
+
const expression = visitExpression(nestedFilter.value.expression);
|
|
23
|
+
if (!expression) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
...nestedFilter,
|
|
28
|
+
value: {
|
|
29
|
+
...nestedFilter.value,
|
|
30
|
+
expression: expression
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}).filter(Boolean);
|
|
34
|
+
if (value.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
...filter,
|
|
39
|
+
value: value
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInFilter = (schema, fromType, filter) => {
|
|
43
|
+
return visitDeleteExpressionInFilterGroup(filter, expression => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression));
|
|
44
|
+
};
|
|
14
45
|
const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, queryExpression) => {
|
|
15
46
|
const {
|
|
16
47
|
"q/from": fromExpression,
|
|
@@ -86,6 +117,40 @@ const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
|
|
|
86
117
|
}
|
|
87
118
|
return queryExpression;
|
|
88
119
|
};
|
|
120
|
+
function visitFilterGroup(filter, visitExpression, type) {
|
|
121
|
+
if (filter.kind !== "group") {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
...filter,
|
|
126
|
+
value: filter.value.map(nestedFilter => {
|
|
127
|
+
if (nestedFilter.kind === "group") {
|
|
128
|
+
return visitFilterGroup(nestedFilter, visitExpression);
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
...nestedFilter,
|
|
132
|
+
value: {
|
|
133
|
+
...nestedFilter.value,
|
|
134
|
+
expression: visitExpression(nestedFilter.value.expression)
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
})
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const replaceIdsWithNamesInFilter = (schema, fromType, filter) => {
|
|
141
|
+
if (schema.typeObjectsById.hasOwnProperty(fromType)) {
|
|
142
|
+
const typeObject = schema.typeObjectsById[fromType];
|
|
143
|
+
return filter ? visitFilterGroup(filter, expression => visitors.replaceIdsWithNamesVisitor(typeObject).visitExpression(expression)) : null;
|
|
144
|
+
}
|
|
145
|
+
return filter;
|
|
146
|
+
};
|
|
147
|
+
const replaceNamesWithIdsInFilter = (schema, fromType, filter) => {
|
|
148
|
+
if (schema.typeObjectsByName.hasOwnProperty(fromType)) {
|
|
149
|
+
const typeObject = schema.typeObjectsByName[fromType];
|
|
150
|
+
return filter ? visitFilterGroup(filter, expression => visitors.replaceNamesWithIdsVisitor(typeObject).visitExpression(expression)) : null;
|
|
151
|
+
}
|
|
152
|
+
return filter;
|
|
153
|
+
};
|
|
89
154
|
const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
|
|
90
155
|
const {
|
|
91
156
|
"q/from": fromExpression,
|
|
@@ -308,18 +373,32 @@ const enableHideWhenEmptyForCheckedEditableUnit = unit => {
|
|
|
308
373
|
const visitQueryExpressionHolder = (queryHolder, visitor) => {
|
|
309
374
|
if (queryHolder) {
|
|
310
375
|
const {
|
|
311
|
-
query
|
|
376
|
+
query,
|
|
377
|
+
filter
|
|
312
378
|
} = queryHolder;
|
|
379
|
+
const newQueryHolder = {
|
|
380
|
+
...queryHolder
|
|
381
|
+
};
|
|
313
382
|
if (query) {
|
|
314
383
|
const queryNew = visitor.visitQueryExpression(query);
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
384
|
+
if (queryNew) {
|
|
385
|
+
newQueryHolder.query = queryNew;
|
|
386
|
+
} else {
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
const {
|
|
390
|
+
"q/from": fromType
|
|
391
|
+
} = query;
|
|
392
|
+
if (filter && fromType) {
|
|
393
|
+
const filterNew = visitor.visitFilter(fromType, filter);
|
|
394
|
+
if (filterNew) {
|
|
395
|
+
newQueryHolder.filter = filterNew;
|
|
396
|
+
} else {
|
|
397
|
+
newQueryHolder.filter = null;
|
|
319
398
|
}
|
|
320
|
-
}
|
|
399
|
+
}
|
|
321
400
|
}
|
|
322
|
-
return
|
|
401
|
+
return newQueryHolder;
|
|
323
402
|
}
|
|
324
403
|
return queryHolder;
|
|
325
404
|
};
|
|
@@ -433,6 +512,9 @@ const visitView$5 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
433
512
|
query: {
|
|
434
513
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
435
514
|
},
|
|
515
|
+
filter: {
|
|
516
|
+
$apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
|
|
517
|
+
},
|
|
436
518
|
units: {
|
|
437
519
|
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
438
520
|
},
|
|
@@ -457,6 +539,7 @@ const visitView$5 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
457
539
|
const replaceNamesWithIdsViewVisitor = schema => {
|
|
458
540
|
const visitor = {
|
|
459
541
|
visitQueryExpression: queryExpression => replaceNamesWithIdsInQueryExpression(schema, queryExpression),
|
|
542
|
+
visitFilter: (fromType, filter) => replaceNamesWithIdsInFilter(schema, fromType, filter),
|
|
460
543
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
461
544
|
visitEnums: enums => ___default["default"].entries(enums).reduce((result, [type, queryHolder]) => {
|
|
462
545
|
if (schema.typeObjectsByName.hasOwnProperty(type)) {
|
|
@@ -475,6 +558,10 @@ const replaceNamesWithIdsViewVisitor = schema => {
|
|
|
475
558
|
const replaceIdsWithNamesViewVisitor = schema => {
|
|
476
559
|
const visitor = {
|
|
477
560
|
visitQueryExpression: queryExpression => replaceIdsWithNamesInQueryExpression(schema, queryExpression),
|
|
561
|
+
visitFilter: (fromType, filter) => {
|
|
562
|
+
const replaceIdsWithNamesInFilter1 = replaceIdsWithNamesInFilter(schema, fromType, filter);
|
|
563
|
+
return replaceIdsWithNamesInFilter1;
|
|
564
|
+
},
|
|
478
565
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
479
566
|
visitEnums: enums => ___default["default"].entries(enums).reduce((result, [typeId, queryHolder]) => {
|
|
480
567
|
if (schema.typeObjectsById.hasOwnProperty(typeId)) {
|
|
@@ -493,6 +580,7 @@ const replaceIdsWithNamesViewVisitor = schema => {
|
|
|
493
580
|
const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = schema => {
|
|
494
581
|
const visitor = {
|
|
495
582
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
583
|
+
visitFilter: (fromType, filter) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, filter),
|
|
496
584
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression),
|
|
497
585
|
visitEnums: enums => {
|
|
498
586
|
const enumsNew = ___default["default"].entries(enums).reduce((result, [type, queryHolder]) => {
|
|
@@ -517,7 +605,8 @@ const fixUserSelectedUnitsViewVisitor = (schema, {
|
|
|
517
605
|
}) => {
|
|
518
606
|
return {
|
|
519
607
|
visitQueryExpression: queryExpression => queryExpression,
|
|
520
|
-
|
|
608
|
+
visitFilter: (_fromType, filter) => filter,
|
|
609
|
+
visitExpression: (_fromType, expression) => expression,
|
|
521
610
|
visitEnums: enums => enums,
|
|
522
611
|
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
523
612
|
unitDefinitions,
|
|
@@ -542,13 +631,15 @@ const fixUserSelectedUnitsInBoardView = (schema, view, {
|
|
|
542
631
|
};
|
|
543
632
|
const fixContextExpressionWithBrokenPath$7 = (schema, view, defaultContextExpression) => visitView$5(view, {
|
|
544
633
|
visitQueryExpression: query => query,
|
|
545
|
-
|
|
634
|
+
visitFilter: (_fromType, filter) => filter,
|
|
635
|
+
visitExpression: (_fromType, expression) => expression,
|
|
546
636
|
visitEnums: enums => enums,
|
|
547
637
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
548
638
|
});
|
|
549
639
|
const collectGarbage$7 = view => {
|
|
550
640
|
return visitView$5(view, {
|
|
551
641
|
visitQueryExpression: queryExpression => queryExpression,
|
|
642
|
+
visitFilter: (_fromType, filter) => filter,
|
|
552
643
|
visitExpression: (fromType, expression) => expression,
|
|
553
644
|
visitEnums: enums => enums,
|
|
554
645
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
@@ -573,6 +664,7 @@ const enableHideWhenEmptyForCovers = view => {
|
|
|
573
664
|
};
|
|
574
665
|
const enableHideWhenEmptyForCheckedEditableUnits$1 = view => {
|
|
575
666
|
return visitView$5(view, {
|
|
667
|
+
visitFilter: (_fromType, filter) => filter,
|
|
576
668
|
visitQueryExpression: queryExpression => queryExpression,
|
|
577
669
|
visitGroupByExpression: groupBy => groupBy,
|
|
578
670
|
visitExpression: (fromType, expression) => expression,
|
|
@@ -599,6 +691,9 @@ const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
599
691
|
query: {
|
|
600
692
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
601
693
|
},
|
|
694
|
+
filter: {
|
|
695
|
+
$apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
|
|
696
|
+
},
|
|
602
697
|
units: {
|
|
603
698
|
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
604
699
|
},
|
|
@@ -623,17 +718,20 @@ const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
623
718
|
const replaceNamesWithIdsInCalendarView = (schema, view) => {
|
|
624
719
|
return visitView$4(view, {
|
|
625
720
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
721
|
+
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
626
722
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
|
|
627
723
|
});
|
|
628
724
|
};
|
|
629
725
|
const replaceIdsWithNamesInCalendarView = (schema, view) => {
|
|
630
726
|
return visitView$4(view, {
|
|
631
727
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
728
|
+
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
632
729
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
|
|
633
730
|
});
|
|
634
731
|
};
|
|
635
732
|
const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView$4(view, {
|
|
636
733
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
734
|
+
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
637
735
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
638
736
|
});
|
|
639
737
|
const fixUserSelectedUnitsInCalendarView = (schema, view, {
|
|
@@ -641,7 +739,8 @@ const fixUserSelectedUnitsInCalendarView = (schema, view, {
|
|
|
641
739
|
getDefaultUnitTypeForField
|
|
642
740
|
}) => {
|
|
643
741
|
return visitView$4(view, {
|
|
644
|
-
visitExpression: (
|
|
742
|
+
visitExpression: (_fromType, expression) => expression,
|
|
743
|
+
visitFilter: (_fromType, filter) => filter,
|
|
645
744
|
visitQueryExpression: query => query,
|
|
646
745
|
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
647
746
|
unitDefinitions,
|
|
@@ -651,12 +750,14 @@ const fixUserSelectedUnitsInCalendarView = (schema, view, {
|
|
|
651
750
|
};
|
|
652
751
|
const fixContextExpressionWithBrokenPath$6 = (schema, view, defaultContextExpression) => visitView$4(view, {
|
|
653
752
|
visitQueryExpression: query => query,
|
|
753
|
+
visitFilter: (_fromType, filter) => filter,
|
|
654
754
|
visitExpression: (fromType, expression) => expression,
|
|
655
755
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
656
756
|
});
|
|
657
757
|
const collectGarbage$6 = view => {
|
|
658
758
|
return visitView$4(view, {
|
|
659
759
|
visitExpression: (fromType, expression) => expression,
|
|
760
|
+
visitFilter: (_fromType, filter) => filter,
|
|
660
761
|
visitQueryExpression: query => query,
|
|
661
762
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
662
763
|
});
|
|
@@ -664,6 +765,7 @@ const collectGarbage$6 = view => {
|
|
|
664
765
|
const enableHideWhenEmptyForCheckedUnits$3 = view => {
|
|
665
766
|
return visitView$4(view, {
|
|
666
767
|
visitQueryExpression: queryExpression => queryExpression,
|
|
768
|
+
visitFilter: (_fromType, filter) => filter,
|
|
667
769
|
visitGroupByExpression: groupBy => groupBy,
|
|
668
770
|
visitExpression: (fromType, expression) => expression,
|
|
669
771
|
visitEnums: enums => enums,
|
|
@@ -686,6 +788,9 @@ const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
686
788
|
query: {
|
|
687
789
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
688
790
|
},
|
|
791
|
+
filter: {
|
|
792
|
+
$apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
|
|
793
|
+
},
|
|
689
794
|
units: {
|
|
690
795
|
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
691
796
|
},
|
|
@@ -710,17 +815,20 @@ const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
710
815
|
const replaceNamesWithIdsInFeedView = (schema, view) => {
|
|
711
816
|
return visitView$3(view, {
|
|
712
817
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
818
|
+
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
713
819
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
|
|
714
820
|
});
|
|
715
821
|
};
|
|
716
822
|
const replaceIdsWithNamesInFeedView = (schema, view) => {
|
|
717
823
|
return visitView$3(view, {
|
|
718
824
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
825
|
+
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
719
826
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
|
|
720
827
|
});
|
|
721
828
|
};
|
|
722
829
|
const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView$3(view, {
|
|
723
830
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
831
|
+
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
724
832
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
725
833
|
});
|
|
726
834
|
const fixUserSelectedUnitsInFeedView = (schema, view, {
|
|
@@ -728,7 +836,8 @@ const fixUserSelectedUnitsInFeedView = (schema, view, {
|
|
|
728
836
|
getDefaultUnitTypeForField
|
|
729
837
|
}) => {
|
|
730
838
|
return visitView$3(view, {
|
|
731
|
-
visitExpression: (
|
|
839
|
+
visitExpression: (_fromType, expression) => expression,
|
|
840
|
+
visitFilter: (_fromType, filter) => filter,
|
|
732
841
|
visitQueryExpression: query => query,
|
|
733
842
|
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
734
843
|
unitDefinitions,
|
|
@@ -738,12 +847,14 @@ const fixUserSelectedUnitsInFeedView = (schema, view, {
|
|
|
738
847
|
};
|
|
739
848
|
const fixContextExpressionWithBrokenPath$5 = (schema, view, defaultContextExpression) => visitView$3(view, {
|
|
740
849
|
visitQueryExpression: query => query,
|
|
741
|
-
|
|
850
|
+
visitFilter: (_fromType, filter) => filter,
|
|
851
|
+
visitExpression: (_fromType, expression) => expression,
|
|
742
852
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
743
853
|
});
|
|
744
854
|
const collectGarbage$5 = view => {
|
|
745
855
|
return visitView$3(view, {
|
|
746
|
-
visitExpression: (
|
|
856
|
+
visitExpression: (_fromType, expression) => expression,
|
|
857
|
+
visitFilter: (_fromType, filter) => filter,
|
|
747
858
|
visitQueryExpression: query => query,
|
|
748
859
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
749
860
|
});
|
|
@@ -752,9 +863,10 @@ const enableHideWhenEmptyForCheckedUnits$2 = view => {
|
|
|
752
863
|
return visitView$3(view, {
|
|
753
864
|
visitQueryExpression: queryExpression => queryExpression,
|
|
754
865
|
visitGroupByExpression: groupBy => groupBy,
|
|
755
|
-
|
|
866
|
+
visitFilter: (_fromType, filter) => filter,
|
|
867
|
+
visitExpression: (_fromType, expression) => expression,
|
|
756
868
|
visitEnums: enums => enums,
|
|
757
|
-
visitViewUnit: (
|
|
869
|
+
visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
758
870
|
});
|
|
759
871
|
};
|
|
760
872
|
|
|
@@ -836,6 +948,9 @@ const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
836
948
|
query: {
|
|
837
949
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
838
950
|
},
|
|
951
|
+
filter: {
|
|
952
|
+
$apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
|
|
953
|
+
},
|
|
839
954
|
units: {
|
|
840
955
|
$apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
|
|
841
956
|
},
|
|
@@ -860,17 +975,20 @@ const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
860
975
|
const replaceNamesWithIdsInMapView = (schema, view) => {
|
|
861
976
|
return visitView$2(view, {
|
|
862
977
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
978
|
+
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
863
979
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
|
|
864
980
|
});
|
|
865
981
|
};
|
|
866
982
|
const replaceIdsWithNamesInMapView = (schema, view) => {
|
|
867
983
|
return visitView$2(view, {
|
|
868
984
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
985
|
+
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
869
986
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
|
|
870
987
|
});
|
|
871
988
|
};
|
|
872
989
|
const deleteExpressionWithNotFoundFieldsOrTypesInMapView = (schema, view) => visitView$2(view, {
|
|
873
990
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
991
|
+
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
874
992
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
875
993
|
});
|
|
876
994
|
const fixUserSelectedUnitsInMapView = (schema, view, {
|
|
@@ -879,7 +997,8 @@ const fixUserSelectedUnitsInMapView = (schema, view, {
|
|
|
879
997
|
}) => {
|
|
880
998
|
return visitView$2(view, {
|
|
881
999
|
visitQueryExpression: query => query,
|
|
882
|
-
|
|
1000
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1001
|
+
visitExpression: (_fromType, expression) => expression,
|
|
883
1002
|
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
884
1003
|
unitDefinitions,
|
|
885
1004
|
getDefaultUnitTypeForField
|
|
@@ -887,24 +1006,27 @@ const fixUserSelectedUnitsInMapView = (schema, view, {
|
|
|
887
1006
|
});
|
|
888
1007
|
};
|
|
889
1008
|
const fixContextExpressionWithBrokenPath$4 = (schema, view, defaultContextExpression) => visitView$2(view, {
|
|
890
|
-
visitExpression: (
|
|
1009
|
+
visitExpression: (_fromType, expression) => expression,
|
|
891
1010
|
visitQueryExpression: query => query,
|
|
1011
|
+
visitFilter: (_fromType, filter) => filter,
|
|
892
1012
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
893
1013
|
});
|
|
894
1014
|
const collectGarbage$4 = view => {
|
|
895
1015
|
return visitView$2(view, {
|
|
896
1016
|
visitQueryExpression: query => query,
|
|
897
|
-
|
|
898
|
-
|
|
1017
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1018
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1019
|
+
visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE
|
|
899
1020
|
});
|
|
900
1021
|
};
|
|
901
1022
|
const enableHideWhenEmptyForCheckedUnits$1 = view => {
|
|
902
1023
|
return visitView$2(view, {
|
|
903
1024
|
visitQueryExpression: queryExpression => queryExpression,
|
|
904
1025
|
visitGroupByExpression: groupBy => groupBy,
|
|
905
|
-
|
|
1026
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1027
|
+
visitExpression: (_fromType, expression) => expression,
|
|
906
1028
|
visitEnums: enums => enums,
|
|
907
|
-
visitViewUnit: (
|
|
1029
|
+
visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
908
1030
|
});
|
|
909
1031
|
};
|
|
910
1032
|
|
|
@@ -951,6 +1073,9 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
|
|
|
951
1073
|
}).map(item => {
|
|
952
1074
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
953
1075
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
1076
|
+
filter: {
|
|
1077
|
+
$apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
|
|
1078
|
+
},
|
|
954
1079
|
query: {
|
|
955
1080
|
$apply: query => {
|
|
956
1081
|
const visitedQuery = visitor.visitQueryExpression(query);
|
|
@@ -1067,12 +1192,14 @@ const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromT
|
|
|
1067
1192
|
};
|
|
1068
1193
|
const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
1069
1194
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
1195
|
+
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
1070
1196
|
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType, Object.keys(groupBy).map(() => 0)),
|
|
1071
1197
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
1072
1198
|
visitUnitGroupKey: unitGroupKey => replaceNamesWithIdsInUnitGroupKey(unitGroupKey, schema)
|
|
1073
1199
|
});
|
|
1074
1200
|
const replaceIdsWithNamesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
1075
1201
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
1202
|
+
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
1076
1203
|
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType, Object.keys(groupBy).map(() => 0)),
|
|
1077
1204
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
1078
1205
|
visitUnitGroupKey: unitGroupKey => replaceIdsWithNamesInUnitGroupKey(unitGroupKey, getFieldObjectsById(smartFolder, schema))
|
|
@@ -1080,12 +1207,14 @@ const replaceIdsWithNamesInSmartFolder = (schema, smartFolder) => visitSmartFold
|
|
|
1080
1207
|
const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
1081
1208
|
visitQueryExpression: query => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, query),
|
|
1082
1209
|
visitGroupByExpression: (groupBy, fromType, removedItems) => deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression(schema, groupBy, fromType, removedItems),
|
|
1210
|
+
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
1083
1211
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
1084
1212
|
});
|
|
1085
1213
|
const fixContextExpressionWithBrokenPath$3 = (schema, view, defaultContextExpression) => visitSmartFolder(view, {
|
|
1086
1214
|
visitQueryExpression: query => query,
|
|
1087
1215
|
visitGroupByExpression: groupBy => groupBy,
|
|
1088
|
-
visitExpression: (
|
|
1216
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1217
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1089
1218
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
1090
1219
|
});
|
|
1091
1220
|
const fixUserSelectedUnitsInSmartFolder = (schema, view, {
|
|
@@ -1095,7 +1224,8 @@ const fixUserSelectedUnitsInSmartFolder = (schema, view, {
|
|
|
1095
1224
|
return visitSmartFolder(view, {
|
|
1096
1225
|
visitQueryExpression: query => query,
|
|
1097
1226
|
visitGroupByExpression: groupBy => groupBy,
|
|
1098
|
-
|
|
1227
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1228
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1099
1229
|
visitViewUnit: (fromType, unit, units) => {
|
|
1100
1230
|
const {
|
|
1101
1231
|
type,
|
|
@@ -1121,18 +1251,20 @@ const fixUserSelectedUnitsInSmartFolder = (schema, view, {
|
|
|
1121
1251
|
const collectGarbage$3 = view => {
|
|
1122
1252
|
return visitSmartFolder(view, {
|
|
1123
1253
|
visitQueryExpression: query => query,
|
|
1254
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1124
1255
|
visitGroupByExpression: groupBy => groupBy,
|
|
1125
|
-
visitExpression: (
|
|
1126
|
-
visitViewUnit: (
|
|
1256
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1257
|
+
visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE
|
|
1127
1258
|
});
|
|
1128
1259
|
};
|
|
1129
1260
|
const enableHideWhenEmptyForCheckedUnits = view => {
|
|
1130
1261
|
return visitSmartFolder(view, {
|
|
1131
1262
|
visitQueryExpression: queryExpression => queryExpression,
|
|
1132
1263
|
visitGroupByExpression: groupBy => groupBy,
|
|
1133
|
-
visitExpression: (
|
|
1264
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1265
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1134
1266
|
visitEnums: enums => enums,
|
|
1135
|
-
visitViewUnit: (
|
|
1267
|
+
visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
1136
1268
|
});
|
|
1137
1269
|
};
|
|
1138
1270
|
|
|
@@ -1145,6 +1277,9 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
1145
1277
|
query: {
|
|
1146
1278
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
1147
1279
|
},
|
|
1280
|
+
filter: {
|
|
1281
|
+
$apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
|
|
1282
|
+
},
|
|
1148
1283
|
contextExpression: {
|
|
1149
1284
|
$apply: contextExpression => contextExpression ? visitor.visitExpression(fromType, contextExpression) : contextExpression
|
|
1150
1285
|
},
|
|
@@ -1171,35 +1306,41 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
1171
1306
|
});
|
|
1172
1307
|
const replaceNamesWithIdsInTableView = (schema, view) => visitView$1(view, {
|
|
1173
1308
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
1309
|
+
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
1174
1310
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
|
|
1175
1311
|
});
|
|
1176
1312
|
const replaceIdsWithNamesInTableView = (schema, view) => visitView$1(view, {
|
|
1177
1313
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
1314
|
+
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
1178
1315
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
|
|
1179
1316
|
});
|
|
1180
1317
|
const deleteExpressionWithNotFoundFieldsOrTypesInTableView = (schema, view) => visitView$1(view, {
|
|
1181
1318
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
1319
|
+
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
1182
1320
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
1183
1321
|
});
|
|
1184
1322
|
const fixUserSelectedUnitsInTableView = (schema, view, {
|
|
1185
1323
|
unitDefinitions,
|
|
1186
1324
|
getDefaultUnitTypeForField
|
|
1187
1325
|
}) => visitView$1(view, {
|
|
1188
|
-
visitExpression: (
|
|
1326
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1189
1327
|
visitQueryExpression: query => query,
|
|
1328
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1190
1329
|
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
1191
1330
|
unitDefinitions,
|
|
1192
1331
|
getDefaultUnitTypeForField
|
|
1193
1332
|
})
|
|
1194
1333
|
});
|
|
1195
1334
|
const fixContextExpressionWithBrokenPath$2 = (schema, view, defaultContextExpression) => visitView$1(view, {
|
|
1196
|
-
visitExpression: (
|
|
1335
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1336
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1197
1337
|
visitQueryExpression: query => query,
|
|
1198
1338
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
1199
1339
|
});
|
|
1200
1340
|
const collectGarbage$2 = view => {
|
|
1201
1341
|
return visitView$1(view, {
|
|
1202
1342
|
visitExpression: (fromType, expression) => expression,
|
|
1343
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1203
1344
|
visitQueryExpression: query => query,
|
|
1204
1345
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
1205
1346
|
});
|
|
@@ -1213,6 +1354,7 @@ const visitAxis = (axis, visitor) => {
|
|
|
1213
1354
|
const firstOrNull = x => ___default["default"].first(x) || null;
|
|
1214
1355
|
const axisResult = {
|
|
1215
1356
|
...axis,
|
|
1357
|
+
filter: axis.filter ? visitor.visitFilter(fromType, axis.filter) : null,
|
|
1216
1358
|
query: axis.query && visitor.visitQueryExpression(axis.query),
|
|
1217
1359
|
contextExpression: visitContextExpression(fromType, axis.contextExpression, visitor),
|
|
1218
1360
|
units: axis.units && axis.units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE),
|
|
@@ -1253,6 +1395,9 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
1253
1395
|
contextExpression: {
|
|
1254
1396
|
$apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
|
|
1255
1397
|
},
|
|
1398
|
+
filter: {
|
|
1399
|
+
$apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
|
|
1400
|
+
},
|
|
1256
1401
|
query: {
|
|
1257
1402
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
1258
1403
|
},
|
|
@@ -1286,6 +1431,9 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
1286
1431
|
dateExpression: {
|
|
1287
1432
|
$apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
|
|
1288
1433
|
},
|
|
1434
|
+
filter: {
|
|
1435
|
+
$apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
|
|
1436
|
+
},
|
|
1289
1437
|
query: {
|
|
1290
1438
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
1291
1439
|
},
|
|
@@ -1306,12 +1454,14 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
1306
1454
|
const replaceNamesWithIdsInTimelineView = (schema, view) => {
|
|
1307
1455
|
return visitView(view, {
|
|
1308
1456
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
1457
|
+
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
1309
1458
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
|
|
1310
1459
|
});
|
|
1311
1460
|
};
|
|
1312
1461
|
const replaceIdsWithNamesInTimelineView = (schema, view) => {
|
|
1313
1462
|
return visitView(view, {
|
|
1314
1463
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
1464
|
+
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
1315
1465
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
|
|
1316
1466
|
});
|
|
1317
1467
|
};
|
|
@@ -1344,6 +1494,7 @@ const ensureAxisAndItemExpressionInvariant = view => {
|
|
|
1344
1494
|
const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant = true) => {
|
|
1345
1495
|
const viewNew = visitView(view, {
|
|
1346
1496
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
1497
|
+
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
1347
1498
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
1348
1499
|
});
|
|
1349
1500
|
return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant(viewNew) : viewNew;
|
|
@@ -1354,7 +1505,8 @@ const fixUserSelectedUnitsInTimelineView = (schema, view, {
|
|
|
1354
1505
|
}) => {
|
|
1355
1506
|
return visitView(view, {
|
|
1356
1507
|
visitQueryExpression: query => query,
|
|
1357
|
-
visitExpression: (
|
|
1508
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1509
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1358
1510
|
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
1359
1511
|
unitDefinitions,
|
|
1360
1512
|
getDefaultUnitTypeForField
|
|
@@ -1362,24 +1514,27 @@ const fixUserSelectedUnitsInTimelineView = (schema, view, {
|
|
|
1362
1514
|
});
|
|
1363
1515
|
};
|
|
1364
1516
|
const fixContextExpressionWithBrokenPath$1 = (schema, view, defaultContextExpression) => visitView(view, {
|
|
1365
|
-
visitExpression: (
|
|
1517
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1518
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1366
1519
|
visitQueryExpression: query => query,
|
|
1367
1520
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
1368
1521
|
});
|
|
1369
1522
|
const collectGarbage$1 = view => {
|
|
1370
1523
|
return visitView(view, {
|
|
1371
1524
|
visitQueryExpression: query => query,
|
|
1372
|
-
|
|
1373
|
-
|
|
1525
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1526
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1527
|
+
visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE
|
|
1374
1528
|
});
|
|
1375
1529
|
};
|
|
1376
1530
|
const enableHideWhenEmptyForCheckedEditableUnits = view => {
|
|
1377
1531
|
return visitView(view, {
|
|
1378
1532
|
visitQueryExpression: queryExpression => queryExpression,
|
|
1379
1533
|
visitGroupByExpression: groupBy => groupBy,
|
|
1380
|
-
visitExpression: (
|
|
1534
|
+
visitExpression: (_fromType, expression) => expression,
|
|
1535
|
+
visitFilter: (_fromType, filter) => filter,
|
|
1381
1536
|
visitEnums: enums => enums,
|
|
1382
|
-
visitViewUnit: (
|
|
1537
|
+
visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
1383
1538
|
});
|
|
1384
1539
|
};
|
|
1385
1540
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.7.0",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"jest-junit": "13.0.0",
|
|
19
19
|
"lodash": "4.17.21",
|
|
20
20
|
"microbundle": "0.15.1",
|
|
21
|
+
"@fibery/eslint-config": "8.6.0",
|
|
21
22
|
"@fibery/babel-preset": "7.4.0",
|
|
22
23
|
"@fibery/expression-utils": "9.0.5",
|
|
23
|
-
"@fibery/eslint-config": "8.6.0",
|
|
24
24
|
"@fibery/schema": "10.2.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|