@fibery/views 1.1.15 → 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,6 +354,7 @@ 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
359
  xExpression: {
304
360
  $apply: xExpression => xExpression ? visitor.visitExpression(fromType, xExpression) : xExpression
@@ -332,6 +388,7 @@ const visitView$5 = (view, visitor) => immutableUpdate__default["default"](view,
332
388
  }
333
389
  }
334
390
  });
391
+
335
392
  const replaceNamesWithIdsViewVisitor = schema => {
336
393
  const visitor = {
337
394
  visitQueryExpression: queryExpression => replaceNamesWithIdsInQueryExpression(schema, queryExpression),
@@ -339,17 +396,21 @@ const replaceNamesWithIdsViewVisitor = schema => {
339
396
  visitEnums: enums => ___default["default"].entries(enums).reduce((result, [type, queryHolder]) => {
340
397
  if (schema.typeObjectsByName.hasOwnProperty(type)) {
341
398
  const typeObject = schema.typeObjectsByName[type];
399
+
342
400
  const fromType = ___default["default"].get(queryHolder, ["query", "q/from"]);
401
+
343
402
  const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
344
403
  result[typeObject.id] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
345
404
  } else {
346
405
  result[type] = queryHolder;
347
406
  }
407
+
348
408
  return result;
349
409
  }, {})
350
410
  };
351
411
  return visitor;
352
412
  };
413
+
353
414
  const replaceIdsWithNamesViewVisitor = schema => {
354
415
  const visitor = {
355
416
  visitQueryExpression: queryExpression => replaceIdsWithNamesInQueryExpression(schema, queryExpression),
@@ -357,17 +418,21 @@ const replaceIdsWithNamesViewVisitor = schema => {
357
418
  visitEnums: enums => ___default["default"].entries(enums).reduce((result, [typeId, queryHolder]) => {
358
419
  if (schema.typeObjectsById.hasOwnProperty(typeId)) {
359
420
  const typeObject = schema.typeObjectsById[typeId];
421
+
360
422
  const fromType = ___default["default"].get(queryHolder, ["query", "q/from"]);
423
+
361
424
  const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
362
425
  result[typeObject.name] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
363
426
  } else {
364
427
  result[typeId] = queryHolder;
365
428
  }
429
+
366
430
  return result;
367
431
  }, {})
368
432
  };
369
433
  return visitor;
370
434
  };
435
+
371
436
  const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = schema => {
372
437
  const visitor = {
373
438
  visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
@@ -377,18 +442,23 @@ const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = schema => {
377
442
  if (schema.typeObjectsByName.hasOwnProperty(type)) {
378
443
  const typeObject = schema.typeObjectsByName[type];
379
444
  const queryHolderResult = visitQueryExpressionHolder(queryHolder, visitor);
445
+
380
446
  if (queryHolderResult) {
381
447
  result[typeObject.name] = queryHolderResult;
382
448
  }
449
+
383
450
  return result;
384
451
  }
452
+
385
453
  return result;
386
454
  }, {});
455
+
387
456
  return ___default["default"].isEmpty(enumsNew) ? null : enumsNew;
388
457
  }
389
458
  };
390
459
  return visitor;
391
460
  };
461
+
392
462
  const fixUserSelectedUnitsViewVisitor = schema => {
393
463
  return {
394
464
  visitQueryExpression: queryExpression => queryExpression,
@@ -397,23 +467,24 @@ const fixUserSelectedUnitsViewVisitor = schema => {
397
467
  visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
398
468
  };
399
469
  };
400
- const replaceIdsWithNamesInBoardView = (schema, view) => visitView$5(view, replaceIdsWithNamesViewVisitor(schema));
401
- 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));
402
473
  const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = (schema, view, ensureAxisInvariant = true) => {
403
- const viewNew = visitView$5(view, deleteExpressionWithNotFoundFieldsOrTypesViewVisitor(schema));
474
+ const viewNew = visitView$4(view, deleteExpressionWithNotFoundFieldsOrTypesViewVisitor(schema));
404
475
  return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant$1(viewNew) : viewNew;
405
476
  };
406
477
  const fixUserSelectedUnitsInBoardView = (schema, view) => {
407
- return visitView$5(view, fixUserSelectedUnitsViewVisitor(schema));
478
+ return visitView$4(view, fixUserSelectedUnitsViewVisitor(schema));
408
479
  };
409
- const fixContextExpressionWithBrokenPath$6 = (schema, view, defaultContextExpression) => visitView$5(view, {
480
+ const fixContextExpressionWithBrokenPath$6 = (schema, view, defaultContextExpression) => visitView$4(view, {
410
481
  visitQueryExpression: query => query,
411
482
  visitExpression: (fromType, expression) => expression,
412
483
  visitEnums: enums => enums,
413
484
  visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
414
485
  });
415
486
  const collectGarbage$6 = view => {
416
- return visitView$5(view, {
487
+ return visitView$4(view, {
417
488
  visitQueryExpression: queryExpression => queryExpression,
418
489
  visitExpression: (fromType, expression) => expression,
419
490
  visitEnums: enums => enums,
@@ -421,11 +492,12 @@ const collectGarbage$6 = view => {
421
492
  });
422
493
  };
423
494
 
424
- const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view, {
495
+ const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view, {
425
496
  "fibery/meta": {
426
497
  items: {
427
498
  $apply: items => items.map(item => {
428
499
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
500
+
429
501
  return fromType ? immutableUpdate__default["default"](item, {
430
502
  startExpression: {
431
503
  $apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
@@ -459,47 +531,49 @@ const visitView$4 = (view, visitor) => immutableUpdate__default["default"](view,
459
531
  }
460
532
  }
461
533
  });
534
+
462
535
  const replaceNamesWithIdsInCalendarView = (schema, view) => {
463
- return visitView$4(view, {
536
+ return visitView$3(view, {
464
537
  visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
465
538
  visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
466
539
  });
467
540
  };
468
541
  const replaceIdsWithNamesInCalendarView = (schema, view) => {
469
- return visitView$4(view, {
542
+ return visitView$3(view, {
470
543
  visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
471
544
  visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
472
545
  });
473
546
  };
474
- const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView$4(view, {
547
+ const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView$3(view, {
475
548
  visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
476
549
  visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
477
550
  });
478
551
  const fixUserSelectedUnitsInCalendarView = (schema, view) => {
479
- return visitView$4(view, {
552
+ return visitView$3(view, {
480
553
  visitExpression: (fromType, expression) => expression,
481
554
  visitQueryExpression: query => query,
482
555
  visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
483
556
  });
484
557
  };
485
- const fixContextExpressionWithBrokenPath$5 = (schema, view, defaultContextExpression) => visitView$4(view, {
558
+ const fixContextExpressionWithBrokenPath$5 = (schema, view, defaultContextExpression) => visitView$3(view, {
486
559
  visitQueryExpression: query => query,
487
560
  visitExpression: (fromType, expression) => expression,
488
561
  visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
489
562
  });
490
563
  const collectGarbage$5 = view => {
491
- return visitView$4(view, {
564
+ return visitView$3(view, {
492
565
  visitExpression: (fromType, expression) => expression,
493
566
  visitQueryExpression: query => query,
494
567
  visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
495
568
  });
496
569
  };
497
570
 
498
- const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view, {
571
+ const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view, {
499
572
  "fibery/meta": {
500
573
  items: {
501
574
  $apply: items => items.map(item => {
502
575
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
576
+
503
577
  return fromType ? immutableUpdate__default["default"](item, {
504
578
  postExpression: {
505
579
  $apply: postExpression => postExpression ? visitor.visitExpression(fromType, postExpression) : postExpression
@@ -530,36 +604,37 @@ const visitView$3 = (view, visitor) => immutableUpdate__default["default"](view,
530
604
  }
531
605
  }
532
606
  });
607
+
533
608
  const replaceNamesWithIdsInFeedView = (schema, view) => {
534
- return visitView$3(view, {
609
+ return visitView$2(view, {
535
610
  visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
536
611
  visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
537
612
  });
538
613
  };
539
614
  const replaceIdsWithNamesInFeedView = (schema, view) => {
540
- return visitView$3(view, {
615
+ return visitView$2(view, {
541
616
  visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
542
617
  visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query)
543
618
  });
544
619
  };
545
- const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView$3(view, {
620
+ const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView$2(view, {
546
621
  visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
547
622
  visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
548
623
  });
549
624
  const fixUserSelectedUnitsInFeedView = (schema, view) => {
550
- return visitView$3(view, {
625
+ return visitView$2(view, {
551
626
  visitExpression: (fromType, expression) => expression,
552
627
  visitQueryExpression: query => query,
553
628
  visitViewUnit: (fromType, unit) => fixViewUnit(schema, fromType, unit)
554
629
  });
555
630
  };
556
- const fixContextExpressionWithBrokenPath$4 = (schema, view, defaultContextExpression) => visitView$3(view, {
631
+ const fixContextExpressionWithBrokenPath$4 = (schema, view, defaultContextExpression) => visitView$2(view, {
557
632
  visitQueryExpression: query => query,
558
633
  visitExpression: (fromType, expression) => expression,
559
634
  visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
560
635
  });
561
636
  const collectGarbage$4 = view => {
562
- return visitView$3(view, {
637
+ return visitView$2(view, {
563
638
  visitExpression: (fromType, expression) => expression,
564
639
  visitQueryExpression: query => query,
565
640
  visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
@@ -568,6 +643,7 @@ const collectGarbage$4 = view => {
568
643
 
569
644
  const replaceNamesWithIdsInFormView = (schema, view) => {
570
645
  var _view$fiberyMeta, _view$fiberyMeta2;
646
+
571
647
  const typeId = (_view$fiberyMeta = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta.typeId;
572
648
  const typeObject = schema.typeObjectsByName.hasOwnProperty(typeId) ? schema.typeObjectsByName[typeId] : null;
573
649
  const fields = (_view$fiberyMeta2 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta2.fields;
@@ -575,6 +651,7 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
575
651
  if (!(typeObject != null && typeObject.fieldObjectsByName.hasOwnProperty(field.id))) {
576
652
  return field;
577
653
  }
654
+
578
655
  return _extends({}, field, {
579
656
  id: typeObject.fieldObjectsByName[field.id].id
580
657
  });
@@ -588,6 +665,7 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
588
665
  };
589
666
  const replaceIdsWithNamesInFormView = (schema, view) => {
590
667
  var _view$fiberyMeta3, _view$fiberyMeta4;
668
+
591
669
  const typeId = (_view$fiberyMeta3 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta3.typeId;
592
670
  const typeObject = schema.typeObjectsById.hasOwnProperty(typeId) ? schema.typeObjectsById[typeId] : null;
593
671
  const fields = (_view$fiberyMeta4 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta4.fields;
@@ -595,6 +673,7 @@ const replaceIdsWithNamesInFormView = (schema, view) => {
595
673
  if (!(typeObject != null && typeObject.fieldObjectsById.hasOwnProperty(field.id))) {
596
674
  return field;
597
675
  }
676
+
598
677
  return _extends({}, field, {
599
678
  id: typeObject.fieldObjectsById[field.id].name
600
679
  });
@@ -608,6 +687,7 @@ const replaceIdsWithNamesInFormView = (schema, view) => {
608
687
  };
609
688
  const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
610
689
  var _view$fiberyMeta5, _view$fiberyMeta6;
690
+
611
691
  // we expect view in names terms here.
612
692
  const typeName = (_view$fiberyMeta5 = view["fibery/meta"]) == null ? void 0 : _view$fiberyMeta5.typeId;
613
693
  const typeObject = schema.typeObjectsByName.hasOwnProperty(typeName) ? schema.typeObjectsByName[typeName] : null;
@@ -621,54 +701,6 @@ const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
621
701
  });
622
702
  };
623
703
 
624
- const visitView$2 = (view, visitor) => immutableUpdate__default["default"](view, {
625
- "fibery/meta": {
626
- items: {
627
- $apply: items => items.map(item => {
628
- const fromType = ___default["default"].get(item, ["query", "q/from"]);
629
- return fromType ? immutableUpdate__default["default"](item, {
630
- locationExpression: {
631
- $apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
632
- },
633
- contextExpression: {
634
- $apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
635
- },
636
- query: {
637
- $apply: query => query ? visitor.visitQueryExpression(query) : null
638
- },
639
- units: {
640
- $apply: units => units ? units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map(unit => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit) : unit) : undefined
641
- },
642
- colorCoding: {
643
- $apply: colorCodings => {
644
- return colorCodings && colorCodings.map(colorCoding => _extends({}, colorCoding, {
645
- expression: visitor.visitExpression(fromType, colorCoding.expression)
646
- })).filter(colorCoding => colorCoding.expression !== null);
647
- }
648
- }
649
- }) : item;
650
- }).filter(item => {
651
- const {
652
- query
653
- } = item;
654
- return query ? item : null;
655
- })
656
- }
657
- }
658
- });
659
- const replaceNamesWithIdsInMapView = (schema, view) => {
660
- return visitView$2(view, {
661
- visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
662
- visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
663
- });
664
- };
665
- const replaceIdsWithNamesInMapView = (schema, view) => {
666
- return visitView$2(view, {
667
- visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
668
- visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
669
- });
670
- };
671
-
672
704
  const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["default"](smartFolder, {
673
705
  "fibery/meta": {
674
706
  items: {
@@ -679,7 +711,9 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
679
711
  if (isOldSmartFolder) {
680
712
  return item;
681
713
  }
714
+
682
715
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
716
+
683
717
  return fromType ? immutableUpdate__default["default"](item, {
684
718
  groupBy: {
685
719
  $apply: groupBy => {
@@ -690,6 +724,7 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
690
724
  }) : item;
691
725
  }).map(item => {
692
726
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
727
+
693
728
  return fromType ? immutableUpdate__default["default"](item, {
694
729
  query: {
695
730
  $apply: query => {
@@ -721,14 +756,17 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
721
756
  }
722
757
  }
723
758
  });
759
+
724
760
  const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, groupByExpression, fromType, removedItems) => {
725
761
  if (!groupByExpression) {
726
762
  return null;
727
763
  }
764
+
728
765
  const [[index, {
729
766
  expression
730
767
  }]] = Object.entries(groupByExpression);
731
768
  const visitedExpression = deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression);
769
+
732
770
  if (visitedExpression) {
733
771
  return {
734
772
  [`${parseInt(index) - removedItems}`]: {
@@ -736,15 +774,19 @@ const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, gr
736
774
  }
737
775
  };
738
776
  }
777
+
739
778
  return null;
740
779
  };
780
+
741
781
  const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromType) => {
742
782
  if (!groupByExpression) {
743
783
  return null;
744
784
  }
785
+
745
786
  const [[index, {
746
787
  expression
747
788
  }]] = Object.entries(groupByExpression);
789
+
748
790
  if (schema.typeObjectsById.hasOwnProperty(fromType)) {
749
791
  const typeObject = schema.typeObjectsById[fromType];
750
792
  return {
@@ -753,15 +795,18 @@ const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromT
753
795
  }
754
796
  };
755
797
  }
798
+
756
799
  return groupByExpression;
757
800
  };
758
801
  const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromType) => {
759
802
  if (!groupByExpression) {
760
803
  return null;
761
804
  }
805
+
762
806
  const [[index, {
763
807
  expression
764
808
  }]] = Object.entries(groupByExpression);
809
+
765
810
  if (schema.typeObjectsByName.hasOwnProperty(fromType)) {
766
811
  const typeObject = schema.typeObjectsByName[fromType];
767
812
  return {
@@ -770,6 +815,7 @@ const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromT
770
815
  }
771
816
  };
772
817
  }
818
+
773
819
  return groupByExpression;
774
820
  };
775
821
  const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
@@ -815,6 +861,7 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
815
861
  items: {
816
862
  $apply: items => items.map(item => {
817
863
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
864
+
818
865
  return fromType ? immutableUpdate__default["default"](item, {
819
866
  query: {
820
867
  $apply: query => query ? visitor.visitQueryExpression(query) : null
@@ -842,6 +889,7 @@ const visitView$1 = (view, visitor) => immutableUpdate__default["default"](view,
842
889
  }
843
890
  }
844
891
  });
892
+
845
893
  const replaceNamesWithIdsInTableView = (schema, view) => visitView$1(view, {
846
894
  visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
847
895
  visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query)
@@ -876,22 +924,29 @@ const visitAxis = (axis, visitor) => {
876
924
  if (!axis) {
877
925
  return axis;
878
926
  }
927
+
879
928
  const fromType = ___default["default"].get(axis, ["query", "q/from"]);
929
+
880
930
  const firstOrNull = x => ___default["default"].first(x) || null;
931
+
881
932
  const axisResult = _extends({}, axis, {
882
933
  query: axis.query && visitor.visitQueryExpression(axis.query),
883
934
  contextExpression: visitContextExpression(fromType, axis.contextExpression, visitor),
884
935
  units: axis.units && axis.units.map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)),
885
936
  groupByExpression: axis.groupByExpression && firstOrNull(visitor.visitExpression(fromType, [axis.groupByExpression]))
886
937
  });
938
+
887
939
  if (!axisResult.query) {
888
940
  return null;
889
941
  }
942
+
890
943
  if (!axisResult.units) {
891
944
  delete axisResult.units;
892
945
  }
946
+
893
947
  return axisResult;
894
948
  };
949
+
895
950
  const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
896
951
  "fibery/meta": {
897
952
  y: {
@@ -900,6 +955,7 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
900
955
  items: {
901
956
  $apply: items => items.map(item => {
902
957
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
958
+
903
959
  return fromType ? immutableUpdate__default["default"](item, {
904
960
  yExpression: {
905
961
  $apply: yExpression => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression
@@ -939,8 +995,10 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
939
995
  if (!milestones) {
940
996
  return milestones;
941
997
  }
998
+
942
999
  return milestones.map(item => {
943
1000
  const fromType = ___default["default"].get(item, ["query", "q/from"]);
1001
+
944
1002
  return fromType ? immutableUpdate__default["default"](item, {
945
1003
  dateExpression: {
946
1004
  $apply: startExpression => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression
@@ -959,6 +1017,7 @@ const visitView = (view, visitor) => immutableUpdate__default["default"](view, {
959
1017
  }
960
1018
  }
961
1019
  });
1020
+
962
1021
  const replaceNamesWithIdsInTimelineView = (schema, view) => {
963
1022
  return visitView(view, {
964
1023
  visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
@@ -971,19 +1030,27 @@ const replaceIdsWithNamesInTimelineView = (schema, view) => {
971
1030
  visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
972
1031
  });
973
1032
  };
1033
+
974
1034
  const ensureAxisAndItemExpressionInvariant = view => {
975
1035
  const actions = [];
1036
+
976
1037
  const y = ___default["default"].get(view, ["fibery/meta", "y"]);
1038
+
977
1039
  const yQuery = ___default["default"].get(view, ["fibery/meta", "y", "query"]);
1040
+
978
1041
  const yGroupByExpression = ___default["default"].get(view, ["fibery/meta", "y", "groupByExpression"]);
1042
+
979
1043
  const items = ___default["default"].get(view, ["fibery/meta", "items"]);
1044
+
980
1045
  if (yQuery === null && yGroupByExpression !== null) {
981
1046
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "y", "groupByExpression"], null));
982
1047
  }
1048
+
983
1049
  if (y === null) {
984
1050
  const resetActions = items.map(item => () => item.yExpression = null);
985
1051
  actions.push(...resetActions);
986
1052
  }
1053
+
987
1054
  if (y !== null && ___default["default"].some(items, ({
988
1055
  yExpression
989
1056
  }) => yExpression === null)) {
@@ -991,12 +1058,15 @@ const ensureAxisAndItemExpressionInvariant = view => {
991
1058
  actions.push(...resetActions);
992
1059
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
993
1060
  }
1061
+
994
1062
  if (y !== null && ___default["default"].isEmpty(items)) {
995
1063
  actions.push(() => ___default["default"].set(view, ["fibery/meta", "y"], null));
996
1064
  }
1065
+
997
1066
  actions.forEach(action => action());
998
1067
  return view;
999
1068
  };
1069
+
1000
1070
  const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant = true) => {
1001
1071
  const viewNew = visitView(view, {
1002
1072
  visitQueryExpression: queryExpression => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
@@ -1028,20 +1098,25 @@ const deleteExpressionWithNotFoundFieldsOrTypesInView = (schema, view, ensureAxi
1028
1098
  switch (view["fibery/type"]) {
1029
1099
  case "board":
1030
1100
  return deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView(schema, view, ensureAxisInvariant);
1101
+
1031
1102
  case "list":
1032
1103
  return deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema, view);
1033
- case "grid":
1034
- return deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema, view);
1104
+
1035
1105
  case "timeline":
1036
1106
  return deleteExpressionWithNotFoundFieldsOrTypesInTimelineView(schema, view, ensureAxisInvariant);
1107
+
1037
1108
  case "calendar":
1038
1109
  return deleteExpressionWithNotFoundFieldsOrTypesInCalendarView(schema, view);
1110
+
1039
1111
  case "table":
1040
1112
  return deleteExpressionWithNotFoundFieldsOrTypesInTableView(schema, view);
1113
+
1041
1114
  case "feed":
1042
1115
  return deleteExpressionWithNotFoundFieldsOrTypesInFeedView(schema, view);
1116
+
1043
1117
  case "form":
1044
1118
  return deleteExpressionWithNotFoundFieldsOrTypesInFormView(schema, view);
1119
+
1045
1120
  default:
1046
1121
  return view;
1047
1122
  }
@@ -1050,18 +1125,22 @@ const fixUserSelectedUnits = (schema, view) => {
1050
1125
  switch (view["fibery/type"]) {
1051
1126
  case "board":
1052
1127
  return fixUserSelectedUnitsInBoardView(schema, view);
1128
+
1053
1129
  case "list":
1054
1130
  return fixUserSelectedUnitsInSmartFolder(schema, view);
1055
- case "grid":
1056
- return fixUserSelectedUnitsInSmartFolder(schema, view);
1131
+
1057
1132
  case "table":
1058
1133
  return fixUserSelectedUnitsInTableView(schema, view);
1134
+
1059
1135
  case "timeline":
1060
1136
  return fixUserSelectedUnitsInTimelineView(schema, view);
1137
+
1061
1138
  case "calendar":
1062
1139
  return fixUserSelectedUnitsInCalendarView(schema, view);
1140
+
1063
1141
  case "feed":
1064
1142
  return fixUserSelectedUnitsInFeedView(schema, view);
1143
+
1065
1144
  default:
1066
1145
  return view;
1067
1146
  }
@@ -1070,54 +1149,65 @@ const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpressi
1070
1149
  switch (view["fibery/type"]) {
1071
1150
  case "board":
1072
1151
  return fixContextExpressionWithBrokenPath$6(schema, view, defaultContextExpression);
1152
+
1073
1153
  case "list":
1074
1154
  return fixContextExpressionWithBrokenPath$3(schema, view, defaultContextExpression);
1075
- case "grid":
1076
- return fixContextExpressionWithBrokenPath$3(schema, view, defaultContextExpression);
1155
+
1077
1156
  case "table":
1078
1157
  return fixContextExpressionWithBrokenPath$2(schema, view, defaultContextExpression);
1158
+
1079
1159
  case "timeline":
1080
1160
  return fixContextExpressionWithBrokenPath$1(schema, view, defaultContextExpression);
1161
+
1081
1162
  case "calendar":
1082
1163
  return fixContextExpressionWithBrokenPath$5(schema, view, defaultContextExpression);
1164
+
1083
1165
  case "feed":
1084
1166
  return fixContextExpressionWithBrokenPath$4(schema, view, defaultContextExpression);
1167
+
1085
1168
  default:
1086
1169
  return view;
1087
1170
  }
1088
1171
  };
1089
-
1090
1172
  /**
1091
1173
  * Removes garbage from view's meta to reduce the size.
1092
1174
  */
1175
+
1093
1176
  const collectGarbage = (schema, view) => {
1094
1177
  const deleteRemoved = x => {
1095
1178
  if (Array.isArray(x)) {
1096
1179
  return x.map(deleteRemoved).filter(y => y !== REMOVE);
1097
1180
  }
1181
+
1098
1182
  if (typeof x === "object" && x !== null) {
1099
1183
  let tmp = Object.entries(x);
1100
1184
  tmp = tmp.map(e => [e[0], deleteRemoved(e[1])]);
1101
1185
  tmp = tmp.filter(e => e[1] !== REMOVE);
1102
1186
  return Object.fromEntries(tmp);
1103
1187
  }
1188
+
1104
1189
  return x;
1105
1190
  };
1191
+
1106
1192
  switch (view["fibery/type"]) {
1107
1193
  case "board":
1108
1194
  return deleteRemoved(collectGarbage$6(view));
1195
+
1109
1196
  case "list":
1110
1197
  return deleteRemoved(collectGarbage$3(view));
1111
- case "grid":
1112
- return deleteRemoved(collectGarbage$3(view));
1198
+
1113
1199
  case "table":
1114
1200
  return deleteRemoved(collectGarbage$2(view));
1201
+
1115
1202
  case "timeline":
1116
1203
  return deleteRemoved(collectGarbage$1(view));
1204
+
1117
1205
  case "calendar":
1118
1206
  return deleteRemoved(collectGarbage$5(view));
1207
+
1119
1208
  case "feed":
1120
1209
  return deleteRemoved(collectGarbage$4(view));
1210
+
1121
1211
  default:
1122
1212
  return view;
1123
1213
  }
@@ -1126,22 +1216,25 @@ const replaceNamesWithIdsInView = (schema, view) => {
1126
1216
  switch (view["fibery/type"]) {
1127
1217
  case "board":
1128
1218
  return replaceNamesWithIdsInBoardView(schema, view);
1219
+
1129
1220
  case "list":
1130
1221
  return replaceNamesWithIdsInSmartFolder(schema, view);
1131
- case "grid":
1132
- return replaceNamesWithIdsInSmartFolder(schema, view);
1222
+
1133
1223
  case "table":
1134
1224
  return replaceNamesWithIdsInTableView(schema, view);
1225
+
1135
1226
  case "timeline":
1136
1227
  return replaceNamesWithIdsInTimelineView(schema, view);
1228
+
1137
1229
  case "calendar":
1138
1230
  return replaceNamesWithIdsInCalendarView(schema, view);
1231
+
1139
1232
  case "feed":
1140
1233
  return replaceNamesWithIdsInFeedView(schema, view);
1234
+
1141
1235
  case "form":
1142
1236
  return replaceNamesWithIdsInFormView(schema, view);
1143
- case "map":
1144
- return replaceNamesWithIdsInMapView(schema, view);
1237
+
1145
1238
  default:
1146
1239
  return view;
1147
1240
  }
@@ -1150,22 +1243,25 @@ const replaceIdsWithNamesInView = (schema, view) => {
1150
1243
  switch (view["fibery/type"]) {
1151
1244
  case "board":
1152
1245
  return replaceIdsWithNamesInBoardView(schema, view);
1246
+
1153
1247
  case "list":
1154
1248
  return replaceIdsWithNamesInSmartFolder(schema, view);
1155
- case "grid":
1156
- return replaceIdsWithNamesInSmartFolder(schema, view);
1249
+
1157
1250
  case "table":
1158
1251
  return replaceIdsWithNamesInTableView(schema, view);
1252
+
1159
1253
  case "timeline":
1160
1254
  return replaceIdsWithNamesInTimelineView(schema, view);
1255
+
1161
1256
  case "calendar":
1162
1257
  return replaceIdsWithNamesInCalendarView(schema, view);
1258
+
1163
1259
  case "feed":
1164
1260
  return replaceIdsWithNamesInFeedView(schema, view);
1261
+
1165
1262
  case "form":
1166
1263
  return replaceIdsWithNamesInFormView(schema, view);
1167
- case "map":
1168
- return replaceIdsWithNamesInMapView(schema, view);
1264
+
1169
1265
  default:
1170
1266
  return view;
1171
1267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/views",
3
- "version": "1.1.15",
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
+ }