@fibery/views 17.0.0 → 17.0.1
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 +27 -16
- package/package.json +4 -4
package/lib/views.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
var immutableUpdate = require('immutability-helper');
|
|
2
2
|
var _ = require('lodash');
|
|
3
|
-
var
|
|
4
|
-
var visitors = require('@fibery/expression-utils/src/visitors');
|
|
3
|
+
var expressionUtils = require('@fibery/expression-utils');
|
|
5
4
|
|
|
6
5
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
6
|
|
|
@@ -11,6 +10,11 @@ var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
|
11
10
|
// Return this symbol from a visitor callback to remove the node from the
|
|
12
11
|
// output. Not supported in all places, add support as needed.
|
|
13
12
|
const REMOVE = Symbol("remove");
|
|
13
|
+
const {
|
|
14
|
+
deleteExpressionsWithNotFoundFieldsVisitor,
|
|
15
|
+
replaceIdsWithNamesVisitor: replaceIdsWithNamesVisitor$1,
|
|
16
|
+
replaceNamesWithIdsVisitor: replaceNamesWithIdsVisitor$1
|
|
17
|
+
} = expressionUtils.visitors;
|
|
14
18
|
function visitDeleteExpressionInFilterGroup(filter, visitExpression) {
|
|
15
19
|
if (filter.kind !== "group") {
|
|
16
20
|
return null;
|
|
@@ -53,10 +57,10 @@ const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, quer
|
|
|
53
57
|
return ___default["default"].pickBy({
|
|
54
58
|
...queryExpression,
|
|
55
59
|
...(whereExpression ? {
|
|
56
|
-
"q/where":
|
|
60
|
+
"q/where": deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitExpression(whereExpression)
|
|
57
61
|
} : null),
|
|
58
62
|
...(orderByExpression ? {
|
|
59
|
-
"q/order-by":
|
|
63
|
+
"q/order-by": deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitOrderByExpression(orderByExpression)
|
|
60
64
|
} : null)
|
|
61
65
|
});
|
|
62
66
|
}
|
|
@@ -65,14 +69,14 @@ const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, quer
|
|
|
65
69
|
const replaceNamesWithIdsInExpression = (schema, fromType, expression) => {
|
|
66
70
|
if (schema.typeObjectsByName.hasOwnProperty(fromType)) {
|
|
67
71
|
const typeObject = schema.typeObjectsByName[fromType];
|
|
68
|
-
return
|
|
72
|
+
return replaceNamesWithIdsVisitor$1(typeObject).visitExpression(expression);
|
|
69
73
|
}
|
|
70
74
|
return expression;
|
|
71
75
|
};
|
|
72
76
|
const replaceIdsWithNamesInExpression = (schema, fromTypeId, expression) => {
|
|
73
77
|
if (schema.typeObjectsById.hasOwnProperty(fromTypeId)) {
|
|
74
78
|
const typeObject = schema.typeObjectsById[fromTypeId];
|
|
75
|
-
return
|
|
79
|
+
return replaceIdsWithNamesVisitor$1(typeObject).visitExpression(expression);
|
|
76
80
|
}
|
|
77
81
|
return expression;
|
|
78
82
|
};
|
|
@@ -108,10 +112,10 @@ const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
|
|
|
108
112
|
"q/from": typeObject.name
|
|
109
113
|
},
|
|
110
114
|
...(whereExpression ? {
|
|
111
|
-
"q/where":
|
|
115
|
+
"q/where": replaceIdsWithNamesVisitor$1(typeObject).visitExpression(whereExpression)
|
|
112
116
|
} : null),
|
|
113
117
|
...(orderByExpression ? {
|
|
114
|
-
"q/order-by":
|
|
118
|
+
"q/order-by": replaceIdsWithNamesVisitor$1(typeObject).visitOrderByExpression(orderByExpression)
|
|
115
119
|
} : null)
|
|
116
120
|
};
|
|
117
121
|
}
|
|
@@ -140,14 +144,14 @@ function visitFilterGroup(filter, visitExpression, type) {
|
|
|
140
144
|
const replaceIdsWithNamesInFilter = (schema, fromType, filter) => {
|
|
141
145
|
if (schema.typeObjectsById.hasOwnProperty(fromType)) {
|
|
142
146
|
const typeObject = schema.typeObjectsById[fromType];
|
|
143
|
-
return filter ? visitFilterGroup(filter, expression =>
|
|
147
|
+
return filter ? visitFilterGroup(filter, expression => replaceIdsWithNamesVisitor$1(typeObject).visitExpression(expression)) : null;
|
|
144
148
|
}
|
|
145
149
|
return filter;
|
|
146
150
|
};
|
|
147
151
|
const replaceNamesWithIdsInFilter = (schema, fromType, filter) => {
|
|
148
152
|
if (schema.typeObjectsByName.hasOwnProperty(fromType)) {
|
|
149
153
|
const typeObject = schema.typeObjectsByName[fromType];
|
|
150
|
-
return filter ? visitFilterGroup(filter, expression =>
|
|
154
|
+
return filter ? visitFilterGroup(filter, expression => replaceNamesWithIdsVisitor$1(typeObject).visitExpression(expression)) : null;
|
|
151
155
|
}
|
|
152
156
|
return filter;
|
|
153
157
|
};
|
|
@@ -165,10 +169,10 @@ const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
|
|
|
165
169
|
"q/from": typeObject.id
|
|
166
170
|
},
|
|
167
171
|
...(whereExpression ? {
|
|
168
|
-
"q/where":
|
|
172
|
+
"q/where": replaceNamesWithIdsVisitor$1(typeObject).visitExpression(whereExpression)
|
|
169
173
|
} : null),
|
|
170
174
|
...(orderByExpression ? {
|
|
171
|
-
"q/order-by":
|
|
175
|
+
"q/order-by": replaceNamesWithIdsVisitor$1(typeObject).visitOrderByExpression(orderByExpression)
|
|
172
176
|
} : null)
|
|
173
177
|
};
|
|
174
178
|
}
|
|
@@ -177,7 +181,7 @@ const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
|
|
|
177
181
|
const deleteExpressionWithNotFoundFieldsOrTypesInExpression = (schema, fromType, expression) => {
|
|
178
182
|
if (schema.typeObjectsByName.hasOwnProperty(fromType)) {
|
|
179
183
|
const typeObject = schema.typeObjectsByName[fromType];
|
|
180
|
-
return
|
|
184
|
+
return deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitExpression(expression);
|
|
181
185
|
}
|
|
182
186
|
return null;
|
|
183
187
|
};
|
|
@@ -389,6 +393,9 @@ const enableHideWhenEmptyForCheckedEditableUnit = unit => {
|
|
|
389
393
|
return unit;
|
|
390
394
|
};
|
|
391
395
|
|
|
396
|
+
const {
|
|
397
|
+
isFieldExpression
|
|
398
|
+
} = expressionUtils.utils;
|
|
392
399
|
const visitQueryExpressionHolder = (queryHolder, visitor) => {
|
|
393
400
|
if (queryHolder) {
|
|
394
401
|
const {
|
|
@@ -453,7 +460,7 @@ const visitAxis$1 = (axis, visitor) => {
|
|
|
453
460
|
}
|
|
454
461
|
return axis;
|
|
455
462
|
};
|
|
456
|
-
const isAxisFieldExpression = expression =>
|
|
463
|
+
const isAxisFieldExpression = expression => isFieldExpression(expression) && expression.length === 1;
|
|
457
464
|
const ensureAxisAndItemExpressionInvariant$1 = view => {
|
|
458
465
|
const actions = [];
|
|
459
466
|
const x = ___default["default"].get(view, ["fibery/meta", "x"]);
|
|
@@ -1054,6 +1061,10 @@ const enableHideWhenEmptyForCheckedUnits$1 = view => {
|
|
|
1054
1061
|
});
|
|
1055
1062
|
};
|
|
1056
1063
|
|
|
1064
|
+
const {
|
|
1065
|
+
replaceIdsWithNamesVisitor,
|
|
1066
|
+
replaceNamesWithIdsVisitor
|
|
1067
|
+
} = expressionUtils.visitors;
|
|
1057
1068
|
const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["default"](smartFolder, {
|
|
1058
1069
|
"fibery/meta": {
|
|
1059
1070
|
items: {
|
|
@@ -1186,7 +1197,7 @@ const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromT
|
|
|
1186
1197
|
if (schema.typeObjectsById.hasOwnProperty(fromType)) {
|
|
1187
1198
|
const typeObject = schema.typeObjectsById[fromType];
|
|
1188
1199
|
return [index, {
|
|
1189
|
-
expression:
|
|
1200
|
+
expression: replaceIdsWithNamesVisitor(typeObject).visitExpression(expression)
|
|
1190
1201
|
}];
|
|
1191
1202
|
} else {
|
|
1192
1203
|
return [index, {
|
|
@@ -1205,7 +1216,7 @@ const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromT
|
|
|
1205
1216
|
if (schema.typeObjectsByName.hasOwnProperty(fromType)) {
|
|
1206
1217
|
const typeObject = schema.typeObjectsByName[fromType];
|
|
1207
1218
|
return [index, {
|
|
1208
|
-
expression:
|
|
1219
|
+
expression: replaceNamesWithIdsVisitor(typeObject).visitExpression(expression)
|
|
1209
1220
|
}];
|
|
1210
1221
|
} else {
|
|
1211
1222
|
return [index, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.1",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"lodash": "4.17.21",
|
|
20
20
|
"microbundle": "0.15.1",
|
|
21
21
|
"@fibery/babel-preset": "7.4.0",
|
|
22
|
+
"@fibery/expression-utils": "9.5.1",
|
|
22
23
|
"@fibery/eslint-config": "8.6.1",
|
|
23
|
-
"@fibery/schema": "10.2.8"
|
|
24
|
-
"@fibery/expression-utils": "9.5.0"
|
|
24
|
+
"@fibery/schema": "10.2.8"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@fibery/expression-utils": "^9.5.
|
|
27
|
+
"@fibery/expression-utils": "^9.5.1",
|
|
28
28
|
"@fibery/schema": "^10.2.8",
|
|
29
29
|
"immutability-helper": "^2.4.0",
|
|
30
30
|
"lodash": "^4.17.21"
|