@fibery/views 1.1.16 → 1.1.17

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/LICENSE ADDED
@@ -0,0 +1,214 @@
1
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
2
+ LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
3
+ CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
4
+
5
+ 1. DEFINITIONS
6
+
7
+ "Contribution" means:
8
+
9
+ a) in the case of the initial Contributor, the initial code and
10
+ documentation distributed under this Agreement, and
11
+
12
+ b) in the case of each subsequent Contributor:
13
+
14
+ i) changes to the Program, and
15
+
16
+ ii) additions to the Program;
17
+
18
+ where such changes and/or additions to the Program originate from and are
19
+ distributed by that particular Contributor. A Contribution 'originates' from
20
+ a Contributor if it was added to the Program by such Contributor itself or
21
+ anyone acting on such Contributor's behalf. Contributions do not include
22
+ additions to the Program which: (i) are separate modules of software
23
+ distributed in conjunction with the Program under their own license
24
+ agreement, and (ii) are not derivative works of the Program.
25
+
26
+ "Contributor" means any person or entity that distributes the Program.
27
+
28
+ "Licensed Patents" mean patent claims licensable by a Contributor which are
29
+ necessarily infringed by the use or sale of its Contribution alone or when
30
+ combined with the Program.
31
+
32
+ "Program" means the Contributions distributed in accordance with this
33
+ Agreement.
34
+
35
+ "Recipient" means anyone who receives the Program under this Agreement,
36
+ including all Contributors.
37
+
38
+ 2. GRANT OF RIGHTS
39
+
40
+ a) Subject to the terms of this Agreement, each Contributor hereby grants
41
+ Recipient a non-exclusive, worldwide, royalty-free copyright license to
42
+ reproduce, prepare derivative works of, publicly display, publicly perform,
43
+ distribute and sublicense the Contribution of such Contributor, if any, and
44
+ such derivative works, in source code and object code form.
45
+
46
+ b) Subject to the terms of this Agreement, each Contributor hereby grants
47
+ Recipient a non-exclusive, worldwide, royalty-free patent license under
48
+ Licensed Patents to make, use, sell, offer to sell, import and otherwise
49
+ transfer the Contribution of such Contributor, if any, in source code and
50
+ object code form. This patent license shall apply to the combination of the
51
+ Contribution and the Program if, at the time the Contribution is added by the
52
+ Contributor, such addition of the Contribution causes such combination to be
53
+ covered by the Licensed Patents. The patent license shall not apply to any
54
+ other combinations which include the Contribution. No hardware per se is
55
+ licensed hereunder.
56
+
57
+ c) Recipient understands that although each Contributor grants the licenses
58
+ to its Contributions set forth herein, no assurances are provided by any
59
+ Contributor that the Program does not infringe the patent or other
60
+ intellectual property rights of any other entity. Each Contributor disclaims
61
+ any liability to Recipient for claims brought by any other entity based on
62
+ infringement of intellectual property rights or otherwise. As a condition to
63
+ exercising the rights and licenses granted hereunder, each Recipient hereby
64
+ assumes sole responsibility to secure any other intellectual property rights
65
+ needed, if any. For example, if a third party patent license is required to
66
+ allow Recipient to distribute the Program, it is Recipient's responsibility
67
+ to acquire that license before distributing the Program.
68
+
69
+ d) Each Contributor represents that to its knowledge it has sufficient
70
+ copyright rights in its Contribution, if any, to grant the copyright license
71
+ set forth in this Agreement.
72
+
73
+ 3. REQUIREMENTS
74
+
75
+ A Contributor may choose to distribute the Program in object code form under
76
+ its own license agreement, provided that:
77
+
78
+ a) it complies with the terms and conditions of this Agreement; and
79
+
80
+ b) its license agreement:
81
+
82
+ i) effectively disclaims on behalf of all Contributors all warranties and
83
+ conditions, express and implied, including warranties or conditions of title
84
+ and non-infringement, and implied warranties or conditions of merchantability
85
+ and fitness for a particular purpose;
86
+
87
+ ii) effectively excludes on behalf of all Contributors all liability for
88
+ damages, including direct, indirect, special, incidental and consequential
89
+ damages, such as lost profits;
90
+
91
+ iii) states that any provisions which differ from this Agreement are offered
92
+ by that Contributor alone and not by any other party; and
93
+
94
+ iv) states that source code for the Program is available from such
95
+ Contributor, and informs licensees how to obtain it in a reasonable manner on
96
+ or through a medium customarily used for software exchange.
97
+
98
+ When the Program is made available in source code form:
99
+
100
+ a) it must be made available under this Agreement; and
101
+
102
+ b) a copy of this Agreement must be included with each copy of the Program.
103
+
104
+ Contributors may not remove or alter any copyright notices contained within
105
+ the Program.
106
+
107
+ Each Contributor must identify itself as the originator of its Contribution,
108
+ if any, in a manner that reasonably allows subsequent Recipients to identify
109
+ the originator of the Contribution.
110
+
111
+ 4. COMMERCIAL DISTRIBUTION
112
+
113
+ Commercial distributors of software may accept certain responsibilities with
114
+ respect to end users, business partners and the like. While this license is
115
+ intended to facilitate the commercial use of the Program, the Contributor who
116
+ includes the Program in a commercial product offering should do so in a
117
+ manner which does not create potential liability for other Contributors.
118
+ Therefore, if a Contributor includes the Program in a commercial product
119
+ offering, such Contributor ("Commercial Contributor") hereby agrees to defend
120
+ and indemnify every other Contributor ("Indemnified Contributor") against any
121
+ losses, damages and costs (collectively "Losses") arising from claims,
122
+ lawsuits and other legal actions brought by a third party against the
123
+ Indemnified Contributor to the extent caused by the acts or omissions of such
124
+ Commercial Contributor in connection with its distribution of the Program in
125
+ a commercial product offering. The obligations in this section do not apply
126
+ to any claims or Losses relating to any actual or alleged intellectual
127
+ property infringement. In order to qualify, an Indemnified Contributor must:
128
+ a) promptly notify the Commercial Contributor in writing of such claim, and
129
+ b) allow the Commercial Contributor to control, and cooperate with the
130
+ Commercial Contributor in, the defense and any related settlement
131
+ negotiations. The Indemnified Contributor may participate in any such claim
132
+ at its own expense.
133
+
134
+ For example, a Contributor might include the Program in a commercial product
135
+ offering, Product X. That Contributor is then a Commercial Contributor. If
136
+ that Commercial Contributor then makes performance claims, or offers
137
+ warranties related to Product X, those performance claims and warranties are
138
+ such Commercial Contributor's responsibility alone. Under this section, the
139
+ Commercial Contributor would have to defend claims against the other
140
+ Contributors related to those performance claims and warranties, and if a
141
+ court requires any other Contributor to pay any damages as a result, the
142
+ Commercial Contributor must pay those damages.
143
+
144
+ 5. NO WARRANTY
145
+
146
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON
147
+ AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
148
+ EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR
149
+ CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A
150
+ PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the
151
+ appropriateness of using and distributing the Program and assumes all risks
152
+ associated with its exercise of rights under this Agreement , including but
153
+ not limited to the risks and costs of program errors, compliance with
154
+ applicable laws, damage to or loss of data, programs or equipment, and
155
+ unavailability or interruption of operations.
156
+
157
+ 6. DISCLAIMER OF LIABILITY
158
+
159
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
160
+ CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
161
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
162
+ LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
163
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
164
+ ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
165
+ EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
166
+ OF SUCH DAMAGES.
167
+
168
+ 7. GENERAL
169
+
170
+ If any provision of this Agreement is invalid or unenforceable under
171
+ applicable law, it shall not affect the validity or enforceability of the
172
+ remainder of the terms of this Agreement, and without further action by the
173
+ parties hereto, such provision shall be reformed to the minimum extent
174
+ necessary to make such provision valid and enforceable.
175
+
176
+ If Recipient institutes patent litigation against any entity (including a
177
+ cross-claim or counterclaim in a lawsuit) alleging that the Program itself
178
+ (excluding combinations of the Program with other software or hardware)
179
+ infringes such Recipient's patent(s), then such Recipient's rights granted
180
+ under Section 2(b) shall terminate as of the date such litigation is filed.
181
+
182
+ All Recipient's rights under this Agreement shall terminate if it fails to
183
+ comply with any of the material terms or conditions of this Agreement and
184
+ does not cure such failure in a reasonable period of time after becoming
185
+ aware of such noncompliance. If all Recipient's rights under this Agreement
186
+ terminate, Recipient agrees to cease use and distribution of the Program as
187
+ soon as reasonably practicable. However, Recipient's obligations under this
188
+ Agreement and any licenses granted by Recipient relating to the Program shall
189
+ continue and survive.
190
+
191
+ Everyone is permitted to copy and distribute copies of this Agreement, but in
192
+ order to avoid inconsistency the Agreement is copyrighted and may only be
193
+ modified in the following manner. The Agreement Steward reserves the right to
194
+ publish new versions (including revisions) of this Agreement from time to
195
+ time. No one other than the Agreement Steward has the right to modify this
196
+ Agreement. The Eclipse Foundation is the initial Agreement Steward. The
197
+ Eclipse Foundation may assign the responsibility to serve as the Agreement
198
+ Steward to a suitable separate entity. Each new version of the Agreement will
199
+ be given a distinguishing version number. The Program (including
200
+ Contributions) may always be distributed subject to the version of the
201
+ Agreement under which it was received. In addition, after a new version of
202
+ the Agreement is published, Contributor may elect to distribute the Program
203
+ (including its Contributions) under the new version. Except as expressly
204
+ stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
205
+ licenses to the intellectual property of any Contributor under this
206
+ Agreement, whether expressly, by implication, estoppel or otherwise. All
207
+ rights in the Program not expressly granted under this Agreement are
208
+ reserved.
209
+
210
+ This Agreement is governed by the laws of the State of New York and the
211
+ intellectual property laws of the United States of America. No party to this
212
+ Agreement will bring a legal action under this Agreement more than one year
213
+ after the cause of action arose. Each party waives its rights to a jury trial
214
+ in any resulting litigation.
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./src";
package/lib/views.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Removes garbage from view's meta to reduce the size.
3
+ */
4
+ export function collectGarbage(schema: any, view: any): any;
5
+ export function deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema: any, smartFolder: any): any;
6
+ export function deleteExpressionWithNotFoundFieldsOrTypesInView(schema: any, view: any, ensureAxisInvariant?: boolean): any;
7
+ export function fixContextExpressionWithBrokenPath(schema: any, view: any, defaultContextExpression: any): any;
8
+ export function fixUserSelectedUnits(schema: any, view: any): any;
9
+ export function getViewCardTypes({ "fibery/meta": { items } }: {
10
+ "fibery/meta": {
11
+ items: any;
12
+ };
13
+ }): any;
14
+ export function replaceIdsWithNamesInSmartFolder(schema: any, smartFolder: any): any;
15
+ export function replaceIdsWithNamesInView(schema: any, view: any): any;
16
+ export function replaceNamesWithIdsInSmartFolder(schema: any, smartFolder: any): any;
17
+ export function replaceNamesWithIdsInView(schema: any, view: any): any;
package/lib/views.js CHANGED
@@ -9,17 +9,20 @@ var immutableUpdate__default = /*#__PURE__*/_interopDefaultLegacy(immutableUpdat
9
9
  var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
10
10
 
11
11
  function _extends() {
12
- _extends = Object.assign ? Object.assign.bind() : function (target) {
12
+ _extends = Object.assign || function (target) {
13
13
  for (var i = 1; i < arguments.length; i++) {
14
14
  var source = arguments[i];
15
+
15
16
  for (var key in source) {
16
17
  if (Object.prototype.hasOwnProperty.call(source, key)) {
17
18
  target[key] = source[key];
18
19
  }
19
20
  }
20
21
  }
22
+
21
23
  return target;
22
24
  };
25
+
23
26
  return _extends.apply(this, arguments);
24
27
  }
25
28
 
@@ -27,69 +30,86 @@ const getFieldType = (schema, fromType, field) => {
27
30
  if (!schema.typeObjectsByName.hasOwnProperty(fromType) || !schema.typeObjectsByName[fromType].fieldObjectsByName.hasOwnProperty(field)) {
28
31
  return null;
29
32
  }
33
+
30
34
  return schema.typeObjectsByName[fromType].fieldObjectsByName[field].type;
31
35
  };
36
+
32
37
  const getFieldMeta = (schema, fromType, field) => {
33
38
  if (!schema.typeObjectsByName.hasOwnProperty(fromType) || !schema.typeObjectsByName[fromType].fieldObjectsByName.hasOwnProperty(field)) {
34
39
  return null;
35
40
  }
41
+
36
42
  return schema.typeObjectsByName[fromType].fieldObjectsByName[field].rawMeta;
37
43
  };
44
+
38
45
  const getUnitTypeForTextField = fieldMeta => {
39
46
  switch (fieldMeta["ui/type"]) {
40
47
  case "email":
41
48
  return "email";
49
+
42
50
  case "url":
43
51
  return "url";
52
+
44
53
  case "phone":
45
54
  return "phone";
55
+
46
56
  default:
47
57
  return "text";
48
58
  }
49
59
  };
60
+
50
61
  const fixViewUnit = (schema, fromType, unit) => {
51
62
  const {
52
63
  type,
53
64
  expression
54
65
  } = unit;
66
+
55
67
  if (type === "date") {
56
68
  const [field] = expression;
69
+
57
70
  if (getFieldType(schema, fromType, field) === "fibery/date-time") {
58
71
  return _extends({}, unit, {
59
72
  type: "date-time"
60
73
  });
61
74
  }
62
75
  }
76
+
63
77
  if (type === "date-range") {
64
78
  const [field] = expression;
79
+
65
80
  if (getFieldType(schema, fromType, field) === "fibery/date-time-range") {
66
81
  return _extends({}, unit, {
67
82
  type: "date-time-range"
68
83
  });
69
84
  }
70
85
  }
86
+
71
87
  if (type === "text") {
72
88
  const [field] = expression;
73
89
  const fieldType = getFieldType(schema, fromType, field);
90
+
74
91
  if (fieldType === "fibery/email") {
75
92
  return _extends({}, unit, {
76
93
  type: "email"
77
94
  });
78
95
  }
79
96
  }
97
+
80
98
  if (["text", "email", "phone", "url"].includes(type)) {
81
99
  const [field] = expression;
100
+
82
101
  if (getFieldType(schema, fromType, field) === "fibery/text") {
83
102
  return _extends({}, unit, {
84
103
  type: getUnitTypeForTextField(getFieldMeta(schema, fromType, field))
85
104
  });
86
105
  }
87
106
  }
107
+
88
108
  return unit;
89
109
  };
90
110
 
91
- // Return this symbol from a visitor callback to remove the node from the
92
111
  // output. Not supported in all places, add support as needed.
112
+
93
113
  const REMOVE = Symbol("remove");
94
114
  const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, queryExpression) => {
95
115
  const {
@@ -97,6 +117,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, quer
97
117
  "q/where": whereExpression,
98
118
  "q/order-by": orderByExpression
99
119
  } = queryExpression;
120
+
100
121
  if (schema.typeObjectsByName.hasOwnProperty(fromExpression)) {
101
122
  const typeObject = schema.typeObjectsByName[fromExpression];
102
123
  return ___default["default"].pickBy(_extends({}, queryExpression, whereExpression ? {
@@ -105,6 +126,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, quer
105
126
  "q/order-by": visitors.deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitOrderByExpression(orderByExpression)
106
127
  } : null));
107
128
  }
129
+
108
130
  return null;
109
131
  };
110
132
  const replaceNamesWithIdsInExpression = (schema, fromType, expression) => {
@@ -112,6 +134,7 @@ const replaceNamesWithIdsInExpression = (schema, fromType, expression) => {
112
134
  const typeObject = schema.typeObjectsByName[fromType];
113
135
  return visitors.replaceNamesWithIdsVisitor(typeObject).visitExpression(expression);
114
136
  }
137
+
115
138
  return expression;
116
139
  };
117
140
  const replaceIdsWithNamesInExpression = (schema, fromTypeId, expression) => {
@@ -119,17 +142,20 @@ const replaceIdsWithNamesInExpression = (schema, fromTypeId, expression) => {
119
142
  const typeObject = schema.typeObjectsById[fromTypeId];
120
143
  return visitors.replaceIdsWithNamesVisitor(typeObject).visitExpression(expression);
121
144
  }
145
+
122
146
  return expression;
123
147
  };
124
148
  const visitViewUnit = (fromType, unit, visitor) => {
125
149
  const {
126
150
  expression
127
151
  } = unit;
152
+
128
153
  if (expression) {
129
154
  return _extends({}, unit, {
130
155
  expression: visitor.visitExpression(fromType, expression)
131
156
  });
132
157
  }
158
+
133
159
  return unit;
134
160
  };
135
161
  const visitContextExpression = (fromType, contextExpression, visitor) => {
@@ -142,6 +168,7 @@ const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
142
168
  "q/where": whereExpression,
143
169
  "q/order-by": orderByExpression
144
170
  } = queryExpression;
171
+
145
172
  if (schema.typeObjectsById.hasOwnProperty(fromExpression)) {
146
173
  const typeObject = schema.typeObjectsById[fromExpression];
147
174
  return _extends({}, queryExpression, {
@@ -152,6 +179,7 @@ const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
152
179
  "q/order-by": visitors.replaceIdsWithNamesVisitor(typeObject).visitOrderByExpression(orderByExpression)
153
180
  } : null);
154
181
  }
182
+
155
183
  return queryExpression;
156
184
  };
157
185
  const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
@@ -160,6 +188,7 @@ const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
160
188
  "q/where": whereExpression,
161
189
  "q/order-by": orderByExpression
162
190
  } = queryExpression;
191
+
163
192
  if (schema.typeObjectsByName.hasOwnProperty(fromExpression)) {
164
193
  const typeObject = schema.typeObjectsByName[fromExpression];
165
194
  return _extends({}, queryExpression, {
@@ -170,6 +199,7 @@ const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
170
199
  "q/order-by": visitors.replaceNamesWithIdsVisitor(typeObject).visitOrderByExpression(orderByExpression)
171
200
  } : null);
172
201
  }
202
+
173
203
  return queryExpression;
174
204
  };
175
205
  const deleteExpressionWithNotFoundFieldsOrTypesInExpression = (schema, fromType, expression) => {
@@ -177,6 +207,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInExpression = (schema, fromType,
177
207
  const typeObject = schema.typeObjectsByName[fromType];
178
208
  return visitors.deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitExpression(expression);
179
209
  }
210
+
180
211
  return null;
181
212
  };
182
213
  const resetContextExpressionIfBroken = (schema, fromType, expression, defaultExpression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression) || defaultExpression;
@@ -187,6 +218,7 @@ const isUnitExpressionValid = unit => {
187
218
  } = unit;
188
219
  return expression !== null;
189
220
  }
221
+
190
222
  return true;
191
223
  };
192
224
 
@@ -195,16 +227,20 @@ const visitQueryExpressionHolder = (queryHolder, visitor) => {
195
227
  const {
196
228
  query
197
229
  } = queryHolder;
230
+
198
231
  if (query) {
199
232
  const queryNew = visitor.visitQueryExpression(query);
200
233
  return queryNew ? _extends({}, queryHolder, {
201
234
  query: queryNew
202
235
  }) : null;
203
236
  }
237
+
204
238
  return queryHolder;
205
239
  }
240
+
206
241
  return queryHolder;
207
242
  };
243
+
208
244
  const visitAxisUnits = (axis, fromType, visitor) => {
209
245
  return fromType ? immutableUpdate__default["default"](axis, {
210
246
  contextExpression: {
@@ -215,15 +251,20 @@ const visitAxisUnits = (axis, fromType, visitor) => {
215
251
  }
216
252
  }) : axis;
217
253
  };
254
+
218
255
  const visitAxis$1 = (axis, visitor) => {
219
256
  if (axis && axis.hasOwnProperty("query")) {
220
257
  const fromType = ___default["default"].get(axis, ["query", "q/from"]);
258
+
221
259
  const axisWithVisitedQuery = visitQueryExpressionHolder(axis, visitor);
260
+
222
261
  if (axisWithVisitedQuery) {
223
262
  return visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
224
263
  }
264
+
225
265
  return axisWithVisitedQuery;
226
266
  }
267
+
227
268
  if (axis && axis.hasOwnProperty("enums")) {
228
269
  const axisNew = immutableUpdate__default["default"](axis, {
229
270
  enums: {
@@ -235,18 +276,24 @@ const visitAxis$1 = (axis, visitor) => {
235
276
  } = axisNew;
236
277
  return enums ? axisNew : null;
237
278
  }
279
+
238
280
  return axis;
239
281
  };
240
- const isAxisFieldExpression = expression => utils.isFieldExpression(expression) && expression.length === 1;
282
+
241
283
  const ensureAxisAndItemExpressionInvariant$1 = view => {
242
284
  const actions = [];
285
+
243
286
  const x = ___default["default"].get(view, ["fibery/meta", "x"]);
287
+
244
288
  const y = ___default["default"].get(view, ["fibery/meta", "y"]);
289
+
245
290
  const items = ___default["default"].get(view, ["fibery/meta", "items"]);
291
+
246
292
  if (x === null) {
247
293
  const resetActions = items.map(item => () => item.xExpression = null);
248
294
  actions.push(...resetActions);
249
295
  }
296
+
250
297
  if (x !== null && ___default["default"].some(items, ({
251
298
  xExpression
252
299
  }) => xExpression === null)) {
@@ -254,10 +301,12 @@ const ensureAxisAndItemExpressionInvariant$1 = view => {
254
301
  actions.push(...resetActions);
255
302
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "x"], null));
256
303
  }
304
+
257
305
  if (y === null) {
258
306
  const resetActions = items.map(item => () => item.yExpression = null);
259
307
  actions.push(...resetActions);
260
308
  }
309
+
261
310
  if (y !== null && ___default["default"].some(items, ({
262
311
  yExpression
263
312
  }) => yExpression === null)) {
@@ -265,30 +314,36 @@ const ensureAxisAndItemExpressionInvariant$1 = view => {
265
314
  actions.push(...resetActions);
266
315
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
267
316
  }
317
+
268
318
  if (x !== null && ___default["default"].isEmpty(items)) {
269
319
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "x"], null));
270
320
  }
321
+
271
322
  if (y !== null && ___default["default"].isEmpty(items)) {
272
323
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
273
324
  }
325
+
274
326
  if (x !== null && ___default["default"].some(items, ({
275
327
  xExpression
276
- }) => !isAxisFieldExpression(xExpression))) {
328
+ }) => !utils.isAxisFieldExpression(xExpression))) {
277
329
  const resetActions = items.map(item => () => item.xExpression = null);
278
330
  actions.push(...resetActions);
279
331
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "x"], null));
280
332
  }
333
+
281
334
  if (y !== null && ___default["default"].some(items, ({
282
335
  yExpression
283
- }) => !isAxisFieldExpression(yExpression))) {
336
+ }) => !utils.isAxisFieldExpression(yExpression))) {
284
337
  const resetActions = items.map(item => () => item.yExpression = null);
285
338
  actions.push(...resetActions);
286
339
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
287
340
  }
341
+
288
342
  actions.forEach(action => action());
289
343
  return view;
290
344
  };
291
- const visitView$5 = (view, visitor) => immutableUpdate__default["default"](view, {
345
+
346
+ const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view, {
292
347
  "fibery/meta": {
293
348
  x: {
294
349
  $apply: x => visitAxis$1(x, visitor)
@@ -299,10 +354,8 @@ const visitView$5 = (view, visitor) => immutableUpdate__default["default"](view,
299
354
  items: {
300
355
  $apply: items => items.map(item => {
301
356
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
357
+
302
358
  return fromType ? immutableUpdate__default["default"](item, {
303
- coverExpression: {
304
- $apply: coverExpression => coverExpression ? visitor.visitExpression(fromType, coverExpression) : coverExpression
305
- },
306
359
  xExpression: {
307
360
  $apply: xExpression => xExpression ? visitor.visitExpression(fromType, xExpression) : xExpression
308
361
  },
@@ -335,6 +388,7 @@ const visitView$5 = (view, visitor) => immutableUpdate__default["default"](view,
335
388
  }
336
389
  }
337
390
  });
391
+
338
392
  const replaceNamesWithIdsViewVisitor = schema => {
339
393
  const visitor = {
340
394
  visitQueryExpression: queryExpression => replaceNamesWithIdsInQueryExpression(schema, queryExpression),
@@ -342,17 +396,21 @@ const replaceNamesWithIdsViewVisitor = schema => {
342
396
  visitEnums: enums => ___default["default"].entries(enums).reduce((result, [type, queryHolder]) => {
343
397
  if (schema.typeObjectsByName.hasOwnProperty(type)) {
344
398
  const typeObject = schema.typeObjectsByName[type];
399
+
345
400
  const fromType = ___default["default"].get(queryHolder, ["query", "q/from"]);
401
+
346
402
  const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
347
403
  result[typeObject.id] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
348
404
  } else {
349
405
  result[type] = queryHolder;
350
406
  }
407
+
351
408
  return result;
352
409
  }, {})
353
410
  };
354
411
  return visitor;
355
412
  };
413
+
356
414
  const replaceIdsWithNamesViewVisitor = schema => {
357
415
  const visitor = {
358
416
  visitQueryExpression: queryExpression => replaceIdsWithNamesInQueryExpression(schema, queryExpression),
@@ -360,17 +418,21 @@ const replaceIdsWithNamesViewVisitor = schema => {
360
418
  visitEnums: enums => ___default["default"].entries(enums).reduce((result, [typeId, queryHolder]) => {
361
419
  if (schema.typeObjectsById.hasOwnProperty(typeId)) {
362
420
  const typeObject = schema.typeObjectsById[typeId];
421
+
363
422
  const fromType = ___default["default"].get(queryHolder, ["query", "q/from"]);
423
+
364
424
  const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
365
425
  result[typeObject.name] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
366
426
  } else {
367
427
  result[typeId] = queryHolder;
368
428
  }
429
+
369
430
  return result;
370
431
  }, {})
371
432
  };
372
433
  return visitor;
373
434
  };
435
+
374
436
  const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = schema => {
375
437
  const visitor = {
376
438
  visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
@@ -380,18 +442,23 @@ const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = schema => {
380
442
  if (schema.typeObjectsByName.hasOwnProperty(type)) {
381
443
  const typeObject = schema.typeObjectsByName[type];
382
444
  const queryHolderResult = visitQueryExpressionHolder(queryHolder, visitor);
445
+
383
446
  if (queryHolderResult) {
384
447
  result[typeObject.name] = queryHolderResult;
385
448
  }
449
+
386
450
  return result;
387
451
  }
452
+
388
453
  return result;
389
454
  }, {});
455
+
390
456
  return ___default["default"].isEmpty(enumsNew) ? null : enumsNew;
391
457
  }
392
458
  };
393
459
  return visitor;
394
460
  };
461
+
395
462
  const fixUserSelectedUnitsViewVisitor = schema => {
396
463
  return {
397
464
  visitQueryExpression: queryExpression => queryExpression,
@@ -400,23 +467,24 @@ const fixUserSelectedUnitsViewVisitor = schema => {
400
467
  visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
401
468
  };
402
469
  };
403
- const replaceIdsWithNamesInBoardView = (schema, view) => visitView$5(view, replaceIdsWithNamesViewVisitor(schema));
404
- const replaceNamesWithIdsInBoardView = (schema, view) => visitView$5(view, replaceNamesWithIdsViewVisitor(schema));
470
+
471
+ const replaceIdsWithNamesInBoardView = (schema, view) => visitView$4(view, replaceIdsWithNamesViewVisitor(schema));
472
+ const replaceNamesWithIdsInBoardView = (schema, view) => visitView$4(view, replaceNamesWithIdsViewVisitor(schema));
405
473
  const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = (schema, view, ensureAxisInvariant = true) => {
406
- const viewNew = visitView$5(view, deleteExpressionWithNotFoundFieldsOrTypesViewVisitor(schema));
474
+ const viewNew = visitView$4(view, deleteExpressionWithNotFoundFieldsOrTypesViewVisitor(schema));
407
475
  return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant$1(viewNew) : viewNew;
408
476
  };
409
477
  const fixUserSelectedUnitsInBoardView = (schema, view) => {
410
- return visitView$5(view, fixUserSelectedUnitsViewVisitor(schema));
478
+ return visitView$4(view, fixUserSelectedUnitsViewVisitor(schema));
411
479
  };
412
- const fixContextExpressionWithBrokenPath$7 = (schema, view, defaultContextExpression) => visitView$5(view, {
480
+ const fixContextExpressionWithBrokenPath$6 = (schema, view, defaultContextExpression) => visitView$4(view, {
413
481
  visitQueryExpression: query => query,
414
482
  visitExpression: (fromType, expression) => expression,
415
483
  visitEnums: enums => enums,
416
484
  visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
417
485
  });
418
- const collectGarbage$7 = view => {
419
- return visitView$5(view, {
486
+ const collectGarbage$6 = view => {
487
+ return visitView$4(view, {
420
488
  visitQueryExpression: queryExpression => queryExpression,
421
489
  visitExpression: (fromType, expression) => expression,
422
490
  visitEnums: enums => enums,
@@ -424,11 +492,12 @@ const collectGarbage$7 = view => {
424
492
  });
425
493
  };
426
494
 
427
- const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view, {
495
+ const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view, {
428
496
  "fibery/meta": {
429
497
  items: {
430
498
  $apply: items => items.map(item => {
431
499
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
500
+
432
501
  return fromType ? immutableUpdate__default["default"](item, {
433
502
  startExpression: {
434
503
  $apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
@@ -462,47 +531,49 @@ const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view,
462
531
  }
463
532
  }
464
533
  });
534
+
465
535
  const replaceNamesWithIdsInCalendarView = (schema, view) => {
466
- return visitView$4(view, {
536
+ return visitView$3(view, {
467
537
  visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
468
538
  visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
469
539
  });
470
540
  };
471
541
  const replaceIdsWithNamesInCalendarView = (schema, view) => {
472
- return visitView$4(view, {
542
+ return visitView$3(view, {
473
543
  visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
474
544
  visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
475
545
  });
476
546
  };
477
- const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView$4(view, {
547
+ const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView$3(view, {
478
548
  visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
479
549
  visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
480
550
  });
481
551
  const fixUserSelectedUnitsInCalendarView = (schema, view) => {
482
- return visitView$4(view, {
552
+ return visitView$3(view, {
483
553
  visitExpression: (fromType, expression) => expression,
484
554
  visitQueryExpression: query => query,
485
555
  visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
486
556
  });
487
557
  };
488
- const fixContextExpressionWithBrokenPath$6 = (schema, view, defaultContextExpression) => visitView$4(view, {
558
+ const fixContextExpressionWithBrokenPath$5 = (schema, view, defaultContextExpression) => visitView$3(view, {
489
559
  visitQueryExpression: query => query,
490
560
  visitExpression: (fromType, expression) => expression,
491
561
  visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
492
562
  });
493
- const collectGarbage$6 = view => {
494
- return visitView$4(view, {
563
+ const collectGarbage$5 = view => {
564
+ return visitView$3(view, {
495
565
  visitExpression: (fromType, expression) => expression,
496
566
  visitQueryExpression: query => query,
497
567
  visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
498
568
  });
499
569
  };
500
570
 
501
- const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view, {
571
+ const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view, {
502
572
  "fibery/meta": {
503
573
  items: {
504
574
  $apply: items => items.map(item => {
505
575
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
576
+
506
577
  return fromType ? immutableUpdate__default["default"](item, {
507
578
  postExpression: {
508
579
  $apply: postExpression => postExpression ? visitor.visitExpression(fromType, postExpression) : postExpression
@@ -533,36 +604,37 @@ const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view,
533
604
  }
534
605
  }
535
606
  });
607
+
536
608
  const replaceNamesWithIdsInFeedView = (schema, view) => {
537
- return visitView$3(view, {
609
+ return visitView$2(view, {
538
610
  visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
539
611
  visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
540
612
  });
541
613
  };
542
614
  const replaceIdsWithNamesInFeedView = (schema, view) => {
543
- return visitView$3(view, {
615
+ return visitView$2(view, {
544
616
  visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
545
617
  visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
546
618
  });
547
619
  };
548
- const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView$3(view, {
620
+ const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView$2(view, {
549
621
  visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
550
622
  visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
551
623
  });
552
624
  const fixUserSelectedUnitsInFeedView = (schema, view) => {
553
- return visitView$3(view, {
625
+ return visitView$2(view, {
554
626
  visitExpression: (fromType, expression) => expression,
555
627
  visitQueryExpression: query => query,
556
628
  visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
557
629
  });
558
630
  };
559
- const fixContextExpressionWithBrokenPath$5 = (schema, view, defaultContextExpression) => visitView$3(view, {
631
+ const fixContextExpressionWithBrokenPath$4 = (schema, view, defaultContextExpression) => visitView$2(view, {
560
632
  visitQueryExpression: query => query,
561
633
  visitExpression: (fromType, expression) => expression,
562
634
  visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
563
635
  });
564
- const collectGarbage$5 = view => {
565
- return visitView$3(view, {
636
+ const collectGarbage$4 = view => {
637
+ return visitView$2(view, {
566
638
  visitExpression: (fromType, expression) => expression,
567
639
  visitQueryExpression: query => query,
568
640
  visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
@@ -571,6 +643,7 @@ const collectGarbage$5 = view => {
571
643
 
572
644
  const replaceNamesWithIdsInFormView = (schema, view) => {
573
645
  var _view$fiberyMeta, _view$fiberyMeta2;
646
+
574
647
  const typeId = (_view$fiberyMeta = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta.typeId;
575
648
  const typeObject = schema.typeObjectsByName.hasOwnProperty(typeId) ? schema.typeObjectsByName[typeId] : null;
576
649
  const fields = (_view$fiberyMeta2 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta2.fields;
@@ -578,6 +651,7 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
578
651
  if (!(typeObject != null && typeObject.fieldObjectsByName.hasOwnProperty(field.id))) {
579
652
  return field;
580
653
  }
654
+
581
655
  return _extends({}, field, {
582
656
  id: typeObject.fieldObjectsByName[field.id].id
583
657
  });
@@ -591,6 +665,7 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
591
665
  };
592
666
  const replaceIdsWithNamesInFormView = (schema, view) => {
593
667
  var _view$fiberyMeta3, _view$fiberyMeta4;
668
+
594
669
  const typeId = (_view$fiberyMeta3 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta3.typeId;
595
670
  const typeObject = schema.typeObjectsById.hasOwnProperty(typeId) ? schema.typeObjectsById[typeId] : null;
596
671
  const fields = (_view$fiberyMeta4 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta4.fields;
@@ -598,6 +673,7 @@ const replaceIdsWithNamesInFormView = (schema, view) => {
598
673
  if (!(typeObject != null && typeObject.fieldObjectsById.hasOwnProperty(field.id))) {
599
674
  return field;
600
675
  }
676
+
601
677
  return _extends({}, field, {
602
678
  id: typeObject.fieldObjectsById[field.id].name
603
679
  });
@@ -611,6 +687,7 @@ const replaceIdsWithNamesInFormView = (schema, view) => {
611
687
  };
612
688
  const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
613
689
  var _view$fiberyMeta5, _view$fiberyMeta6;
690
+
614
691
  // we expect view in names terms here.
615
692
  const typeName = (_view$fiberyMeta5 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta5.typeId;
616
693
  const typeObject = schema.typeObjectsByName.hasOwnProperty(typeName) ? schema.typeObjectsByName[typeName] : null;
@@ -624,88 +701,19 @@ const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
624
701
  });
625
702
  };
626
703
 
627
- const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view, {
628
- "fibery/meta": {
629
- items: {
630
- $apply: items => items.map(item => {
631
- const fromType = ___default["default"].get(item, ["query", "q/from"]);
632
- return fromType ? immutableUpdate__default["default"](item, {
633
- locationExpression: {
634
- $apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
635
- },
636
- contextExpression: {
637
- $apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
638
- },
639
- query: {
640
- $apply: query => query ? visitor.visitQueryExpression(query) : null
641
- },
642
- units: {
643
- $apply: units => units ? units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit) : undefined
644
- },
645
- colorCoding: {
646
- $apply: colorCodings => {
647
- return colorCodings && colorCodings.map(colorCoding => _extends({}, colorCoding, {
648
- expression: visitor.visitExpression(fromType, colorCoding.expression)
649
- })).filter(colorCoding => colorCoding.expression !== null);
650
- }
651
- }
652
- }) : item;
653
- }).filter(item => {
654
- const {
655
- query
656
- } = item;
657
- return query ? item : null;
658
- })
659
- }
660
- }
661
- });
662
- const replaceNamesWithIdsInMapView = (schema, view) => {
663
- return visitView$2(view, {
664
- visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
665
- visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
666
- });
667
- };
668
- const replaceIdsWithNamesInMapView = (schema, view) => {
669
- return visitView$2(view, {
670
- visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
671
- visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
672
- });
673
- };
674
- const deleteExpressionWithNotFoundFieldsOrTypesInMapView = (schema, view) => visitView$2(view, {
675
- visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
676
- visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
677
- });
678
- const fixUserSelectedUnitsInMapView = (schema, view) => {
679
- return visitView$2(view, {
680
- visitQueryExpression: query => query,
681
- visitExpression: (fromType, expression) => expression,
682
- visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
683
- });
684
- };
685
- const fixContextExpressionWithBrokenPath$4 = (schema, view, defaultContextExpression) => visitView$2(view, {
686
- visitExpression: (fromType, expression) => expression,
687
- visitQueryExpression: query => query,
688
- visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
689
- });
690
- const collectGarbage$4 = view => {
691
- return visitView$2(view, {
692
- visitQueryExpression: query => query,
693
- visitExpression: (fromType, expression) => expression,
694
- visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
695
- });
696
- };
697
-
698
704
  const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["default"](smartFolder, {
699
705
  "fibery/meta": {
700
706
  items: {
701
- $apply: (items = []) => {
707
+ $apply: items => {
702
708
  const isOldSmartFolder = !items.every(item => item.hasOwnProperty("groupBy"));
703
709
  const removedItemsIndexes = items.map((item, index) => visitor.visitQueryExpression(item.query) ? null : index).filter(value => value !== null);
704
710
  return items.map((item, index) => {
705
711
  if (isOldSmartFolder) {
706
712
  return item;
707
713
  }
714
+
708
715
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
716
+
709
717
  return fromType ? immutableUpdate__default["default"](item, {
710
718
  groupBy: {
711
719
  $apply: groupBy => {
@@ -716,6 +724,7 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
716
724
  }) : item;
717
725
  }).map(item => {
718
726
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
727
+
719
728
  return fromType ? immutableUpdate__default["default"](item, {
720
729
  query: {
721
730
  $apply: query => {
@@ -747,14 +756,17 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
747
756
  }
748
757
  }
749
758
  });
759
+
750
760
  const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, groupByExpression, fromType, removedItems) => {
751
761
  if (!groupByExpression) {
752
762
  return null;
753
763
  }
764
+
754
765
  const [[index, {
755
766
  expression
756
767
  }]] = Object.entries(groupByExpression);
757
768
  const visitedExpression = deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression);
769
+
758
770
  if (visitedExpression) {
759
771
  return {
760
772
  [`${parseInt(index) - removedItems}`]: {
@@ -762,15 +774,19 @@ const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, gr
762
774
  }
763
775
  };
764
776
  }
777
+
765
778
  return null;
766
779
  };
780
+
767
781
  const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromType) => {
768
782
  if (!groupByExpression) {
769
783
  return null;
770
784
  }
785
+
771
786
  const [[index, {
772
787
  expression
773
788
  }]] = Object.entries(groupByExpression);
789
+
774
790
  if (schema.typeObjectsById.hasOwnProperty(fromType)) {
775
791
  const typeObject = schema.typeObjectsById[fromType];
776
792
  return {
@@ -779,15 +795,18 @@ const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromT
779
795
  }
780
796
  };
781
797
  }
798
+
782
799
  return groupByExpression;
783
800
  };
784
801
  const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromType) => {
785
802
  if (!groupByExpression) {
786
803
  return null;
787
804
  }
805
+
788
806
  const [[index, {
789
807
  expression
790
808
  }]] = Object.entries(groupByExpression);
809
+
791
810
  if (schema.typeObjectsByName.hasOwnProperty(fromType)) {
792
811
  const typeObject = schema.typeObjectsByName[fromType];
793
812
  return {
@@ -796,6 +815,7 @@ const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromT
796
815
  }
797
816
  };
798
817
  }
818
+
799
819
  return groupByExpression;
800
820
  };
801
821
  const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
@@ -841,6 +861,7 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
841
861
  items: {
842
862
  $apply: items => items.map(item => {
843
863
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
864
+
844
865
  return fromType ? immutableUpdate__default["default"](item, {
845
866
  query: {
846
867
  $apply: query => query ? visitor.visitQueryExpression(query) : null
@@ -868,6 +889,7 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
868
889
  }
869
890
  }
870
891
  });
892
+
871
893
  const replaceNamesWithIdsInTableView = (schema, view) => visitView$1(view, {
872
894
  visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
873
895
  visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
@@ -902,22 +924,29 @@ const visitAxis = (axis, visitor) => {
902
924
  if (!axis) {
903
925
  return axis;
904
926
  }
927
+
905
928
  const fromType = ___default["default"].get(axis, ["query", "q/from"]);
929
+
906
930
  const firstOrNull = x => ___default["default"].first(x) || null;
931
+
907
932
  const axisResult = _extends({}, axis, {
908
933
  query: axis.query && visitor.visitQueryExpression(axis.query),
909
934
  contextExpression: visitContextExpression(fromType, axis.contextExpression, visitor),
910
935
  units: axis.units && axis.units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)),
911
936
  groupByExpression: axis.groupByExpression && firstOrNull(visitor.visitExpression(fromType, [axis.groupByExpression]))
912
937
  });
938
+
913
939
  if (!axisResult.query) {
914
940
  return null;
915
941
  }
942
+
916
943
  if (!axisResult.units) {
917
944
  delete axisResult.units;
918
945
  }
946
+
919
947
  return axisResult;
920
948
  };
949
+
921
950
  const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
922
951
  "fibery/meta": {
923
952
  y: {
@@ -926,6 +955,7 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
926
955
  items: {
927
956
  $apply: items => items.map(item => {
928
957
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
958
+
929
959
  return fromType ? immutableUpdate__default["default"](item, {
930
960
  yExpression: {
931
961
  $apply: yExpression => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression
@@ -965,17 +995,16 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
965
995
  if (!milestones) {
966
996
  return milestones;
967
997
  }
998
+
968
999
  return milestones.map(item => {
969
1000
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
1001
+
970
1002
  return fromType ? immutableUpdate__default["default"](item, {
971
1003
  dateExpression: {
972
1004
  $apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
973
1005
  },
974
1006
  query: {
975
1007
  $apply: query => query ? visitor.visitQueryExpression(query) : null
976
- },
977
- contextExpression: {
978
- $apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
979
1008
  }
980
1009
  }) : item;
981
1010
  }).filter(item => {
@@ -988,6 +1017,7 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
988
1017
  }
989
1018
  }
990
1019
  });
1020
+
991
1021
  const replaceNamesWithIdsInTimelineView = (schema, view) => {
992
1022
  return visitView(view, {
993
1023
  visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
@@ -1000,19 +1030,27 @@ const replaceIdsWithNamesInTimelineView = (schema, view) => {
1000
1030
  visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
1001
1031
  });
1002
1032
  };
1033
+
1003
1034
  const ensureAxisAndItemExpressionInvariant = view => {
1004
1035
  const actions = [];
1036
+
1005
1037
  const y = ___default["default"].get(view, ["fibery/meta", "y"]);
1038
+
1006
1039
  const yQuery = ___default["default"].get(view, ["fibery/meta", "y", "query"]);
1040
+
1007
1041
  const yGroupByExpression = ___default["default"].get(view, ["fibery/meta", "y", "groupByExpression"]);
1042
+
1008
1043
  const items = ___default["default"].get(view, ["fibery/meta", "items"]);
1044
+
1009
1045
  if (yQuery === null && yGroupByExpression !== null) {
1010
1046
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "y", "groupByExpression"], null));
1011
1047
  }
1048
+
1012
1049
  if (y === null) {
1013
1050
  const resetActions = items.map(item => () => item.yExpression = null);
1014
1051
  actions.push(...resetActions);
1015
1052
  }
1053
+
1016
1054
  if (y !== null && ___default["default"].some(items, ({
1017
1055
  yExpression
1018
1056
  }) => yExpression === null)) {
@@ -1020,12 +1058,15 @@ const ensureAxisAndItemExpressionInvariant = view => {
1020
1058
  actions.push(...resetActions);
1021
1059
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
1022
1060
  }
1061
+
1023
1062
  if (y !== null && ___default["default"].isEmpty(items)) {
1024
1063
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
1025
1064
  }
1065
+
1026
1066
  actions.forEach(action => action());
1027
1067
  return view;
1028
1068
  };
1069
+
1029
1070
  const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant = true) => {
1030
1071
  const viewNew = visitView(view, {
1031
1072
  visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
@@ -1057,22 +1098,25 @@ const deleteExpressionWithNotFoundFieldsOrTypesInView = (schema, view, ensureAxi
1057
1098
  switch (view["fibery/type"]) {
1058
1099
  case "board":
1059
1100
  return deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView(schema, view, ensureAxisInvariant);
1101
+
1060
1102
  case "list":
1061
1103
  return deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema, view);
1062
- case "grid":
1063
- return deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema, view);
1104
+
1064
1105
  case "timeline":
1065
1106
  return deleteExpressionWithNotFoundFieldsOrTypesInTimelineView(schema, view, ensureAxisInvariant);
1107
+
1066
1108
  case "calendar":
1067
1109
  return deleteExpressionWithNotFoundFieldsOrTypesInCalendarView(schema, view);
1110
+
1068
1111
  case "table":
1069
1112
  return deleteExpressionWithNotFoundFieldsOrTypesInTableView(schema, view);
1113
+
1070
1114
  case "feed":
1071
1115
  return deleteExpressionWithNotFoundFieldsOrTypesInFeedView(schema, view);
1116
+
1072
1117
  case "form":
1073
1118
  return deleteExpressionWithNotFoundFieldsOrTypesInFormView(schema, view);
1074
- case "map":
1075
- return deleteExpressionWithNotFoundFieldsOrTypesInMapView(schema, view);
1119
+
1076
1120
  default:
1077
1121
  return view;
1078
1122
  }
@@ -1081,20 +1125,22 @@ const fixUserSelectedUnits = (schema, view) => {
1081
1125
  switch (view["fibery/type"]) {
1082
1126
  case "board":
1083
1127
  return fixUserSelectedUnitsInBoardView(schema, view);
1128
+
1084
1129
  case "list":
1085
1130
  return fixUserSelectedUnitsInSmartFolder(schema, view);
1086
- case "grid":
1087
- return fixUserSelectedUnitsInSmartFolder(schema, view);
1131
+
1088
1132
  case "table":
1089
1133
  return fixUserSelectedUnitsInTableView(schema, view);
1134
+
1090
1135
  case "timeline":
1091
1136
  return fixUserSelectedUnitsInTimelineView(schema, view);
1137
+
1092
1138
  case "calendar":
1093
1139
  return fixUserSelectedUnitsInCalendarView(schema, view);
1140
+
1094
1141
  case "feed":
1095
1142
  return fixUserSelectedUnitsInFeedView(schema, view);
1096
- case "map":
1097
- return fixUserSelectedUnitsInMapView(schema, view);
1143
+
1098
1144
  default:
1099
1145
  return view;
1100
1146
  }
@@ -1102,59 +1148,66 @@ const fixUserSelectedUnits = (schema, view) => {
1102
1148
  const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => {
1103
1149
  switch (view["fibery/type"]) {
1104
1150
  case "board":
1105
- return fixContextExpressionWithBrokenPath$7(schema, view, defaultContextExpression);
1151
+ return fixContextExpressionWithBrokenPath$6(schema, view, defaultContextExpression);
1152
+
1106
1153
  case "list":
1107
1154
  return fixContextExpressionWithBrokenPath$3(schema, view, defaultContextExpression);
1108
- case "grid":
1109
- return fixContextExpressionWithBrokenPath$3(schema, view, defaultContextExpression);
1155
+
1110
1156
  case "table":
1111
1157
  return fixContextExpressionWithBrokenPath$2(schema, view, defaultContextExpression);
1158
+
1112
1159
  case "timeline":
1113
1160
  return fixContextExpressionWithBrokenPath$1(schema, view, defaultContextExpression);
1161
+
1114
1162
  case "calendar":
1115
- return fixContextExpressionWithBrokenPath$6(schema, view, defaultContextExpression);
1116
- case "feed":
1117
1163
  return fixContextExpressionWithBrokenPath$5(schema, view, defaultContextExpression);
1118
- case "map":
1164
+
1165
+ case "feed":
1119
1166
  return fixContextExpressionWithBrokenPath$4(schema, view, defaultContextExpression);
1167
+
1120
1168
  default:
1121
1169
  return view;
1122
1170
  }
1123
1171
  };
1124
-
1125
1172
  /**
1126
1173
  * Removes garbage from view's meta to reduce the size.
1127
1174
  */
1175
+
1128
1176
  const collectGarbage = (schema, view) => {
1129
1177
  const deleteRemoved = x => {
1130
1178
  if (Array.isArray(x)) {
1131
1179
  return x.map(deleteRemoved).filter(y => y !== REMOVE);
1132
1180
  }
1181
+
1133
1182
  if (typeof x === "object" && x !== null) {
1134
1183
  let tmp = Object.entries(x);
1135
1184
  tmp = tmp.map(e => [e[0], deleteRemoved(e[1])]);
1136
1185
  tmp = tmp.filter(e => e[1] !== REMOVE);
1137
1186
  return Object.fromEntries(tmp);
1138
1187
  }
1188
+
1139
1189
  return x;
1140
1190
  };
1191
+
1141
1192
  switch (view["fibery/type"]) {
1142
1193
  case "board":
1143
- return deleteRemoved(collectGarbage$7(view));
1194
+ return deleteRemoved(collectGarbage$6(view));
1195
+
1144
1196
  case "list":
1145
1197
  return deleteRemoved(collectGarbage$3(view));
1146
- case "grid":
1147
- return deleteRemoved(collectGarbage$3(view));
1198
+
1148
1199
  case "table":
1149
1200
  return deleteRemoved(collectGarbage$2(view));
1201
+
1150
1202
  case "timeline":
1151
1203
  return deleteRemoved(collectGarbage$1(view));
1204
+
1152
1205
  case "calendar":
1153
- return deleteRemoved(collectGarbage$6(view));
1154
- case "feed":
1155
1206
  return deleteRemoved(collectGarbage$5(view));
1156
- case "map":
1207
+
1208
+ case "feed":
1157
1209
  return deleteRemoved(collectGarbage$4(view));
1210
+
1158
1211
  default:
1159
1212
  return view;
1160
1213
  }
@@ -1163,22 +1216,25 @@ const replaceNamesWithIdsInView = (schema, view) => {
1163
1216
  switch (view["fibery/type"]) {
1164
1217
  case "board":
1165
1218
  return replaceNamesWithIdsInBoardView(schema, view);
1219
+
1166
1220
  case "list":
1167
1221
  return replaceNamesWithIdsInSmartFolder(schema, view);
1168
- case "grid":
1169
- return replaceNamesWithIdsInSmartFolder(schema, view);
1222
+
1170
1223
  case "table":
1171
1224
  return replaceNamesWithIdsInTableView(schema, view);
1225
+
1172
1226
  case "timeline":
1173
1227
  return replaceNamesWithIdsInTimelineView(schema, view);
1228
+
1174
1229
  case "calendar":
1175
1230
  return replaceNamesWithIdsInCalendarView(schema, view);
1231
+
1176
1232
  case "feed":
1177
1233
  return replaceNamesWithIdsInFeedView(schema, view);
1234
+
1178
1235
  case "form":
1179
1236
  return replaceNamesWithIdsInFormView(schema, view);
1180
- case "map":
1181
- return replaceNamesWithIdsInMapView(schema, view);
1237
+
1182
1238
  default:
1183
1239
  return view;
1184
1240
  }
@@ -1187,22 +1243,25 @@ const replaceIdsWithNamesInView = (schema, view) => {
1187
1243
  switch (view["fibery/type"]) {
1188
1244
  case "board":
1189
1245
  return replaceIdsWithNamesInBoardView(schema, view);
1246
+
1190
1247
  case "list":
1191
1248
  return replaceIdsWithNamesInSmartFolder(schema, view);
1192
- case "grid":
1193
- return replaceIdsWithNamesInSmartFolder(schema, view);
1249
+
1194
1250
  case "table":
1195
1251
  return replaceIdsWithNamesInTableView(schema, view);
1252
+
1196
1253
  case "timeline":
1197
1254
  return replaceIdsWithNamesInTimelineView(schema, view);
1255
+
1198
1256
  case "calendar":
1199
1257
  return replaceIdsWithNamesInCalendarView(schema, view);
1258
+
1200
1259
  case "feed":
1201
1260
  return replaceIdsWithNamesInFeedView(schema, view);
1261
+
1202
1262
  case "form":
1203
1263
  return replaceIdsWithNamesInFormView(schema, view);
1204
- case "map":
1205
- return replaceIdsWithNamesInMapView(schema, view);
1264
+
1206
1265
  default:
1207
1266
  return view;
1208
1267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/views",
3
- "version": "1.1.16",
3
+ "version": "1.1.17",
4
4
  "description": "Operations on view objects",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Fibery",
@@ -12,29 +12,22 @@
12
12
  "private": false,
13
13
  "devDependencies": {
14
14
  "@babel/core": "7.20.5",
15
- "@fibery/babel-preset": "7.2.0",
16
- "@fibery/eslint-config": "workspace:*",
17
- "@fibery/expression-utils": "workspace:*",
18
- "@fibery/schema": "workspace:*",
19
15
  "immutability-helper": "2.4.0",
20
16
  "jest": "27.5.1",
21
17
  "jest-junit": "13.0.0",
22
18
  "lodash": "4.17.21",
23
- "microbundle": "0.15.0"
19
+ "microbundle": "0.15.0",
20
+ "@fibery/babel-preset": "7.2.0",
21
+ "@fibery/eslint-config": "8.3.0",
22
+ "@fibery/expression-utils": "1.1.12",
23
+ "@fibery/schema": "8.1.11"
24
24
  },
25
25
  "peerDependencies": {
26
- "@fibery/expression-utils": "^1.1.7",
27
- "@fibery/schema": "^8.1.0",
26
+ "@fibery/expression-utils": "^1.1.12",
27
+ "@fibery/schema": "^8.1.11",
28
28
  "immutability-helper": "^2.4.0",
29
29
  "lodash": "^4.17.21"
30
30
  },
31
- "scripts": {
32
- "build": "rm -rf lib && microbundle index.js -o lib -f cjs --no-compress --target node --sourcemap false",
33
- "test": "node scripts/test.js",
34
- "test:ci": "yarn test --reporters=default --reporters=jest-junit",
35
- "test:coverage": "yarn test --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/view --reporters=default --reporters=jest-junit",
36
- "lint": "eslint ."
37
- },
38
31
  "jest": {
39
32
  "testEnvironment": "node",
40
33
  "coveragePathIgnorePatterns": [
@@ -55,5 +48,12 @@
55
48
  "^.+\\.(js|jsx|ts|tsx)$": "../../fibery-ui/config/jest/babel.js"
56
49
  },
57
50
  "testURL": "http://localhost"
51
+ },
52
+ "scripts": {
53
+ "build": "rm -rf lib && microbundle index.js -o lib -f cjs --no-compress --target node --sourcemap false",
54
+ "test": "node scripts/test.js",
55
+ "test:ci": "yarn test --reporters=default --reporters=jest-junit",
56
+ "test:coverage": "yarn test --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/view --reporters=default --reporters=jest-junit",
57
+ "lint": "eslint ."
58
58
  }
59
- }
59
+ }