@fibery/views 1.1.9 → 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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/lib/views.js +0 -1202
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/views",
3
- "version": "1.1.9",
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,1202 +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
- const fieldObject = typeObject != null && typeObject.fieldObjectsByName.hasOwnProperty(field.id) ? typeObject.fieldObjectsByName[field.id] : null;
631
- return fieldObject ? _extends({}, field, {
632
- id: fieldObject.id
633
- }) : null;
634
- }).filter(Boolean);
635
- return _extends({}, view, {
636
- "fibery/meta": _extends({}, view["fibery/meta"], {
637
- typeId: typeObject ? typeObject.id : typeId,
638
- fields: fieldsInIdsTerms || fields
639
- })
640
- });
641
- };
642
- const replaceIdsWithNamesInFormView = (schema, view) => {
643
- var _view$fiberyMeta3, _view$fiberyMeta4;
644
-
645
- const typeId = (_view$fiberyMeta3 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta3.typeId;
646
- const typeObject = schema.typeObjectsById.hasOwnProperty(typeId) ? schema.typeObjectsById[typeId] : null;
647
- const fields = (_view$fiberyMeta4 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta4.fields;
648
- const fieldsInNameTerms = fields && fields.map(field => {
649
- const fieldObject = typeObject != null && typeObject.fieldObjectsById.hasOwnProperty(field.id) ? typeObject.fieldObjectsById[field.id] : null;
650
- return fieldObject ? _extends({}, field, {
651
- id: fieldObject.name
652
- }) : null;
653
- }).filter(Boolean);
654
- return _extends({}, view, {
655
- "fibery/meta": _extends({}, view["fibery/meta"], {
656
- typeId: typeObject ? typeObject.name : typeId,
657
- fields: fieldsInNameTerms || fields
658
- })
659
- });
660
- };
661
-
662
- const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["default"](smartFolder, {
663
- "fibery/meta": {
664
- items: {
665
- $apply: items => {
666
- const isOldSmartFolder = !items.every(item => item.hasOwnProperty("groupBy"));
667
- const removedItemsIndexes = items.map((item, index) => visitor.visitQueryExpression(item.query) ? null : index).filter(value => value !== null);
668
- return items.map((item, index) => {
669
- if (isOldSmartFolder) {
670
- return item;
671
- }
672
-
673
- const fromType = ___default["default"].get(item, ["query", "q/from"]);
674
-
675
- return fromType ? immutableUpdate__default["default"](item, {
676
- groupBy: {
677
- $apply: groupBy => {
678
- const removedItemsBeforeCurrent = removedItemsIndexes.filter(n => n < index);
679
- return groupBy ? visitor.visitGroupByExpression(groupBy, fromType, removedItemsBeforeCurrent.length) : null;
680
- }
681
- }
682
- }) : item;
683
- }).map(item => {
684
- const fromType = ___default["default"].get(item, ["query", "q/from"]);
685
-
686
- return fromType ? immutableUpdate__default["default"](item, {
687
- query: {
688
- $apply: query => {
689
- const visitedQuery = visitor.visitQueryExpression(query);
690
- return query ? visitedQuery : null;
691
- }
692
- },
693
- units: {
694
- $apply: units => units ? units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit) : undefined
695
- },
696
- contextExpression: {
697
- $apply: contextExpression => contextExpression ? visitor.visitExpression(fromType, contextExpression) : contextExpression
698
- },
699
- colorCoding: {
700
- $apply: colorCodings => {
701
- return colorCodings ? colorCodings.map(colorCoding => _extends({}, colorCoding, {
702
- expression: visitor.visitExpression(fromType, colorCoding.expression)
703
- })).filter(colorCoding => colorCoding.expression !== null) : undefined;
704
- }
705
- }
706
- }) : item;
707
- }).filter(item => {
708
- const {
709
- query
710
- } = item;
711
- return query ? item : null;
712
- });
713
- }
714
- }
715
- }
716
- });
717
-
718
- const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, groupByExpression, fromType, removedItems) => {
719
- if (!groupByExpression) {
720
- return null;
721
- }
722
-
723
- const [[index, {
724
- expression
725
- }]] = Object.entries(groupByExpression);
726
- const visitedExpression = deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression);
727
-
728
- if (visitedExpression) {
729
- return {
730
- [`${parseInt(index) - removedItems}`]: {
731
- expression: visitedExpression
732
- }
733
- };
734
- }
735
-
736
- return null;
737
- };
738
-
739
- const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromType) => {
740
- if (!groupByExpression) {
741
- return null;
742
- }
743
-
744
- const [[index, {
745
- expression
746
- }]] = Object.entries(groupByExpression);
747
-
748
- if (schema.typeObjectsById.hasOwnProperty(fromType)) {
749
- const typeObject = schema.typeObjectsById[fromType];
750
- return {
751
- [index]: {
752
- expression: visitors.replaceIdsWithNamesVisitor(typeObject).visitExpression(expression)
753
- }
754
- };
755
- }
756
-
757
- return null;
758
- };
759
- const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromType) => {
760
- if (!groupByExpression) {
761
- return null;
762
- }
763
-
764
- const [[index, {
765
- expression
766
- }]] = Object.entries(groupByExpression);
767
-
768
- if (schema.typeObjectsByName.hasOwnProperty(fromType)) {
769
- const typeObject = schema.typeObjectsByName[fromType];
770
- return {
771
- [index]: {
772
- expression: visitors.replaceNamesWithIdsVisitor(typeObject).visitExpression(expression)
773
- }
774
- };
775
- }
776
-
777
- return null;
778
- };
779
- const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
780
- visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
781
- visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType),
782
- visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
783
- });
784
- const replaceIdsWithNamesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
785
- visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
786
- visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType),
787
- visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
788
- });
789
- const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
790
- visitQueryExpression: query => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, query),
791
- visitGroupByExpression: (groupBy, fromType, removedItems) => deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression(schema, groupBy, fromType, removedItems),
792
- visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
793
- });
794
- const fixUserSelectedUnitsInSmartFolder = (schema, view) => {
795
- return visitSmartFolder(view, {
796
- visitQueryExpression: query => query,
797
- visitGroupByExpression: groupBy => groupBy,
798
- visitExpression: (fromType, expression) => expression,
799
- visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
800
- });
801
- };
802
- const collectGarbage$3 = view => {
803
- return visitSmartFolder(view, {
804
- visitQueryExpression: query => query,
805
- visitGroupByExpression: groupBy => groupBy,
806
- visitExpression: (fromType, expression) => expression,
807
- visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
808
- });
809
- };
810
-
811
- const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view, {
812
- "fibery/meta": {
813
- items: {
814
- $apply: items => items.map(item => {
815
- const fromType = ___default["default"].get(item, ["query", "q/from"]);
816
-
817
- return fromType ? immutableUpdate__default["default"](item, {
818
- query: {
819
- $apply: query => query ? visitor.visitQueryExpression(query) : null
820
- },
821
- contextExpression: {
822
- $apply: contextExpression => contextExpression ? visitor.visitExpression(fromType, contextExpression) : contextExpression
823
- },
824
- units: {
825
- $apply: units => units ? units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit) : undefined
826
- },
827
- colorCoding: {
828
- $apply: colorCodings => {
829
- return colorCodings && colorCodings.map(colorCoding => _extends({}, colorCoding, {
830
- expression: visitor.visitExpression(fromType, colorCoding.expression)
831
- })).filter(colorCoding => colorCoding.expression !== null);
832
- }
833
- }
834
- }) : item;
835
- }).filter(item => {
836
- const {
837
- query
838
- } = item;
839
- return query ? item : null;
840
- })
841
- }
842
- }
843
- });
844
-
845
- const replaceNamesWithIdsInTableView = (schema, view) => visitView$1(view, {
846
- visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
847
- visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
848
- });
849
- const replaceIdsWithNamesInTableView = (schema, view) => visitView$1(view, {
850
- visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
851
- visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
852
- });
853
- const deleteExpressionWithNotFoundFieldsOrTypesInTableView = (schema, view) => visitView$1(view, {
854
- visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
855
- visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
856
- });
857
- const fixUserSelectedUnitsInTableView = (schema, view) => visitView$1(view, {
858
- visitExpression: (fromType, expression) => expression,
859
- visitQueryExpression: query => query,
860
- visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
861
- });
862
- const collectGarbage$2 = view => {
863
- return visitView$1(view, {
864
- visitExpression: (fromType, expression) => expression,
865
- visitQueryExpression: query => query,
866
- visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
867
- });
868
- };
869
-
870
- const visitAxis = (axis, visitor) => {
871
- if (!axis) {
872
- return axis;
873
- }
874
-
875
- const fromType = ___default["default"].get(axis, ["query", "q/from"]);
876
-
877
- const firstOrNull = x => ___default["default"].first(x) || null;
878
-
879
- const axisResult = _extends({}, axis, {
880
- query: axis.query && visitor.visitQueryExpression(axis.query),
881
- contextExpression: axis.contextExpression && visitor.visitExpression(fromType, axis.contextExpression),
882
- units: axis.units && axis.units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)),
883
- groupByExpression: axis.groupByExpression && firstOrNull(visitor.visitExpression(fromType, [axis.groupByExpression]))
884
- });
885
-
886
- if (!axisResult.query) {
887
- return null;
888
- }
889
-
890
- if (!axisResult.units) {
891
- delete axisResult.units;
892
- }
893
-
894
- return axisResult;
895
- };
896
-
897
- const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
898
- "fibery/meta": {
899
- y: {
900
- $apply: y => visitAxis(y, visitor)
901
- },
902
- items: {
903
- $apply: items => items.map(item => {
904
- const fromType = ___default["default"].get(item, ["query", "q/from"]);
905
-
906
- return fromType ? immutableUpdate__default["default"](item, {
907
- yExpression: {
908
- $apply: yExpression => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression
909
- },
910
- startExpression: {
911
- $apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
912
- },
913
- endExpression: {
914
- $apply: endExpression => endExpression ? visitor.visitExpression(fromType, endExpression) : endExpression
915
- },
916
- contextExpression: {
917
- $apply: contextExpression => contextExpression ? visitor.visitExpression(fromType, contextExpression) : contextExpression
918
- },
919
- query: {
920
- $apply: query => query ? visitor.visitQueryExpression(query) : null
921
- },
922
- units: {
923
- $apply: units => units ? units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit) : undefined
924
- },
925
- colorCoding: {
926
- $apply: colorCodings => {
927
- return colorCodings && colorCodings.map(colorCoding => _extends({}, colorCoding, {
928
- expression: visitor.visitExpression(fromType, colorCoding.expression)
929
- })).filter(colorCoding => colorCoding.expression !== null);
930
- }
931
- }
932
- }) : item;
933
- }).filter(item => {
934
- const {
935
- query
936
- } = item;
937
- return query ? item : null;
938
- })
939
- },
940
- milestones: {
941
- $apply: milestones => {
942
- if (!milestones) {
943
- return milestones;
944
- }
945
-
946
- return milestones.map(item => {
947
- const fromType = ___default["default"].get(item, ["query", "q/from"]);
948
-
949
- return fromType ? immutableUpdate__default["default"](item, {
950
- dateExpression: {
951
- $apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
952
- },
953
- query: {
954
- $apply: query => query ? visitor.visitQueryExpression(query) : null
955
- }
956
- }) : item;
957
- }).filter(item => {
958
- const {
959
- query
960
- } = item;
961
- return query ? item : null;
962
- });
963
- }
964
- }
965
- }
966
- });
967
-
968
- const replaceNamesWithIdsInTimelineView = (schema, view) => {
969
- return visitView(view, {
970
- visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
971
- visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
972
- });
973
- };
974
- const replaceIdsWithNamesInTimelineView = (schema, view) => {
975
- return visitView(view, {
976
- visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
977
- visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
978
- });
979
- };
980
-
981
- const ensureAxisAndItemExpressionInvariant = view => {
982
- const actions = [];
983
-
984
- const y = ___default["default"].get(view, ["fibery/meta", "y"]);
985
-
986
- const yQuery = ___default["default"].get(view, ["fibery/meta", "y", "query"]);
987
-
988
- const yGroupByExpression = ___default["default"].get(view, ["fibery/meta", "y", "groupByExpression"]);
989
-
990
- const items = ___default["default"].get(view, ["fibery/meta", "items"]);
991
-
992
- if (yQuery === null && yGroupByExpression !== null) {
993
- actions.push(() => ___default["default"].set(view, ["fibery/meta", "y", "groupByExpression"], null));
994
- }
995
-
996
- if (y === null) {
997
- const resetActions = items.map(item => () => item.yExpression = null);
998
- actions.push(...resetActions);
999
- }
1000
-
1001
- if (y !== null && ___default["default"].some(items, ({
1002
- yExpression
1003
- }) => yExpression === null)) {
1004
- const resetActions = items.map(item => () => item.yExpression = null);
1005
- actions.push(...resetActions);
1006
- actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
1007
- }
1008
-
1009
- if (y !== null && ___default["default"].isEmpty(items)) {
1010
- actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
1011
- }
1012
-
1013
- actions.forEach(action => action());
1014
- return view;
1015
- };
1016
-
1017
- const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant = true) => {
1018
- const viewNew = visitView(view, {
1019
- visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
1020
- visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
1021
- });
1022
- return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant(viewNew) : viewNew;
1023
- };
1024
- const fixUserSelectedUnitsInTimelineView = (schema, view) => {
1025
- return visitView(view, {
1026
- visitQueryExpression: query => query,
1027
- visitExpression: (fromType, expression) => expression,
1028
- visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
1029
- });
1030
- };
1031
- const collectGarbage$1 = view => {
1032
- return visitView(view, {
1033
- visitQueryExpression: query => query,
1034
- visitExpression: (fromType, expression) => expression,
1035
- visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
1036
- });
1037
- };
1038
-
1039
- const deleteExpressionWithNotFoundFieldsOrTypesInView = (schema, view, ensureAxisInvariant = true) => {
1040
- switch (view["fibery/type"]) {
1041
- case "board":
1042
- return deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView(schema, view, ensureAxisInvariant);
1043
-
1044
- case "list":
1045
- return deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema, view);
1046
-
1047
- case "timeline":
1048
- return deleteExpressionWithNotFoundFieldsOrTypesInTimelineView(schema, view, ensureAxisInvariant);
1049
-
1050
- case "calendar":
1051
- return deleteExpressionWithNotFoundFieldsOrTypesInCalendarView(schema, view);
1052
-
1053
- case "table":
1054
- return deleteExpressionWithNotFoundFieldsOrTypesInTableView(schema, view);
1055
-
1056
- case "feed":
1057
- return deleteExpressionWithNotFoundFieldsOrTypesInFeedView(schema, view);
1058
-
1059
- default:
1060
- return view;
1061
- }
1062
- };
1063
- const fixUserSelectedUnits = (schema, view) => {
1064
- switch (view["fibery/type"]) {
1065
- case "board":
1066
- return fixUserSelectedUnitsInBoardView(schema, view);
1067
-
1068
- case "list":
1069
- return fixUserSelectedUnitsInSmartFolder(schema, view);
1070
-
1071
- case "table":
1072
- return fixUserSelectedUnitsInTableView(schema, view);
1073
-
1074
- case "timeline":
1075
- return fixUserSelectedUnitsInTimelineView(schema, view);
1076
-
1077
- case "calendar":
1078
- return fixUserSelectedUnitsInCalendarView(schema, view);
1079
-
1080
- case "feed":
1081
- return fixUserSelectedUnitsInFeedView(schema, view);
1082
-
1083
- default:
1084
- return view;
1085
- }
1086
- };
1087
- /**
1088
- * Removes garbage from view's meta to reduce the size.
1089
- */
1090
-
1091
- const collectGarbage = (schema, view) => {
1092
- const deleteRemoved = x => {
1093
- if (Array.isArray(x)) {
1094
- return x.map(deleteRemoved).filter(y => y !== REMOVE);
1095
- }
1096
-
1097
- if (typeof x === "object" && x !== null) {
1098
- let tmp = Object.entries(x);
1099
- tmp = tmp.map(e => [e[0], deleteRemoved(e[1])]);
1100
- tmp = tmp.filter(e => e[1] !== REMOVE);
1101
- return Object.fromEntries(tmp);
1102
- }
1103
-
1104
- return x;
1105
- };
1106
-
1107
- switch (view["fibery/type"]) {
1108
- case "board":
1109
- return deleteRemoved(collectGarbage$6(view));
1110
-
1111
- case "list":
1112
- return deleteRemoved(collectGarbage$3(view));
1113
-
1114
- case "table":
1115
- return deleteRemoved(collectGarbage$2(view));
1116
-
1117
- case "timeline":
1118
- return deleteRemoved(collectGarbage$1(view));
1119
-
1120
- case "calendar":
1121
- return deleteRemoved(collectGarbage$5(view));
1122
-
1123
- case "feed":
1124
- return deleteRemoved(collectGarbage$4(view));
1125
-
1126
- default:
1127
- return view;
1128
- }
1129
- };
1130
- const replaceNamesWithIdsInView = (schema, view) => {
1131
- switch (view["fibery/type"]) {
1132
- case "board":
1133
- return replaceNamesWithIdsInBoardView(schema, view);
1134
-
1135
- case "list":
1136
- return replaceNamesWithIdsInSmartFolder(schema, view);
1137
-
1138
- case "table":
1139
- return replaceNamesWithIdsInTableView(schema, view);
1140
-
1141
- case "timeline":
1142
- return replaceNamesWithIdsInTimelineView(schema, view);
1143
-
1144
- case "calendar":
1145
- return replaceNamesWithIdsInCalendarView(schema, view);
1146
-
1147
- case "feed":
1148
- return replaceNamesWithIdsInFeedView(schema, view);
1149
-
1150
- case "form":
1151
- return replaceNamesWithIdsInFormView(schema, view);
1152
-
1153
- default:
1154
- return view;
1155
- }
1156
- };
1157
- const replaceIdsWithNamesInView = (schema, view) => {
1158
- switch (view["fibery/type"]) {
1159
- case "board":
1160
- return replaceIdsWithNamesInBoardView(schema, view);
1161
-
1162
- case "list":
1163
- return replaceIdsWithNamesInSmartFolder(schema, view);
1164
-
1165
- case "table":
1166
- return replaceIdsWithNamesInTableView(schema, view);
1167
-
1168
- case "timeline":
1169
- return replaceIdsWithNamesInTimelineView(schema, view);
1170
-
1171
- case "calendar":
1172
- return replaceIdsWithNamesInCalendarView(schema, view);
1173
-
1174
- case "feed":
1175
- return replaceIdsWithNamesInFeedView(schema, view);
1176
-
1177
- case "form":
1178
- return replaceIdsWithNamesInFormView(schema, view);
1179
-
1180
- default:
1181
- return view;
1182
- }
1183
- };
1184
- const getViewCardTypes = ({
1185
- "fibery/meta": {
1186
- items
1187
- }
1188
- }) => items.map(({
1189
- query: {
1190
- "q/from": type
1191
- }
1192
- }) => type);
1193
-
1194
- exports.collectGarbage = collectGarbage;
1195
- exports.deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder;
1196
- exports.deleteExpressionWithNotFoundFieldsOrTypesInView = deleteExpressionWithNotFoundFieldsOrTypesInView;
1197
- exports.fixUserSelectedUnits = fixUserSelectedUnits;
1198
- exports.getViewCardTypes = getViewCardTypes;
1199
- exports.replaceIdsWithNamesInSmartFolder = replaceIdsWithNamesInSmartFolder;
1200
- exports.replaceIdsWithNamesInView = replaceIdsWithNamesInView;
1201
- exports.replaceNamesWithIdsInSmartFolder = replaceNamesWithIdsInSmartFolder;
1202
- exports.replaceNamesWithIdsInView = replaceNamesWithIdsInView;