@fibery/views 1.1.14 → 1.1.16
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 +136 -195
- package/package.json +9 -5
package/lib/views.js
CHANGED
|
@@ -9,20 +9,17 @@ var immutableUpdate__default = /*#__PURE__*/_interopDefaultLegacy(immutableUpdat
|
|
|
9
9
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
10
10
|
|
|
11
11
|
function _extends() {
|
|
12
|
-
_extends = Object.assign
|
|
12
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
13
13
|
for (var i = 1; i < arguments.length; i++) {
|
|
14
14
|
var source = arguments[i];
|
|
15
|
-
|
|
16
15
|
for (var key in source) {
|
|
17
16
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
18
17
|
target[key] = source[key];
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
return target;
|
|
24
22
|
};
|
|
25
|
-
|
|
26
23
|
return _extends.apply(this, arguments);
|
|
27
24
|
}
|
|
28
25
|
|
|
@@ -30,86 +27,69 @@ const getFieldType = (schema, fromType, field) => {
|
|
|
30
27
|
if (!schema.typeObjectsByName.hasOwnProperty(fromType) || !schema.typeObjectsByName[fromType].fieldObjectsByName.hasOwnProperty(field)) {
|
|
31
28
|
return null;
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
return schema.typeObjectsByName[fromType].fieldObjectsByName[field].type;
|
|
35
31
|
};
|
|
36
|
-
|
|
37
32
|
const getFieldMeta = (schema, fromType, field) => {
|
|
38
33
|
if (!schema.typeObjectsByName.hasOwnProperty(fromType) || !schema.typeObjectsByName[fromType].fieldObjectsByName.hasOwnProperty(field)) {
|
|
39
34
|
return null;
|
|
40
35
|
}
|
|
41
|
-
|
|
42
36
|
return schema.typeObjectsByName[fromType].fieldObjectsByName[field].rawMeta;
|
|
43
37
|
};
|
|
44
|
-
|
|
45
38
|
const getUnitTypeForTextField = fieldMeta => {
|
|
46
39
|
switch (fieldMeta["ui/type"]) {
|
|
47
40
|
case "email":
|
|
48
41
|
return "email";
|
|
49
|
-
|
|
50
42
|
case "url":
|
|
51
43
|
return "url";
|
|
52
|
-
|
|
53
44
|
case "phone":
|
|
54
45
|
return "phone";
|
|
55
|
-
|
|
56
46
|
default:
|
|
57
47
|
return "text";
|
|
58
48
|
}
|
|
59
49
|
};
|
|
60
|
-
|
|
61
50
|
const fixViewUnit = (schema, fromType, unit) => {
|
|
62
51
|
const {
|
|
63
52
|
type,
|
|
64
53
|
expression
|
|
65
54
|
} = unit;
|
|
66
|
-
|
|
67
55
|
if (type === "date") {
|
|
68
56
|
const [field] = expression;
|
|
69
|
-
|
|
70
57
|
if (getFieldType(schema, fromType, field) === "fibery/date-time") {
|
|
71
58
|
return _extends({}, unit, {
|
|
72
59
|
type: "date-time"
|
|
73
60
|
});
|
|
74
61
|
}
|
|
75
62
|
}
|
|
76
|
-
|
|
77
63
|
if (type === "date-range") {
|
|
78
64
|
const [field] = expression;
|
|
79
|
-
|
|
80
65
|
if (getFieldType(schema, fromType, field) === "fibery/date-time-range") {
|
|
81
66
|
return _extends({}, unit, {
|
|
82
67
|
type: "date-time-range"
|
|
83
68
|
});
|
|
84
69
|
}
|
|
85
70
|
}
|
|
86
|
-
|
|
87
71
|
if (type === "text") {
|
|
88
72
|
const [field] = expression;
|
|
89
73
|
const fieldType = getFieldType(schema, fromType, field);
|
|
90
|
-
|
|
91
74
|
if (fieldType === "fibery/email") {
|
|
92
75
|
return _extends({}, unit, {
|
|
93
76
|
type: "email"
|
|
94
77
|
});
|
|
95
78
|
}
|
|
96
79
|
}
|
|
97
|
-
|
|
98
80
|
if (["text", "email", "phone", "url"].includes(type)) {
|
|
99
81
|
const [field] = expression;
|
|
100
|
-
|
|
101
82
|
if (getFieldType(schema, fromType, field) === "fibery/text") {
|
|
102
83
|
return _extends({}, unit, {
|
|
103
84
|
type: getUnitTypeForTextField(getFieldMeta(schema, fromType, field))
|
|
104
85
|
});
|
|
105
86
|
}
|
|
106
87
|
}
|
|
107
|
-
|
|
108
88
|
return unit;
|
|
109
89
|
};
|
|
110
90
|
|
|
91
|
+
// Return this symbol from a visitor callback to remove the node from the
|
|
111
92
|
// output. Not supported in all places, add support as needed.
|
|
112
|
-
|
|
113
93
|
const REMOVE = Symbol("remove");
|
|
114
94
|
const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, queryExpression) => {
|
|
115
95
|
const {
|
|
@@ -117,7 +97,6 @@ const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, quer
|
|
|
117
97
|
"q/where": whereExpression,
|
|
118
98
|
"q/order-by": orderByExpression
|
|
119
99
|
} = queryExpression;
|
|
120
|
-
|
|
121
100
|
if (schema.typeObjectsByName.hasOwnProperty(fromExpression)) {
|
|
122
101
|
const typeObject = schema.typeObjectsByName[fromExpression];
|
|
123
102
|
return ___default["default"].pickBy(_extends({}, queryExpression, whereExpression ? {
|
|
@@ -126,7 +105,6 @@ const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, quer
|
|
|
126
105
|
"q/order-by": visitors.deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitOrderByExpression(orderByExpression)
|
|
127
106
|
} : null));
|
|
128
107
|
}
|
|
129
|
-
|
|
130
108
|
return null;
|
|
131
109
|
};
|
|
132
110
|
const replaceNamesWithIdsInExpression = (schema, fromType, expression) => {
|
|
@@ -134,7 +112,6 @@ const replaceNamesWithIdsInExpression = (schema, fromType, expression) => {
|
|
|
134
112
|
const typeObject = schema.typeObjectsByName[fromType];
|
|
135
113
|
return visitors.replaceNamesWithIdsVisitor(typeObject).visitExpression(expression);
|
|
136
114
|
}
|
|
137
|
-
|
|
138
115
|
return expression;
|
|
139
116
|
};
|
|
140
117
|
const replaceIdsWithNamesInExpression = (schema, fromTypeId, expression) => {
|
|
@@ -142,20 +119,17 @@ const replaceIdsWithNamesInExpression = (schema, fromTypeId, expression) => {
|
|
|
142
119
|
const typeObject = schema.typeObjectsById[fromTypeId];
|
|
143
120
|
return visitors.replaceIdsWithNamesVisitor(typeObject).visitExpression(expression);
|
|
144
121
|
}
|
|
145
|
-
|
|
146
122
|
return expression;
|
|
147
123
|
};
|
|
148
124
|
const visitViewUnit = (fromType, unit, visitor) => {
|
|
149
125
|
const {
|
|
150
126
|
expression
|
|
151
127
|
} = unit;
|
|
152
|
-
|
|
153
128
|
if (expression) {
|
|
154
129
|
return _extends({}, unit, {
|
|
155
130
|
expression: visitor.visitExpression(fromType, expression)
|
|
156
131
|
});
|
|
157
132
|
}
|
|
158
|
-
|
|
159
133
|
return unit;
|
|
160
134
|
};
|
|
161
135
|
const visitContextExpression = (fromType, contextExpression, visitor) => {
|
|
@@ -168,7 +142,6 @@ const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
|
|
|
168
142
|
"q/where": whereExpression,
|
|
169
143
|
"q/order-by": orderByExpression
|
|
170
144
|
} = queryExpression;
|
|
171
|
-
|
|
172
145
|
if (schema.typeObjectsById.hasOwnProperty(fromExpression)) {
|
|
173
146
|
const typeObject = schema.typeObjectsById[fromExpression];
|
|
174
147
|
return _extends({}, queryExpression, {
|
|
@@ -179,7 +152,6 @@ const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
|
|
|
179
152
|
"q/order-by": visitors.replaceIdsWithNamesVisitor(typeObject).visitOrderByExpression(orderByExpression)
|
|
180
153
|
} : null);
|
|
181
154
|
}
|
|
182
|
-
|
|
183
155
|
return queryExpression;
|
|
184
156
|
};
|
|
185
157
|
const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
|
|
@@ -188,7 +160,6 @@ const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
|
|
|
188
160
|
"q/where": whereExpression,
|
|
189
161
|
"q/order-by": orderByExpression
|
|
190
162
|
} = queryExpression;
|
|
191
|
-
|
|
192
163
|
if (schema.typeObjectsByName.hasOwnProperty(fromExpression)) {
|
|
193
164
|
const typeObject = schema.typeObjectsByName[fromExpression];
|
|
194
165
|
return _extends({}, queryExpression, {
|
|
@@ -199,7 +170,6 @@ const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
|
|
|
199
170
|
"q/order-by": visitors.replaceNamesWithIdsVisitor(typeObject).visitOrderByExpression(orderByExpression)
|
|
200
171
|
} : null);
|
|
201
172
|
}
|
|
202
|
-
|
|
203
173
|
return queryExpression;
|
|
204
174
|
};
|
|
205
175
|
const deleteExpressionWithNotFoundFieldsOrTypesInExpression = (schema, fromType, expression) => {
|
|
@@ -207,7 +177,6 @@ const deleteExpressionWithNotFoundFieldsOrTypesInExpression = (schema, fromType,
|
|
|
207
177
|
const typeObject = schema.typeObjectsByName[fromType];
|
|
208
178
|
return visitors.deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitExpression(expression);
|
|
209
179
|
}
|
|
210
|
-
|
|
211
180
|
return null;
|
|
212
181
|
};
|
|
213
182
|
const resetContextExpressionIfBroken = (schema, fromType, expression, defaultExpression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression) || defaultExpression;
|
|
@@ -218,7 +187,6 @@ const isUnitExpressionValid = unit => {
|
|
|
218
187
|
} = unit;
|
|
219
188
|
return expression !== null;
|
|
220
189
|
}
|
|
221
|
-
|
|
222
190
|
return true;
|
|
223
191
|
};
|
|
224
192
|
|
|
@@ -227,20 +195,16 @@ const visitQueryExpressionHolder = (queryHolder, visitor) => {
|
|
|
227
195
|
const {
|
|
228
196
|
query
|
|
229
197
|
} = queryHolder;
|
|
230
|
-
|
|
231
198
|
if (query) {
|
|
232
199
|
const queryNew = visitor.visitQueryExpression(query);
|
|
233
200
|
return queryNew ? _extends({}, queryHolder, {
|
|
234
201
|
query: queryNew
|
|
235
202
|
}) : null;
|
|
236
203
|
}
|
|
237
|
-
|
|
238
204
|
return queryHolder;
|
|
239
205
|
}
|
|
240
|
-
|
|
241
206
|
return queryHolder;
|
|
242
207
|
};
|
|
243
|
-
|
|
244
208
|
const visitAxisUnits = (axis, fromType, visitor) => {
|
|
245
209
|
return fromType ? immutableUpdate__default["default"](axis, {
|
|
246
210
|
contextExpression: {
|
|
@@ -251,20 +215,15 @@ const visitAxisUnits = (axis, fromType, visitor) => {
|
|
|
251
215
|
}
|
|
252
216
|
}) : axis;
|
|
253
217
|
};
|
|
254
|
-
|
|
255
218
|
const visitAxis$1 = (axis, visitor) => {
|
|
256
219
|
if (axis && axis.hasOwnProperty("query")) {
|
|
257
220
|
const fromType = ___default["default"].get(axis, ["query", "q/from"]);
|
|
258
|
-
|
|
259
221
|
const axisWithVisitedQuery = visitQueryExpressionHolder(axis, visitor);
|
|
260
|
-
|
|
261
222
|
if (axisWithVisitedQuery) {
|
|
262
223
|
return visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
|
|
263
224
|
}
|
|
264
|
-
|
|
265
225
|
return axisWithVisitedQuery;
|
|
266
226
|
}
|
|
267
|
-
|
|
268
227
|
if (axis && axis.hasOwnProperty("enums")) {
|
|
269
228
|
const axisNew = immutableUpdate__default["default"](axis, {
|
|
270
229
|
enums: {
|
|
@@ -276,24 +235,18 @@ const visitAxis$1 = (axis, visitor) => {
|
|
|
276
235
|
} = axisNew;
|
|
277
236
|
return enums ? axisNew : null;
|
|
278
237
|
}
|
|
279
|
-
|
|
280
238
|
return axis;
|
|
281
239
|
};
|
|
282
|
-
|
|
240
|
+
const isAxisFieldExpression = expression => utils.isFieldExpression(expression) && expression.length === 1;
|
|
283
241
|
const ensureAxisAndItemExpressionInvariant$1 = view => {
|
|
284
242
|
const actions = [];
|
|
285
|
-
|
|
286
243
|
const x = ___default["default"].get(view, ["fibery/meta", "x"]);
|
|
287
|
-
|
|
288
244
|
const y = ___default["default"].get(view, ["fibery/meta", "y"]);
|
|
289
|
-
|
|
290
245
|
const items = ___default["default"].get(view, ["fibery/meta", "items"]);
|
|
291
|
-
|
|
292
246
|
if (x === null) {
|
|
293
247
|
const resetActions = items.map(item => () => item.xExpression = null);
|
|
294
248
|
actions.push(...resetActions);
|
|
295
249
|
}
|
|
296
|
-
|
|
297
250
|
if (x !== null && ___default["default"].some(items, ({
|
|
298
251
|
xExpression
|
|
299
252
|
}) => xExpression === null)) {
|
|
@@ -301,12 +254,10 @@ const ensureAxisAndItemExpressionInvariant$1 = view => {
|
|
|
301
254
|
actions.push(...resetActions);
|
|
302
255
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "x"], null));
|
|
303
256
|
}
|
|
304
|
-
|
|
305
257
|
if (y === null) {
|
|
306
258
|
const resetActions = items.map(item => () => item.yExpression = null);
|
|
307
259
|
actions.push(...resetActions);
|
|
308
260
|
}
|
|
309
|
-
|
|
310
261
|
if (y !== null && ___default["default"].some(items, ({
|
|
311
262
|
yExpression
|
|
312
263
|
}) => yExpression === null)) {
|
|
@@ -314,36 +265,30 @@ const ensureAxisAndItemExpressionInvariant$1 = view => {
|
|
|
314
265
|
actions.push(...resetActions);
|
|
315
266
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
|
|
316
267
|
}
|
|
317
|
-
|
|
318
268
|
if (x !== null && ___default["default"].isEmpty(items)) {
|
|
319
269
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "x"], null));
|
|
320
270
|
}
|
|
321
|
-
|
|
322
271
|
if (y !== null && ___default["default"].isEmpty(items)) {
|
|
323
272
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
|
|
324
273
|
}
|
|
325
|
-
|
|
326
274
|
if (x !== null && ___default["default"].some(items, ({
|
|
327
275
|
xExpression
|
|
328
|
-
}) => !
|
|
276
|
+
}) => !isAxisFieldExpression(xExpression))) {
|
|
329
277
|
const resetActions = items.map(item => () => item.xExpression = null);
|
|
330
278
|
actions.push(...resetActions);
|
|
331
279
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "x"], null));
|
|
332
280
|
}
|
|
333
|
-
|
|
334
281
|
if (y !== null && ___default["default"].some(items, ({
|
|
335
282
|
yExpression
|
|
336
|
-
}) => !
|
|
283
|
+
}) => !isAxisFieldExpression(yExpression))) {
|
|
337
284
|
const resetActions = items.map(item => () => item.yExpression = null);
|
|
338
285
|
actions.push(...resetActions);
|
|
339
286
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
|
|
340
287
|
}
|
|
341
|
-
|
|
342
288
|
actions.forEach(action => action());
|
|
343
289
|
return view;
|
|
344
290
|
};
|
|
345
|
-
|
|
346
|
-
const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
291
|
+
const visitView$5 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
347
292
|
"fibery/meta": {
|
|
348
293
|
x: {
|
|
349
294
|
$apply: x => visitAxis$1(x, visitor)
|
|
@@ -354,8 +299,10 @@ const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
354
299
|
items: {
|
|
355
300
|
$apply: items => items.map(item => {
|
|
356
301
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
357
|
-
|
|
358
302
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
303
|
+
coverExpression: {
|
|
304
|
+
$apply: coverExpression => coverExpression ? visitor.visitExpression(fromType, coverExpression) : coverExpression
|
|
305
|
+
},
|
|
359
306
|
xExpression: {
|
|
360
307
|
$apply: xExpression => xExpression ? visitor.visitExpression(fromType, xExpression) : xExpression
|
|
361
308
|
},
|
|
@@ -388,7 +335,6 @@ const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
388
335
|
}
|
|
389
336
|
}
|
|
390
337
|
});
|
|
391
|
-
|
|
392
338
|
const replaceNamesWithIdsViewVisitor = schema => {
|
|
393
339
|
const visitor = {
|
|
394
340
|
visitQueryExpression: queryExpression => replaceNamesWithIdsInQueryExpression(schema, queryExpression),
|
|
@@ -396,21 +342,17 @@ const replaceNamesWithIdsViewVisitor = schema => {
|
|
|
396
342
|
visitEnums: enums => ___default["default"].entries(enums).reduce((result, [type, queryHolder]) => {
|
|
397
343
|
if (schema.typeObjectsByName.hasOwnProperty(type)) {
|
|
398
344
|
const typeObject = schema.typeObjectsByName[type];
|
|
399
|
-
|
|
400
345
|
const fromType = ___default["default"].get(queryHolder, ["query", "q/from"]);
|
|
401
|
-
|
|
402
346
|
const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
|
|
403
347
|
result[typeObject.id] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
|
|
404
348
|
} else {
|
|
405
349
|
result[type] = queryHolder;
|
|
406
350
|
}
|
|
407
|
-
|
|
408
351
|
return result;
|
|
409
352
|
}, {})
|
|
410
353
|
};
|
|
411
354
|
return visitor;
|
|
412
355
|
};
|
|
413
|
-
|
|
414
356
|
const replaceIdsWithNamesViewVisitor = schema => {
|
|
415
357
|
const visitor = {
|
|
416
358
|
visitQueryExpression: queryExpression => replaceIdsWithNamesInQueryExpression(schema, queryExpression),
|
|
@@ -418,21 +360,17 @@ const replaceIdsWithNamesViewVisitor = schema => {
|
|
|
418
360
|
visitEnums: enums => ___default["default"].entries(enums).reduce((result, [typeId, queryHolder]) => {
|
|
419
361
|
if (schema.typeObjectsById.hasOwnProperty(typeId)) {
|
|
420
362
|
const typeObject = schema.typeObjectsById[typeId];
|
|
421
|
-
|
|
422
363
|
const fromType = ___default["default"].get(queryHolder, ["query", "q/from"]);
|
|
423
|
-
|
|
424
364
|
const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
|
|
425
365
|
result[typeObject.name] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
|
|
426
366
|
} else {
|
|
427
367
|
result[typeId] = queryHolder;
|
|
428
368
|
}
|
|
429
|
-
|
|
430
369
|
return result;
|
|
431
370
|
}, {})
|
|
432
371
|
};
|
|
433
372
|
return visitor;
|
|
434
373
|
};
|
|
435
|
-
|
|
436
374
|
const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = schema => {
|
|
437
375
|
const visitor = {
|
|
438
376
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
@@ -442,23 +380,18 @@ const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = schema => {
|
|
|
442
380
|
if (schema.typeObjectsByName.hasOwnProperty(type)) {
|
|
443
381
|
const typeObject = schema.typeObjectsByName[type];
|
|
444
382
|
const queryHolderResult = visitQueryExpressionHolder(queryHolder, visitor);
|
|
445
|
-
|
|
446
383
|
if (queryHolderResult) {
|
|
447
384
|
result[typeObject.name] = queryHolderResult;
|
|
448
385
|
}
|
|
449
|
-
|
|
450
386
|
return result;
|
|
451
387
|
}
|
|
452
|
-
|
|
453
388
|
return result;
|
|
454
389
|
}, {});
|
|
455
|
-
|
|
456
390
|
return ___default["default"].isEmpty(enumsNew) ? null : enumsNew;
|
|
457
391
|
}
|
|
458
392
|
};
|
|
459
393
|
return visitor;
|
|
460
394
|
};
|
|
461
|
-
|
|
462
395
|
const fixUserSelectedUnitsViewVisitor = schema => {
|
|
463
396
|
return {
|
|
464
397
|
visitQueryExpression: queryExpression => queryExpression,
|
|
@@ -467,24 +400,23 @@ const fixUserSelectedUnitsViewVisitor = schema => {
|
|
|
467
400
|
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
|
|
468
401
|
};
|
|
469
402
|
};
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
const replaceNamesWithIdsInBoardView = (schema, view) => visitView$4(view, replaceNamesWithIdsViewVisitor(schema));
|
|
403
|
+
const replaceIdsWithNamesInBoardView = (schema, view) => visitView$5(view, replaceIdsWithNamesViewVisitor(schema));
|
|
404
|
+
const replaceNamesWithIdsInBoardView = (schema, view) => visitView$5(view, replaceNamesWithIdsViewVisitor(schema));
|
|
473
405
|
const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = (schema, view, ensureAxisInvariant = true) => {
|
|
474
|
-
const viewNew = visitView$
|
|
406
|
+
const viewNew = visitView$5(view, deleteExpressionWithNotFoundFieldsOrTypesViewVisitor(schema));
|
|
475
407
|
return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant$1(viewNew) : viewNew;
|
|
476
408
|
};
|
|
477
409
|
const fixUserSelectedUnitsInBoardView = (schema, view) => {
|
|
478
|
-
return visitView$
|
|
410
|
+
return visitView$5(view, fixUserSelectedUnitsViewVisitor(schema));
|
|
479
411
|
};
|
|
480
|
-
const fixContextExpressionWithBrokenPath$
|
|
412
|
+
const fixContextExpressionWithBrokenPath$7 = (schema, view, defaultContextExpression) => visitView$5(view, {
|
|
481
413
|
visitQueryExpression: query => query,
|
|
482
414
|
visitExpression: (fromType, expression) => expression,
|
|
483
415
|
visitEnums: enums => enums,
|
|
484
416
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
485
417
|
});
|
|
486
|
-
const collectGarbage$
|
|
487
|
-
return visitView$
|
|
418
|
+
const collectGarbage$7 = view => {
|
|
419
|
+
return visitView$5(view, {
|
|
488
420
|
visitQueryExpression: queryExpression => queryExpression,
|
|
489
421
|
visitExpression: (fromType, expression) => expression,
|
|
490
422
|
visitEnums: enums => enums,
|
|
@@ -492,12 +424,11 @@ const collectGarbage$6 = view => {
|
|
|
492
424
|
});
|
|
493
425
|
};
|
|
494
426
|
|
|
495
|
-
const visitView$
|
|
427
|
+
const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
496
428
|
"fibery/meta": {
|
|
497
429
|
items: {
|
|
498
430
|
$apply: items => items.map(item => {
|
|
499
431
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
500
|
-
|
|
501
432
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
502
433
|
startExpression: {
|
|
503
434
|
$apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
|
|
@@ -531,49 +462,47 @@ const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
531
462
|
}
|
|
532
463
|
}
|
|
533
464
|
});
|
|
534
|
-
|
|
535
465
|
const replaceNamesWithIdsInCalendarView = (schema, view) => {
|
|
536
|
-
return visitView$
|
|
466
|
+
return visitView$4(view, {
|
|
537
467
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
538
468
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
|
|
539
469
|
});
|
|
540
470
|
};
|
|
541
471
|
const replaceIdsWithNamesInCalendarView = (schema, view) => {
|
|
542
|
-
return visitView$
|
|
472
|
+
return visitView$4(view, {
|
|
543
473
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
544
474
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
|
|
545
475
|
});
|
|
546
476
|
};
|
|
547
|
-
const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView$
|
|
477
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView$4(view, {
|
|
548
478
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
549
479
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
550
480
|
});
|
|
551
481
|
const fixUserSelectedUnitsInCalendarView = (schema, view) => {
|
|
552
|
-
return visitView$
|
|
482
|
+
return visitView$4(view, {
|
|
553
483
|
visitExpression: (fromType, expression) => expression,
|
|
554
484
|
visitQueryExpression: query => query,
|
|
555
485
|
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
|
|
556
486
|
});
|
|
557
487
|
};
|
|
558
|
-
const fixContextExpressionWithBrokenPath$
|
|
488
|
+
const fixContextExpressionWithBrokenPath$6 = (schema, view, defaultContextExpression) => visitView$4(view, {
|
|
559
489
|
visitQueryExpression: query => query,
|
|
560
490
|
visitExpression: (fromType, expression) => expression,
|
|
561
491
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
562
492
|
});
|
|
563
|
-
const collectGarbage$
|
|
564
|
-
return visitView$
|
|
493
|
+
const collectGarbage$6 = view => {
|
|
494
|
+
return visitView$4(view, {
|
|
565
495
|
visitExpression: (fromType, expression) => expression,
|
|
566
496
|
visitQueryExpression: query => query,
|
|
567
497
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
568
498
|
});
|
|
569
499
|
};
|
|
570
500
|
|
|
571
|
-
const visitView$
|
|
501
|
+
const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
572
502
|
"fibery/meta": {
|
|
573
503
|
items: {
|
|
574
504
|
$apply: items => items.map(item => {
|
|
575
505
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
576
|
-
|
|
577
506
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
578
507
|
postExpression: {
|
|
579
508
|
$apply: postExpression => postExpression ? visitor.visitExpression(fromType, postExpression) : postExpression
|
|
@@ -604,37 +533,36 @@ const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
604
533
|
}
|
|
605
534
|
}
|
|
606
535
|
});
|
|
607
|
-
|
|
608
536
|
const replaceNamesWithIdsInFeedView = (schema, view) => {
|
|
609
|
-
return visitView$
|
|
537
|
+
return visitView$3(view, {
|
|
610
538
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
611
539
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
|
|
612
540
|
});
|
|
613
541
|
};
|
|
614
542
|
const replaceIdsWithNamesInFeedView = (schema, view) => {
|
|
615
|
-
return visitView$
|
|
543
|
+
return visitView$3(view, {
|
|
616
544
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
617
545
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
|
|
618
546
|
});
|
|
619
547
|
};
|
|
620
|
-
const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView$
|
|
548
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView$3(view, {
|
|
621
549
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
622
550
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
623
551
|
});
|
|
624
552
|
const fixUserSelectedUnitsInFeedView = (schema, view) => {
|
|
625
|
-
return visitView$
|
|
553
|
+
return visitView$3(view, {
|
|
626
554
|
visitExpression: (fromType, expression) => expression,
|
|
627
555
|
visitQueryExpression: query => query,
|
|
628
556
|
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
|
|
629
557
|
});
|
|
630
558
|
};
|
|
631
|
-
const fixContextExpressionWithBrokenPath$
|
|
559
|
+
const fixContextExpressionWithBrokenPath$5 = (schema, view, defaultContextExpression) => visitView$3(view, {
|
|
632
560
|
visitQueryExpression: query => query,
|
|
633
561
|
visitExpression: (fromType, expression) => expression,
|
|
634
562
|
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
635
563
|
});
|
|
636
|
-
const collectGarbage$
|
|
637
|
-
return visitView$
|
|
564
|
+
const collectGarbage$5 = view => {
|
|
565
|
+
return visitView$3(view, {
|
|
638
566
|
visitExpression: (fromType, expression) => expression,
|
|
639
567
|
visitQueryExpression: query => query,
|
|
640
568
|
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
@@ -643,7 +571,6 @@ const collectGarbage$4 = view => {
|
|
|
643
571
|
|
|
644
572
|
const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
645
573
|
var _view$fiberyMeta, _view$fiberyMeta2;
|
|
646
|
-
|
|
647
574
|
const typeId = (_view$fiberyMeta = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta.typeId;
|
|
648
575
|
const typeObject = schema.typeObjectsByName.hasOwnProperty(typeId) ? schema.typeObjectsByName[typeId] : null;
|
|
649
576
|
const fields = (_view$fiberyMeta2 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta2.fields;
|
|
@@ -651,7 +578,6 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
|
651
578
|
if (!(typeObject != null && typeObject.fieldObjectsByName.hasOwnProperty(field.id))) {
|
|
652
579
|
return field;
|
|
653
580
|
}
|
|
654
|
-
|
|
655
581
|
return _extends({}, field, {
|
|
656
582
|
id: typeObject.fieldObjectsByName[field.id].id
|
|
657
583
|
});
|
|
@@ -665,7 +591,6 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
|
665
591
|
};
|
|
666
592
|
const replaceIdsWithNamesInFormView = (schema, view) => {
|
|
667
593
|
var _view$fiberyMeta3, _view$fiberyMeta4;
|
|
668
|
-
|
|
669
594
|
const typeId = (_view$fiberyMeta3 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta3.typeId;
|
|
670
595
|
const typeObject = schema.typeObjectsById.hasOwnProperty(typeId) ? schema.typeObjectsById[typeId] : null;
|
|
671
596
|
const fields = (_view$fiberyMeta4 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta4.fields;
|
|
@@ -673,7 +598,6 @@ const replaceIdsWithNamesInFormView = (schema, view) => {
|
|
|
673
598
|
if (!(typeObject != null && typeObject.fieldObjectsById.hasOwnProperty(field.id))) {
|
|
674
599
|
return field;
|
|
675
600
|
}
|
|
676
|
-
|
|
677
601
|
return _extends({}, field, {
|
|
678
602
|
id: typeObject.fieldObjectsById[field.id].name
|
|
679
603
|
});
|
|
@@ -687,7 +611,6 @@ const replaceIdsWithNamesInFormView = (schema, view) => {
|
|
|
687
611
|
};
|
|
688
612
|
const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
|
|
689
613
|
var _view$fiberyMeta5, _view$fiberyMeta6;
|
|
690
|
-
|
|
691
614
|
// we expect view in names terms here.
|
|
692
615
|
const typeName = (_view$fiberyMeta5 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta5.typeId;
|
|
693
616
|
const typeObject = schema.typeObjectsByName.hasOwnProperty(typeName) ? schema.typeObjectsByName[typeName] : null;
|
|
@@ -701,19 +624,88 @@ const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
|
|
|
701
624
|
});
|
|
702
625
|
};
|
|
703
626
|
|
|
627
|
+
const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
628
|
+
"fibery/meta": {
|
|
629
|
+
items: {
|
|
630
|
+
$apply: items => items.map(item => {
|
|
631
|
+
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
632
|
+
return fromType ? immutableUpdate__default["default"](item, {
|
|
633
|
+
locationExpression: {
|
|
634
|
+
$apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
|
|
635
|
+
},
|
|
636
|
+
contextExpression: {
|
|
637
|
+
$apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
|
|
638
|
+
},
|
|
639
|
+
query: {
|
|
640
|
+
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
641
|
+
},
|
|
642
|
+
units: {
|
|
643
|
+
$apply: units => units ? units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit) : undefined
|
|
644
|
+
},
|
|
645
|
+
colorCoding: {
|
|
646
|
+
$apply: colorCodings => {
|
|
647
|
+
return colorCodings && colorCodings.map(colorCoding => _extends({}, colorCoding, {
|
|
648
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
649
|
+
})).filter(colorCoding => colorCoding.expression !== null);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}) : item;
|
|
653
|
+
}).filter(item => {
|
|
654
|
+
const {
|
|
655
|
+
query
|
|
656
|
+
} = item;
|
|
657
|
+
return query ? item : null;
|
|
658
|
+
})
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
const replaceNamesWithIdsInMapView = (schema, view) => {
|
|
663
|
+
return visitView$2(view, {
|
|
664
|
+
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
665
|
+
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
|
|
666
|
+
});
|
|
667
|
+
};
|
|
668
|
+
const replaceIdsWithNamesInMapView = (schema, view) => {
|
|
669
|
+
return visitView$2(view, {
|
|
670
|
+
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
671
|
+
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
|
|
672
|
+
});
|
|
673
|
+
};
|
|
674
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInMapView = (schema, view) => visitView$2(view, {
|
|
675
|
+
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
676
|
+
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
677
|
+
});
|
|
678
|
+
const fixUserSelectedUnitsInMapView = (schema, view) => {
|
|
679
|
+
return visitView$2(view, {
|
|
680
|
+
visitQueryExpression: query => query,
|
|
681
|
+
visitExpression: (fromType, expression) => expression,
|
|
682
|
+
visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
|
|
683
|
+
});
|
|
684
|
+
};
|
|
685
|
+
const fixContextExpressionWithBrokenPath$4 = (schema, view, defaultContextExpression) => visitView$2(view, {
|
|
686
|
+
visitExpression: (fromType, expression) => expression,
|
|
687
|
+
visitQueryExpression: query => query,
|
|
688
|
+
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
689
|
+
});
|
|
690
|
+
const collectGarbage$4 = view => {
|
|
691
|
+
return visitView$2(view, {
|
|
692
|
+
visitQueryExpression: query => query,
|
|
693
|
+
visitExpression: (fromType, expression) => expression,
|
|
694
|
+
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
695
|
+
});
|
|
696
|
+
};
|
|
697
|
+
|
|
704
698
|
const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["default"](smartFolder, {
|
|
705
699
|
"fibery/meta": {
|
|
706
700
|
items: {
|
|
707
|
-
$apply: items => {
|
|
701
|
+
$apply: (items = []) => {
|
|
708
702
|
const isOldSmartFolder = !items.every(item => item.hasOwnProperty("groupBy"));
|
|
709
703
|
const removedItemsIndexes = items.map((item, index) => visitor.visitQueryExpression(item.query) ? null : index).filter(value => value !== null);
|
|
710
704
|
return items.map((item, index) => {
|
|
711
705
|
if (isOldSmartFolder) {
|
|
712
706
|
return item;
|
|
713
707
|
}
|
|
714
|
-
|
|
715
708
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
716
|
-
|
|
717
709
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
718
710
|
groupBy: {
|
|
719
711
|
$apply: groupBy => {
|
|
@@ -724,7 +716,6 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
|
|
|
724
716
|
}) : item;
|
|
725
717
|
}).map(item => {
|
|
726
718
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
727
|
-
|
|
728
719
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
729
720
|
query: {
|
|
730
721
|
$apply: query => {
|
|
@@ -756,17 +747,14 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
|
|
|
756
747
|
}
|
|
757
748
|
}
|
|
758
749
|
});
|
|
759
|
-
|
|
760
750
|
const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, groupByExpression, fromType, removedItems) => {
|
|
761
751
|
if (!groupByExpression) {
|
|
762
752
|
return null;
|
|
763
753
|
}
|
|
764
|
-
|
|
765
754
|
const [[index, {
|
|
766
755
|
expression
|
|
767
756
|
}]] = Object.entries(groupByExpression);
|
|
768
757
|
const visitedExpression = deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression);
|
|
769
|
-
|
|
770
758
|
if (visitedExpression) {
|
|
771
759
|
return {
|
|
772
760
|
[`${parseInt(index) - removedItems}`]: {
|
|
@@ -774,19 +762,15 @@ const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, gr
|
|
|
774
762
|
}
|
|
775
763
|
};
|
|
776
764
|
}
|
|
777
|
-
|
|
778
765
|
return null;
|
|
779
766
|
};
|
|
780
|
-
|
|
781
767
|
const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
782
768
|
if (!groupByExpression) {
|
|
783
769
|
return null;
|
|
784
770
|
}
|
|
785
|
-
|
|
786
771
|
const [[index, {
|
|
787
772
|
expression
|
|
788
773
|
}]] = Object.entries(groupByExpression);
|
|
789
|
-
|
|
790
774
|
if (schema.typeObjectsById.hasOwnProperty(fromType)) {
|
|
791
775
|
const typeObject = schema.typeObjectsById[fromType];
|
|
792
776
|
return {
|
|
@@ -795,18 +779,15 @@ const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromT
|
|
|
795
779
|
}
|
|
796
780
|
};
|
|
797
781
|
}
|
|
798
|
-
|
|
799
782
|
return groupByExpression;
|
|
800
783
|
};
|
|
801
784
|
const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
802
785
|
if (!groupByExpression) {
|
|
803
786
|
return null;
|
|
804
787
|
}
|
|
805
|
-
|
|
806
788
|
const [[index, {
|
|
807
789
|
expression
|
|
808
790
|
}]] = Object.entries(groupByExpression);
|
|
809
|
-
|
|
810
791
|
if (schema.typeObjectsByName.hasOwnProperty(fromType)) {
|
|
811
792
|
const typeObject = schema.typeObjectsByName[fromType];
|
|
812
793
|
return {
|
|
@@ -815,7 +796,6 @@ const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromT
|
|
|
815
796
|
}
|
|
816
797
|
};
|
|
817
798
|
}
|
|
818
|
-
|
|
819
799
|
return groupByExpression;
|
|
820
800
|
};
|
|
821
801
|
const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
@@ -861,7 +841,6 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
861
841
|
items: {
|
|
862
842
|
$apply: items => items.map(item => {
|
|
863
843
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
864
|
-
|
|
865
844
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
866
845
|
query: {
|
|
867
846
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
@@ -889,7 +868,6 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
|
|
|
889
868
|
}
|
|
890
869
|
}
|
|
891
870
|
});
|
|
892
|
-
|
|
893
871
|
const replaceNamesWithIdsInTableView = (schema, view) => visitView$1(view, {
|
|
894
872
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
895
873
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
|
|
@@ -924,29 +902,22 @@ const visitAxis = (axis, visitor) => {
|
|
|
924
902
|
if (!axis) {
|
|
925
903
|
return axis;
|
|
926
904
|
}
|
|
927
|
-
|
|
928
905
|
const fromType = ___default["default"].get(axis, ["query", "q/from"]);
|
|
929
|
-
|
|
930
906
|
const firstOrNull = x => ___default["default"].first(x) || null;
|
|
931
|
-
|
|
932
907
|
const axisResult = _extends({}, axis, {
|
|
933
908
|
query: axis.query && visitor.visitQueryExpression(axis.query),
|
|
934
909
|
contextExpression: visitContextExpression(fromType, axis.contextExpression, visitor),
|
|
935
910
|
units: axis.units && axis.units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)),
|
|
936
911
|
groupByExpression: axis.groupByExpression && firstOrNull(visitor.visitExpression(fromType, [axis.groupByExpression]))
|
|
937
912
|
});
|
|
938
|
-
|
|
939
913
|
if (!axisResult.query) {
|
|
940
914
|
return null;
|
|
941
915
|
}
|
|
942
|
-
|
|
943
916
|
if (!axisResult.units) {
|
|
944
917
|
delete axisResult.units;
|
|
945
918
|
}
|
|
946
|
-
|
|
947
919
|
return axisResult;
|
|
948
920
|
};
|
|
949
|
-
|
|
950
921
|
const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
951
922
|
"fibery/meta": {
|
|
952
923
|
y: {
|
|
@@ -955,7 +926,6 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
955
926
|
items: {
|
|
956
927
|
$apply: items => items.map(item => {
|
|
957
928
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
958
|
-
|
|
959
929
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
960
930
|
yExpression: {
|
|
961
931
|
$apply: yExpression => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression
|
|
@@ -995,16 +965,17 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
995
965
|
if (!milestones) {
|
|
996
966
|
return milestones;
|
|
997
967
|
}
|
|
998
|
-
|
|
999
968
|
return milestones.map(item => {
|
|
1000
969
|
const fromType = ___default["default"].get(item, ["query", "q/from"]);
|
|
1001
|
-
|
|
1002
970
|
return fromType ? immutableUpdate__default["default"](item, {
|
|
1003
971
|
dateExpression: {
|
|
1004
972
|
$apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
|
|
1005
973
|
},
|
|
1006
974
|
query: {
|
|
1007
975
|
$apply: query => query ? visitor.visitQueryExpression(query) : null
|
|
976
|
+
},
|
|
977
|
+
contextExpression: {
|
|
978
|
+
$apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
|
|
1008
979
|
}
|
|
1009
980
|
}) : item;
|
|
1010
981
|
}).filter(item => {
|
|
@@ -1017,7 +988,6 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
|
|
|
1017
988
|
}
|
|
1018
989
|
}
|
|
1019
990
|
});
|
|
1020
|
-
|
|
1021
991
|
const replaceNamesWithIdsInTimelineView = (schema, view) => {
|
|
1022
992
|
return visitView(view, {
|
|
1023
993
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
@@ -1030,27 +1000,19 @@ const replaceIdsWithNamesInTimelineView = (schema, view) => {
|
|
|
1030
1000
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
|
|
1031
1001
|
});
|
|
1032
1002
|
};
|
|
1033
|
-
|
|
1034
1003
|
const ensureAxisAndItemExpressionInvariant = view => {
|
|
1035
1004
|
const actions = [];
|
|
1036
|
-
|
|
1037
1005
|
const y = ___default["default"].get(view, ["fibery/meta", "y"]);
|
|
1038
|
-
|
|
1039
1006
|
const yQuery = ___default["default"].get(view, ["fibery/meta", "y", "query"]);
|
|
1040
|
-
|
|
1041
1007
|
const yGroupByExpression = ___default["default"].get(view, ["fibery/meta", "y", "groupByExpression"]);
|
|
1042
|
-
|
|
1043
1008
|
const items = ___default["default"].get(view, ["fibery/meta", "items"]);
|
|
1044
|
-
|
|
1045
1009
|
if (yQuery === null && yGroupByExpression !== null) {
|
|
1046
1010
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y", "groupByExpression"], null));
|
|
1047
1011
|
}
|
|
1048
|
-
|
|
1049
1012
|
if (y === null) {
|
|
1050
1013
|
const resetActions = items.map(item => () => item.yExpression = null);
|
|
1051
1014
|
actions.push(...resetActions);
|
|
1052
1015
|
}
|
|
1053
|
-
|
|
1054
1016
|
if (y !== null && ___default["default"].some(items, ({
|
|
1055
1017
|
yExpression
|
|
1056
1018
|
}) => yExpression === null)) {
|
|
@@ -1058,15 +1020,12 @@ const ensureAxisAndItemExpressionInvariant = view => {
|
|
|
1058
1020
|
actions.push(...resetActions);
|
|
1059
1021
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
|
|
1060
1022
|
}
|
|
1061
|
-
|
|
1062
1023
|
if (y !== null && ___default["default"].isEmpty(items)) {
|
|
1063
1024
|
actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
|
|
1064
1025
|
}
|
|
1065
|
-
|
|
1066
1026
|
actions.forEach(action => action());
|
|
1067
1027
|
return view;
|
|
1068
1028
|
};
|
|
1069
|
-
|
|
1070
1029
|
const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant = true) => {
|
|
1071
1030
|
const viewNew = visitView(view, {
|
|
1072
1031
|
visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
@@ -1098,25 +1057,22 @@ const deleteExpressionWithNotFoundFieldsOrTypesInView = (schema, view, ensureAxi
|
|
|
1098
1057
|
switch (view["fibery/type"]) {
|
|
1099
1058
|
case "board":
|
|
1100
1059
|
return deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView(schema, view, ensureAxisInvariant);
|
|
1101
|
-
|
|
1102
1060
|
case "list":
|
|
1103
1061
|
return deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema, view);
|
|
1104
|
-
|
|
1062
|
+
case "grid":
|
|
1063
|
+
return deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema, view);
|
|
1105
1064
|
case "timeline":
|
|
1106
1065
|
return deleteExpressionWithNotFoundFieldsOrTypesInTimelineView(schema, view, ensureAxisInvariant);
|
|
1107
|
-
|
|
1108
1066
|
case "calendar":
|
|
1109
1067
|
return deleteExpressionWithNotFoundFieldsOrTypesInCalendarView(schema, view);
|
|
1110
|
-
|
|
1111
1068
|
case "table":
|
|
1112
1069
|
return deleteExpressionWithNotFoundFieldsOrTypesInTableView(schema, view);
|
|
1113
|
-
|
|
1114
1070
|
case "feed":
|
|
1115
1071
|
return deleteExpressionWithNotFoundFieldsOrTypesInFeedView(schema, view);
|
|
1116
|
-
|
|
1117
1072
|
case "form":
|
|
1118
1073
|
return deleteExpressionWithNotFoundFieldsOrTypesInFormView(schema, view);
|
|
1119
|
-
|
|
1074
|
+
case "map":
|
|
1075
|
+
return deleteExpressionWithNotFoundFieldsOrTypesInMapView(schema, view);
|
|
1120
1076
|
default:
|
|
1121
1077
|
return view;
|
|
1122
1078
|
}
|
|
@@ -1125,22 +1081,20 @@ const fixUserSelectedUnits = (schema, view) => {
|
|
|
1125
1081
|
switch (view["fibery/type"]) {
|
|
1126
1082
|
case "board":
|
|
1127
1083
|
return fixUserSelectedUnitsInBoardView(schema, view);
|
|
1128
|
-
|
|
1129
1084
|
case "list":
|
|
1130
1085
|
return fixUserSelectedUnitsInSmartFolder(schema, view);
|
|
1131
|
-
|
|
1086
|
+
case "grid":
|
|
1087
|
+
return fixUserSelectedUnitsInSmartFolder(schema, view);
|
|
1132
1088
|
case "table":
|
|
1133
1089
|
return fixUserSelectedUnitsInTableView(schema, view);
|
|
1134
|
-
|
|
1135
1090
|
case "timeline":
|
|
1136
1091
|
return fixUserSelectedUnitsInTimelineView(schema, view);
|
|
1137
|
-
|
|
1138
1092
|
case "calendar":
|
|
1139
1093
|
return fixUserSelectedUnitsInCalendarView(schema, view);
|
|
1140
|
-
|
|
1141
1094
|
case "feed":
|
|
1142
1095
|
return fixUserSelectedUnitsInFeedView(schema, view);
|
|
1143
|
-
|
|
1096
|
+
case "map":
|
|
1097
|
+
return fixUserSelectedUnitsInMapView(schema, view);
|
|
1144
1098
|
default:
|
|
1145
1099
|
return view;
|
|
1146
1100
|
}
|
|
@@ -1148,66 +1102,59 @@ const fixUserSelectedUnits = (schema, view) => {
|
|
|
1148
1102
|
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => {
|
|
1149
1103
|
switch (view["fibery/type"]) {
|
|
1150
1104
|
case "board":
|
|
1151
|
-
return fixContextExpressionWithBrokenPath$
|
|
1152
|
-
|
|
1105
|
+
return fixContextExpressionWithBrokenPath$7(schema, view, defaultContextExpression);
|
|
1153
1106
|
case "list":
|
|
1154
1107
|
return fixContextExpressionWithBrokenPath$3(schema, view, defaultContextExpression);
|
|
1155
|
-
|
|
1108
|
+
case "grid":
|
|
1109
|
+
return fixContextExpressionWithBrokenPath$3(schema, view, defaultContextExpression);
|
|
1156
1110
|
case "table":
|
|
1157
1111
|
return fixContextExpressionWithBrokenPath$2(schema, view, defaultContextExpression);
|
|
1158
|
-
|
|
1159
1112
|
case "timeline":
|
|
1160
1113
|
return fixContextExpressionWithBrokenPath$1(schema, view, defaultContextExpression);
|
|
1161
|
-
|
|
1162
1114
|
case "calendar":
|
|
1163
|
-
return fixContextExpressionWithBrokenPath$
|
|
1164
|
-
|
|
1115
|
+
return fixContextExpressionWithBrokenPath$6(schema, view, defaultContextExpression);
|
|
1165
1116
|
case "feed":
|
|
1117
|
+
return fixContextExpressionWithBrokenPath$5(schema, view, defaultContextExpression);
|
|
1118
|
+
case "map":
|
|
1166
1119
|
return fixContextExpressionWithBrokenPath$4(schema, view, defaultContextExpression);
|
|
1167
|
-
|
|
1168
1120
|
default:
|
|
1169
1121
|
return view;
|
|
1170
1122
|
}
|
|
1171
1123
|
};
|
|
1124
|
+
|
|
1172
1125
|
/**
|
|
1173
1126
|
* Removes garbage from view's meta to reduce the size.
|
|
1174
1127
|
*/
|
|
1175
|
-
|
|
1176
1128
|
const collectGarbage = (schema, view) => {
|
|
1177
1129
|
const deleteRemoved = x => {
|
|
1178
1130
|
if (Array.isArray(x)) {
|
|
1179
1131
|
return x.map(deleteRemoved).filter(y => y !== REMOVE);
|
|
1180
1132
|
}
|
|
1181
|
-
|
|
1182
1133
|
if (typeof x === "object" && x !== null) {
|
|
1183
1134
|
let tmp = Object.entries(x);
|
|
1184
1135
|
tmp = tmp.map(e => [e[0], deleteRemoved(e[1])]);
|
|
1185
1136
|
tmp = tmp.filter(e => e[1] !== REMOVE);
|
|
1186
1137
|
return Object.fromEntries(tmp);
|
|
1187
1138
|
}
|
|
1188
|
-
|
|
1189
1139
|
return x;
|
|
1190
1140
|
};
|
|
1191
|
-
|
|
1192
1141
|
switch (view["fibery/type"]) {
|
|
1193
1142
|
case "board":
|
|
1194
|
-
return deleteRemoved(collectGarbage$
|
|
1195
|
-
|
|
1143
|
+
return deleteRemoved(collectGarbage$7(view));
|
|
1196
1144
|
case "list":
|
|
1197
1145
|
return deleteRemoved(collectGarbage$3(view));
|
|
1198
|
-
|
|
1146
|
+
case "grid":
|
|
1147
|
+
return deleteRemoved(collectGarbage$3(view));
|
|
1199
1148
|
case "table":
|
|
1200
1149
|
return deleteRemoved(collectGarbage$2(view));
|
|
1201
|
-
|
|
1202
1150
|
case "timeline":
|
|
1203
1151
|
return deleteRemoved(collectGarbage$1(view));
|
|
1204
|
-
|
|
1205
1152
|
case "calendar":
|
|
1206
|
-
return deleteRemoved(collectGarbage$
|
|
1207
|
-
|
|
1153
|
+
return deleteRemoved(collectGarbage$6(view));
|
|
1208
1154
|
case "feed":
|
|
1155
|
+
return deleteRemoved(collectGarbage$5(view));
|
|
1156
|
+
case "map":
|
|
1209
1157
|
return deleteRemoved(collectGarbage$4(view));
|
|
1210
|
-
|
|
1211
1158
|
default:
|
|
1212
1159
|
return view;
|
|
1213
1160
|
}
|
|
@@ -1216,25 +1163,22 @@ const replaceNamesWithIdsInView = (schema, view) => {
|
|
|
1216
1163
|
switch (view["fibery/type"]) {
|
|
1217
1164
|
case "board":
|
|
1218
1165
|
return replaceNamesWithIdsInBoardView(schema, view);
|
|
1219
|
-
|
|
1220
1166
|
case "list":
|
|
1221
1167
|
return replaceNamesWithIdsInSmartFolder(schema, view);
|
|
1222
|
-
|
|
1168
|
+
case "grid":
|
|
1169
|
+
return replaceNamesWithIdsInSmartFolder(schema, view);
|
|
1223
1170
|
case "table":
|
|
1224
1171
|
return replaceNamesWithIdsInTableView(schema, view);
|
|
1225
|
-
|
|
1226
1172
|
case "timeline":
|
|
1227
1173
|
return replaceNamesWithIdsInTimelineView(schema, view);
|
|
1228
|
-
|
|
1229
1174
|
case "calendar":
|
|
1230
1175
|
return replaceNamesWithIdsInCalendarView(schema, view);
|
|
1231
|
-
|
|
1232
1176
|
case "feed":
|
|
1233
1177
|
return replaceNamesWithIdsInFeedView(schema, view);
|
|
1234
|
-
|
|
1235
1178
|
case "form":
|
|
1236
1179
|
return replaceNamesWithIdsInFormView(schema, view);
|
|
1237
|
-
|
|
1180
|
+
case "map":
|
|
1181
|
+
return replaceNamesWithIdsInMapView(schema, view);
|
|
1238
1182
|
default:
|
|
1239
1183
|
return view;
|
|
1240
1184
|
}
|
|
@@ -1243,25 +1187,22 @@ const replaceIdsWithNamesInView = (schema, view) => {
|
|
|
1243
1187
|
switch (view["fibery/type"]) {
|
|
1244
1188
|
case "board":
|
|
1245
1189
|
return replaceIdsWithNamesInBoardView(schema, view);
|
|
1246
|
-
|
|
1247
1190
|
case "list":
|
|
1248
1191
|
return replaceIdsWithNamesInSmartFolder(schema, view);
|
|
1249
|
-
|
|
1192
|
+
case "grid":
|
|
1193
|
+
return replaceIdsWithNamesInSmartFolder(schema, view);
|
|
1250
1194
|
case "table":
|
|
1251
1195
|
return replaceIdsWithNamesInTableView(schema, view);
|
|
1252
|
-
|
|
1253
1196
|
case "timeline":
|
|
1254
1197
|
return replaceIdsWithNamesInTimelineView(schema, view);
|
|
1255
|
-
|
|
1256
1198
|
case "calendar":
|
|
1257
1199
|
return replaceIdsWithNamesInCalendarView(schema, view);
|
|
1258
|
-
|
|
1259
1200
|
case "feed":
|
|
1260
1201
|
return replaceIdsWithNamesInFeedView(schema, view);
|
|
1261
|
-
|
|
1262
1202
|
case "form":
|
|
1263
1203
|
return replaceIdsWithNamesInFormView(schema, view);
|
|
1264
|
-
|
|
1204
|
+
case "map":
|
|
1205
|
+
return replaceIdsWithNamesInMapView(schema, view);
|
|
1265
1206
|
default:
|
|
1266
1207
|
return view;
|
|
1267
1208
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
@@ -10,13 +10,16 @@
|
|
|
10
10
|
"/lib"
|
|
11
11
|
],
|
|
12
12
|
"private": false,
|
|
13
|
-
"dependencies": {},
|
|
14
13
|
"devDependencies": {
|
|
15
|
-
"@babel/core": "7.
|
|
14
|
+
"@babel/core": "7.20.5",
|
|
16
15
|
"@fibery/babel-preset": "7.2.0",
|
|
17
|
-
"@fibery/eslint-config": "
|
|
16
|
+
"@fibery/eslint-config": "workspace:*",
|
|
17
|
+
"@fibery/expression-utils": "workspace:*",
|
|
18
|
+
"@fibery/schema": "workspace:*",
|
|
19
|
+
"immutability-helper": "2.4.0",
|
|
18
20
|
"jest": "27.5.1",
|
|
19
21
|
"jest-junit": "13.0.0",
|
|
22
|
+
"lodash": "4.17.21",
|
|
20
23
|
"microbundle": "0.15.0"
|
|
21
24
|
},
|
|
22
25
|
"peerDependencies": {
|
|
@@ -28,7 +31,8 @@
|
|
|
28
31
|
"scripts": {
|
|
29
32
|
"build": "rm -rf lib && microbundle index.js -o lib -f cjs --no-compress --target node --sourcemap false",
|
|
30
33
|
"test": "node scripts/test.js",
|
|
31
|
-
"test:ci": "yarn test --
|
|
34
|
+
"test:ci": "yarn test --reporters=default --reporters=jest-junit",
|
|
35
|
+
"test:coverage": "yarn test --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/view --reporters=default --reporters=jest-junit",
|
|
32
36
|
"lint": "eslint ."
|
|
33
37
|
},
|
|
34
38
|
"jest": {
|