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