@fibery/views 17.0.4 → 18.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/lib/index.js +17 -0
  2. package/lib/jest.config.d.ts +2 -0
  3. package/lib/jest.config.js +33 -0
  4. package/lib/src/field-utils/avatar.d.ts +20 -0
  5. package/lib/src/field-utils/avatar.js +42 -0
  6. package/lib/src/field-utils/back-references.d.ts +15 -0
  7. package/lib/src/field-utils/back-references.js +21 -0
  8. package/lib/src/field-utils/comments.d.ts +60 -0
  9. package/lib/src/field-utils/comments.js +46 -0
  10. package/lib/src/field-utils/date-time.d.ts +14 -0
  11. package/lib/src/field-utils/date-time.js +56 -0
  12. package/lib/src/field-utils/enum-value.d.ts +13 -0
  13. package/lib/src/field-utils/enum-value.js +29 -0
  14. package/lib/src/field-utils/file.d.ts +4 -0
  15. package/lib/src/field-utils/file.js +18 -0
  16. package/lib/src/field-utils/icon.d.ts +10 -0
  17. package/lib/src/field-utils/icon.js +26 -0
  18. package/lib/src/field-utils/number.d.ts +31 -0
  19. package/lib/src/field-utils/number.js +91 -0
  20. package/lib/src/field-utils/reference-collection.d.ts +18 -0
  21. package/lib/src/field-utils/reference-collection.js +45 -0
  22. package/lib/src/field-utils/reference.d.ts +7 -0
  23. package/lib/src/field-utils/reference.js +57 -0
  24. package/lib/src/field-utils/relation-view.d.ts +2 -0
  25. package/lib/src/field-utils/relation-view.js +12 -0
  26. package/lib/src/field-utils/rich-text.d.ts +12 -0
  27. package/lib/src/field-utils/rich-text.js +27 -0
  28. package/lib/src/field-utils/text.d.ts +35 -0
  29. package/lib/src/field-utils/text.js +40 -0
  30. package/lib/src/field-utils/user-active.d.ts +8 -0
  31. package/lib/src/field-utils/user-active.js +28 -0
  32. package/lib/src/field-utils/user-role.d.ts +6 -0
  33. package/lib/src/field-utils/user-role.js +25 -0
  34. package/lib/src/field-utils/workflow.d.ts +15 -0
  35. package/lib/src/field-utils/workflow.js +56 -0
  36. package/lib/src/index.d.ts +16 -0
  37. package/lib/src/index.js +258 -0
  38. package/lib/src/private/board.d.ts +11 -0
  39. package/lib/src/private/board.js +326 -0
  40. package/lib/src/private/calendar.d.ts +10 -0
  41. package/lib/src/private/calendar.js +122 -0
  42. package/lib/src/private/feed.d.ts +10 -0
  43. package/lib/src/private/feed.js +119 -0
  44. package/lib/src/private/form.d.ts +3 -0
  45. package/lib/src/private/form.js +61 -0
  46. package/lib/src/private/map.d.ts +10 -0
  47. package/lib/src/private/map.js +119 -0
  48. package/lib/src/private/smart-folder.d.ts +23 -0
  49. package/lib/src/private/smart-folder.js +274 -0
  50. package/lib/src/private/test-data/garbage-test.d.ts +649 -0
  51. package/lib/src/private/test-data/garbage-test.js +520 -0
  52. package/lib/src/private/test-data/kanban.d.ts +1123 -0
  53. package/lib/src/private/test-data/kanban.js +1203 -0
  54. package/lib/src/private/test-data/tasks.d.ts +3216 -0
  55. package/lib/src/private/test-data/tasks.js +2731 -0
  56. package/lib/src/private/timeline.d.ts +10 -0
  57. package/lib/src/private/timeline.js +323 -0
  58. package/lib/src/private/units.d.ts +6 -0
  59. package/lib/src/private/units.js +144 -0
  60. package/lib/src/private/utils.d.ts +17 -0
  61. package/lib/src/private/utils.js +267 -0
  62. package/lib/src/tsfixme.d.ts +1 -0
  63. package/lib/src/tsfixme.js +2 -0
  64. package/lib/src/unit-definitions/avatar-collection.d.ts +2 -0
  65. package/lib/src/unit-definitions/avatar-collection.js +53 -0
  66. package/lib/src/unit-definitions/avatar-input.d.ts +2 -0
  67. package/lib/src/unit-definitions/avatar-input.js +12 -0
  68. package/lib/src/unit-definitions/avatar.d.ts +2 -0
  69. package/lib/src/unit-definitions/avatar.js +80 -0
  70. package/lib/src/unit-definitions/back-references-list.d.ts +2 -0
  71. package/lib/src/unit-definitions/back-references-list.js +38 -0
  72. package/lib/src/unit-definitions/bool-checkbox.d.ts +2 -0
  73. package/lib/src/unit-definitions/bool-checkbox.js +25 -0
  74. package/lib/src/unit-definitions/bool.d.ts +2 -0
  75. package/lib/src/unit-definitions/bool.js +22 -0
  76. package/lib/src/unit-definitions/collection-count.d.ts +2 -0
  77. package/lib/src/unit-definitions/collection-count.js +32 -0
  78. package/lib/src/unit-definitions/color-input.d.ts +2 -0
  79. package/lib/src/unit-definitions/color-input.js +21 -0
  80. package/lib/src/unit-definitions/comments-list.d.ts +2 -0
  81. package/lib/src/unit-definitions/comments-list.js +25 -0
  82. package/lib/src/unit-definitions/date-range-combobox.d.ts +2 -0
  83. package/lib/src/unit-definitions/date-range-combobox.js +22 -0
  84. package/lib/src/unit-definitions/date-range.d.ts +2 -0
  85. package/lib/src/unit-definitions/date-range.js +22 -0
  86. package/lib/src/unit-definitions/date-time-combobox.d.ts +2 -0
  87. package/lib/src/unit-definitions/date-time-combobox.js +22 -0
  88. package/lib/src/unit-definitions/date.d.ts +2 -0
  89. package/lib/src/unit-definitions/date.js +22 -0
  90. package/lib/src/unit-definitions/email-input.d.ts +2 -0
  91. package/lib/src/unit-definitions/email-input.js +12 -0
  92. package/lib/src/unit-definitions/email.d.ts +2 -0
  93. package/lib/src/unit-definitions/email.js +17 -0
  94. package/lib/src/unit-definitions/emoji.d.ts +2 -0
  95. package/lib/src/unit-definitions/emoji.js +17 -0
  96. package/lib/src/unit-definitions/file-collection-count.d.ts +2 -0
  97. package/lib/src/unit-definitions/file-collection-count.js +30 -0
  98. package/lib/src/unit-definitions/file-compact-collection.d.ts +2 -0
  99. package/lib/src/unit-definitions/file-compact-collection.js +30 -0
  100. package/lib/src/unit-definitions/file-compact-reference.d.ts +2 -0
  101. package/lib/src/unit-definitions/file-compact-reference.js +36 -0
  102. package/lib/src/unit-definitions/file-reference.d.ts +2 -0
  103. package/lib/src/unit-definitions/file-reference.js +26 -0
  104. package/lib/src/unit-definitions/files-gallery.d.ts +2 -0
  105. package/lib/src/unit-definitions/files-gallery.js +30 -0
  106. package/lib/src/unit-definitions/files-l-list-item.d.ts +2 -0
  107. package/lib/src/unit-definitions/files-l-list-item.js +26 -0
  108. package/lib/src/unit-definitions/files-l-list.d.ts +2 -0
  109. package/lib/src/unit-definitions/files-l-list.js +30 -0
  110. package/lib/src/unit-definitions/files-list-item.d.ts +2 -0
  111. package/lib/src/unit-definitions/files-list-item.js +26 -0
  112. package/lib/src/unit-definitions/files-list.d.ts +2 -0
  113. package/lib/src/unit-definitions/files-list.js +30 -0
  114. package/lib/src/unit-definitions/geometry-preview.d.ts +2 -0
  115. package/lib/src/unit-definitions/geometry-preview.js +17 -0
  116. package/lib/src/unit-definitions/icon-button.d.ts +2 -0
  117. package/lib/src/unit-definitions/icon-button.js +29 -0
  118. package/lib/src/unit-definitions/icon-input.d.ts +2 -0
  119. package/lib/src/unit-definitions/icon-input.js +12 -0
  120. package/lib/src/unit-definitions/id.d.ts +2 -0
  121. package/lib/src/unit-definitions/id.js +29 -0
  122. package/lib/src/unit-definitions/index.d.ts +27 -0
  123. package/lib/src/unit-definitions/index.js +57 -0
  124. package/lib/src/unit-definitions/json-input.d.ts +2 -0
  125. package/lib/src/unit-definitions/json-input.js +21 -0
  126. package/lib/src/unit-definitions/location-input.d.ts +2 -0
  127. package/lib/src/unit-definitions/location-input.js +18 -0
  128. package/lib/src/unit-definitions/location.d.ts +2 -0
  129. package/lib/src/unit-definitions/location.js +17 -0
  130. package/lib/src/unit-definitions/not-found.d.ts +2 -0
  131. package/lib/src/unit-definitions/not-found.js +24 -0
  132. package/lib/src/unit-definitions/number-input.d.ts +2 -0
  133. package/lib/src/unit-definitions/number-input.js +22 -0
  134. package/lib/src/unit-definitions/number.d.ts +2 -0
  135. package/lib/src/unit-definitions/number.js +27 -0
  136. package/lib/src/unit-definitions/phone-input.d.ts +2 -0
  137. package/lib/src/unit-definitions/phone-input.js +12 -0
  138. package/lib/src/unit-definitions/phone.d.ts +2 -0
  139. package/lib/src/unit-definitions/phone.js +12 -0
  140. package/lib/src/unit-definitions/progress-bar.d.ts +2 -0
  141. package/lib/src/unit-definitions/progress-bar.js +32 -0
  142. package/lib/src/unit-definitions/reference-collection-combobox.d.ts +2 -0
  143. package/lib/src/unit-definitions/reference-collection-combobox.js +21 -0
  144. package/lib/src/unit-definitions/reference-collection-list.d.ts +2 -0
  145. package/lib/src/unit-definitions/reference-collection-list.js +22 -0
  146. package/lib/src/unit-definitions/reference-collection-view.d.ts +2 -0
  147. package/lib/src/unit-definitions/reference-collection-view.js +19 -0
  148. package/lib/src/unit-definitions/reference-collection.d.ts +2 -0
  149. package/lib/src/unit-definitions/reference-collection.js +27 -0
  150. package/lib/src/unit-definitions/reference-combobox.d.ts +2 -0
  151. package/lib/src/unit-definitions/reference-combobox.js +21 -0
  152. package/lib/src/unit-definitions/reference-icon.d.ts +2 -0
  153. package/lib/src/unit-definitions/reference-icon.js +12 -0
  154. package/lib/src/unit-definitions/reference.d.ts +2 -0
  155. package/lib/src/unit-definitions/reference.js +49 -0
  156. package/lib/src/unit-definitions/rich-text-document.d.ts +2 -0
  157. package/lib/src/unit-definitions/rich-text-document.js +22 -0
  158. package/lib/src/unit-definitions/rich-text-snippet.d.ts +2 -0
  159. package/lib/src/unit-definitions/rich-text-snippet.js +39 -0
  160. package/lib/src/unit-definitions/single-location-preview.d.ts +2 -0
  161. package/lib/src/unit-definitions/single-location-preview.js +17 -0
  162. package/lib/src/unit-definitions/text-input.d.ts +2 -0
  163. package/lib/src/unit-definitions/text-input.js +22 -0
  164. package/lib/src/unit-definitions/text.d.ts +2 -0
  165. package/lib/src/unit-definitions/text.js +22 -0
  166. package/lib/src/unit-definitions/title-input.d.ts +2 -0
  167. package/lib/src/unit-definitions/title-input.js +16 -0
  168. package/lib/src/unit-definitions/title.d.ts +2 -0
  169. package/lib/src/unit-definitions/title.js +34 -0
  170. package/lib/src/unit-definitions/type-badge-abbr.d.ts +2 -0
  171. package/lib/src/unit-definitions/type-badge-abbr.js +25 -0
  172. package/lib/src/unit-definitions/type-badge.d.ts +2 -0
  173. package/lib/src/unit-definitions/type-badge.js +25 -0
  174. package/lib/src/unit-definitions/type-icon.d.ts +2 -0
  175. package/lib/src/unit-definitions/type-icon.js +25 -0
  176. package/lib/src/unit-definitions/url-input.d.ts +2 -0
  177. package/lib/src/unit-definitions/url-input.js +12 -0
  178. package/lib/src/unit-definitions/url.d.ts +2 -0
  179. package/lib/src/unit-definitions/url.js +17 -0
  180. package/lib/src/unit-definitions/user-button.d.ts +2 -0
  181. package/lib/src/unit-definitions/user-button.js +23 -0
  182. package/lib/src/unit-definitions/user-role-input.d.ts +2 -0
  183. package/lib/src/unit-definitions/user-role-input.js +12 -0
  184. package/lib/src/unit-definitions/user-role.d.ts +2 -0
  185. package/lib/src/unit-definitions/user-role.js +29 -0
  186. package/lib/src/unit-utils/access.d.ts +9 -0
  187. package/lib/src/unit-utils/access.js +14 -0
  188. package/lib/src/unit-utils/can-edit-field.d.ts +6 -0
  189. package/lib/src/unit-utils/can-edit-field.js +8 -0
  190. package/lib/src/unit-utils/common.d.ts +14 -0
  191. package/lib/src/unit-utils/common.js +43 -0
  192. package/lib/src/unit-utils/decimal.d.ts +42 -0
  193. package/lib/src/unit-utils/decimal.js +414 -0
  194. package/lib/src/unit-utils/dynamic-keys.d.ts +7 -0
  195. package/lib/src/unit-utils/dynamic-keys.js +13 -0
  196. package/lib/src/unit-utils/enums.d.ts +27 -0
  197. package/lib/src/unit-utils/enums.js +69 -0
  198. package/lib/src/unit-utils/formatters.d.ts +50 -0
  199. package/lib/src/unit-utils/formatters.js +163 -0
  200. package/lib/src/unit-utils/get-export-value.d.ts +45 -0
  201. package/lib/src/unit-utils/get-export-value.js +83 -0
  202. package/lib/src/unit-utils/get-field-label.d.ts +6 -0
  203. package/lib/src/unit-utils/get-field-label.js +10 -0
  204. package/lib/src/unit-utils/get-unmatched-unit-label.d.ts +2 -0
  205. package/lib/src/unit-utils/get-unmatched-unit-label.js +9 -0
  206. package/lib/src/unit-utils/schema.d.ts +4 -0
  207. package/lib/src/unit-utils/schema.js +12 -0
  208. package/lib/src/units/board.d.ts +43 -0
  209. package/lib/src/units/board.js +51 -0
  210. package/lib/src/units/canvas/all-units-data-definitions.d.ts +18 -0
  211. package/lib/src/units/canvas/all-units-data-definitions.js +40 -0
  212. package/lib/src/units/canvas/index.d.ts +42 -0
  213. package/lib/src/units/canvas/index.js +48 -0
  214. package/lib/src/units/canvas/type-badge-abbr.d.ts +36 -0
  215. package/lib/src/units/canvas/type-badge-abbr.js +11 -0
  216. package/lib/src/units/canvas/type-badge.d.ts +36 -0
  217. package/lib/src/units/canvas/type-badge.js +11 -0
  218. package/lib/src/units/default.d.ts +43 -0
  219. package/lib/src/units/default.js +51 -0
  220. package/lib/src/units/gallery.d.ts +3 -0
  221. package/lib/src/units/gallery.js +18 -0
  222. package/lib/src/units/gantt.d.ts +44 -0
  223. package/lib/src/units/gantt.js +59 -0
  224. package/lib/src/units/get-unit-definitions-for-view-type.d.ts +2 -0
  225. package/lib/src/units/get-unit-definitions-for-view-type.js +64 -0
  226. package/lib/src/units/grid.d.ts +42 -0
  227. package/lib/src/units/grid.js +67 -0
  228. package/lib/src/units/list.d.ts +43 -0
  229. package/lib/src/units/list.js +49 -0
  230. package/lib/src/units/make-factory.d.ts +50 -0
  231. package/lib/src/units/make-factory.js +245 -0
  232. package/lib/src/units/types.d.ts +73 -0
  233. package/lib/src/units/types.js +2 -0
  234. package/package.json +42 -52
  235. package/lib/views.js +0 -1813
  236. /package/{index.js → lib/index.d.ts} +0 -0
@@ -0,0 +1,326 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.enableHideWhenEmptyForCheckedEditableUnits = exports.enableHideWhenEmptyForCovers = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInBoardView = exports.deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = exports.replaceNamesWithIdsInBoardView = exports.replaceIdsWithNamesInBoardView = void 0;
7
+ const utils_1 = require("@fibery/expression-utils/src/utils");
8
+ const immutability_helper_1 = __importDefault(require("immutability-helper"));
9
+ const entries_1 = __importDefault(require("lodash/entries"));
10
+ const get_1 = __importDefault(require("lodash/get"));
11
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
12
+ const set_1 = __importDefault(require("lodash/set"));
13
+ const some_1 = __importDefault(require("lodash/some"));
14
+ const units_1 = require("./units");
15
+ const utils_2 = require("./utils");
16
+ const visitQueryExpressionHolder = (queryHolder, visitor) => {
17
+ if (queryHolder) {
18
+ const { query, filter } = queryHolder;
19
+ const newQueryHolder = { ...queryHolder };
20
+ if (query) {
21
+ const queryNew = visitor.visitQueryExpression(query);
22
+ if (queryNew) {
23
+ newQueryHolder.query = queryNew;
24
+ }
25
+ else {
26
+ return null;
27
+ }
28
+ const { "q/from": fromType } = query;
29
+ if (filter && fromType) {
30
+ const filterNew = visitor.visitFilter(fromType, filter);
31
+ if (filterNew) {
32
+ newQueryHolder.filter = filterNew;
33
+ }
34
+ else {
35
+ newQueryHolder.filter = null;
36
+ }
37
+ }
38
+ }
39
+ return newQueryHolder;
40
+ }
41
+ return queryHolder;
42
+ };
43
+ const visitAxisUnits = (axis, fromType, visitor) => {
44
+ return fromType
45
+ ? (0, immutability_helper_1.default)(axis, {
46
+ contextExpression: {
47
+ $apply: (contextExpression) => (0, utils_2.visitContextExpression)(fromType, contextExpression, visitor),
48
+ },
49
+ units: {
50
+ $apply: (units) => units
51
+ ? units
52
+ .filter((unit) => Boolean(unit))
53
+ .map((unit) => (0, utils_2.visitViewUnit)(fromType, unit, visitor))
54
+ .filter((unit) => (0, utils_2.isUnitExpressionValid)(unit))
55
+ .map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
56
+ .filter((unit) => unit !== utils_2.REMOVE)
57
+ : undefined,
58
+ },
59
+ })
60
+ : axis;
61
+ };
62
+ const visitAxis = (axis, visitor) => {
63
+ if (axis && Object.hasOwn(axis, "query")) {
64
+ const fromType = (0, get_1.default)(axis, ["query", "q/from"]);
65
+ const axisWithVisitedQuery = visitQueryExpressionHolder(axis, visitor);
66
+ if (axisWithVisitedQuery) {
67
+ return visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
68
+ }
69
+ return axisWithVisitedQuery;
70
+ }
71
+ if (axis && Object.hasOwn(axis, "enums")) {
72
+ const axisNew = (0, immutability_helper_1.default)(axis, {
73
+ enums: {
74
+ $apply: (enums) => visitor.visitEnums(enums),
75
+ },
76
+ });
77
+ const { enums } = axisNew;
78
+ return enums ? axisNew : null;
79
+ }
80
+ return axis;
81
+ };
82
+ const isAxisFieldExpression = (expression) => (0, utils_1.isFieldExpression)(expression) && expression.length === 1;
83
+ const ensureAxisAndItemExpressionInvariant = (view) => {
84
+ const actions = [];
85
+ const x = (0, get_1.default)(view, ["fibery/meta", "x"]);
86
+ const y = (0, get_1.default)(view, ["fibery/meta", "y"]);
87
+ const items = (0, get_1.default)(view, ["fibery/meta", "items"]);
88
+ if (x === null) {
89
+ const resetActions = items.map((item) => () => (item.xExpression = null));
90
+ actions.push(...resetActions);
91
+ }
92
+ if (x !== null && (0, some_1.default)(items, ({ xExpression }) => xExpression === null)) {
93
+ const resetActions = items.map((item) => () => (item.xExpression = null));
94
+ actions.push(...resetActions);
95
+ actions.push(() => (0, set_1.default)(view, ["fibery/meta", "x"], null));
96
+ }
97
+ if (y === null) {
98
+ const resetActions = items.map((item) => () => (item.yExpression = null));
99
+ actions.push(...resetActions);
100
+ }
101
+ if (y !== null && (0, some_1.default)(items, ({ yExpression }) => yExpression === null)) {
102
+ const resetActions = items.map((item) => () => (item.yExpression = null));
103
+ actions.push(...resetActions);
104
+ actions.push(() => (0, set_1.default)(view, ["fibery/meta", "y"], null));
105
+ }
106
+ if (x !== null && (0, isEmpty_1.default)(items)) {
107
+ actions.push(() => (0, set_1.default)(view, ["fibery/meta", "x"], null));
108
+ }
109
+ if (y !== null && (0, isEmpty_1.default)(items)) {
110
+ actions.push(() => (0, set_1.default)(view, ["fibery/meta", "y"], null));
111
+ }
112
+ if (x !== null && (0, some_1.default)(items, ({ xExpression }) => !isAxisFieldExpression(xExpression))) {
113
+ const resetActions = items.map((item) => () => (item.xExpression = null));
114
+ actions.push(...resetActions);
115
+ actions.push(() => (0, set_1.default)(view, ["fibery/meta", "x"], null));
116
+ }
117
+ if (y !== null && (0, some_1.default)(items, ({ yExpression }) => !isAxisFieldExpression(yExpression))) {
118
+ const resetActions = items.map((item) => () => (item.yExpression = null));
119
+ actions.push(...resetActions);
120
+ actions.push(() => (0, set_1.default)(view, ["fibery/meta", "y"], null));
121
+ }
122
+ actions.forEach((action) => action());
123
+ return view;
124
+ };
125
+ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
126
+ "fibery/meta": {
127
+ x: {
128
+ $apply: (x) => visitAxis(x, visitor),
129
+ },
130
+ y: {
131
+ $apply: (y) => visitAxis(y, visitor),
132
+ },
133
+ items: {
134
+ $apply: (items) => {
135
+ if (!items) {
136
+ return [];
137
+ }
138
+ return items
139
+ .map((item) => {
140
+ const fromType = (0, get_1.default)(item, ["query", "q/from"]);
141
+ return fromType
142
+ ? (0, immutability_helper_1.default)(item, {
143
+ coverExpression: {
144
+ $apply: (coverExpression) => coverExpression ? visitor.visitExpression(fromType, coverExpression) : coverExpression,
145
+ },
146
+ xExpression: {
147
+ $apply: (xExpression) => xExpression ? visitor.visitExpression(fromType, xExpression) : xExpression,
148
+ },
149
+ yExpression: {
150
+ $apply: (yExpression) => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression,
151
+ },
152
+ contextExpression: {
153
+ $apply: (contextExpression) => (0, utils_2.visitContextExpression)(fromType, contextExpression, visitor),
154
+ },
155
+ query: {
156
+ $apply: (query) => (query ? visitor.visitQueryExpression(query) : null),
157
+ },
158
+ filter: {
159
+ $apply: (filter) => (filter ? visitor.visitFilter(fromType, filter) : null),
160
+ },
161
+ units: {
162
+ $apply: (units) => units
163
+ ? units
164
+ .filter((unit) => Boolean(unit))
165
+ .map((unit) => (0, utils_2.visitViewUnit)(fromType, unit, visitor))
166
+ .filter((unit) => (0, utils_2.isUnitExpressionValid)(unit))
167
+ .map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
168
+ .filter((unit) => unit !== utils_2.REMOVE)
169
+ : undefined,
170
+ },
171
+ colorCoding: {
172
+ $apply: (colorCodings) => {
173
+ return colorCodings
174
+ ? colorCodings
175
+ .map((colorCoding) => ({
176
+ ...colorCoding,
177
+ expression: visitor.visitExpression(fromType, colorCoding.expression),
178
+ }))
179
+ .filter((colorCoding) => colorCoding.expression !== null)
180
+ : undefined;
181
+ },
182
+ },
183
+ })
184
+ : item;
185
+ })
186
+ .filter((item) => {
187
+ const { query } = item;
188
+ return query ? item : null;
189
+ });
190
+ },
191
+ },
192
+ },
193
+ });
194
+ const replaceNamesWithIdsViewVisitor = (schema) => {
195
+ const visitor = {
196
+ visitQueryExpression: (queryExpression) => (0, utils_2.replaceNamesWithIdsInQueryExpression)(schema, queryExpression),
197
+ visitFilter: (fromType, filter) => (0, utils_2.replaceNamesWithIdsInFilter)(schema, fromType, filter),
198
+ visitExpression: (fromType, expression) => (0, utils_2.replaceNamesWithIdsInExpression)(schema, fromType, expression),
199
+ visitEnums: (enums) => (0, entries_1.default)(enums).reduce((result, [type, queryHolder]) => {
200
+ if (Object.hasOwn(schema.typeObjectsByName, type)) {
201
+ const typeObject = schema.typeObjectsByName[type];
202
+ const fromType = (0, get_1.default)(queryHolder, ["query", "q/from"]);
203
+ const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
204
+ result[typeObject.id] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
205
+ }
206
+ else {
207
+ result[type] = queryHolder;
208
+ }
209
+ return result;
210
+ }, {}),
211
+ };
212
+ return visitor;
213
+ };
214
+ const replaceIdsWithNamesViewVisitor = (schema) => {
215
+ const visitor = {
216
+ visitQueryExpression: (queryExpression) => (0, utils_2.replaceIdsWithNamesInQueryExpression)(schema, queryExpression),
217
+ visitFilter: (fromType, filter) => {
218
+ return (0, utils_2.replaceIdsWithNamesInFilter)(schema, fromType, filter);
219
+ },
220
+ visitExpression: (fromType, expression) => (0, utils_2.replaceIdsWithNamesInExpression)(schema, fromType, expression),
221
+ visitEnums: (enums) => (0, entries_1.default)(enums).reduce((result, [typeId, queryHolder]) => {
222
+ if (Object.hasOwn(schema.typeObjectsById, typeId)) {
223
+ const typeObject = schema.typeObjectsById[typeId];
224
+ const fromType = (0, get_1.default)(queryHolder, ["query", "q/from"]);
225
+ const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
226
+ result[typeObject.name] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
227
+ }
228
+ else {
229
+ result[typeId] = queryHolder;
230
+ }
231
+ return result;
232
+ }, {}),
233
+ };
234
+ return visitor;
235
+ };
236
+ const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = (schema) => {
237
+ const visitor = {
238
+ visitQueryExpression: (queryExpression) => (0, utils_2.deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression)(schema, queryExpression),
239
+ visitFilter: (fromType, filter) => (0, utils_2.deleteExpressionWithNotFoundFieldsOrTypesInFilter)(schema, fromType, filter),
240
+ visitExpression: (fromType, expression) => (0, utils_2.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
241
+ visitEnums: (enums) => {
242
+ const enumsNew = (0, entries_1.default)(enums).reduce((result, [type, queryHolder]) => {
243
+ if (Object.hasOwn(schema.typeObjectsByName, type)) {
244
+ const typeObject = schema.typeObjectsByName[type];
245
+ const queryHolderResult = visitQueryExpressionHolder(queryHolder, visitor);
246
+ if (queryHolderResult) {
247
+ result[typeObject.name] = queryHolderResult;
248
+ }
249
+ return result;
250
+ }
251
+ return result;
252
+ }, {});
253
+ return (0, isEmpty_1.default)(enumsNew) ? null : enumsNew;
254
+ },
255
+ };
256
+ return visitor;
257
+ };
258
+ const fixUserSelectedUnitsViewVisitor = (schema, { unitDefinitions, getDefaultUnitTypeForField }) => {
259
+ return {
260
+ visitQueryExpression: (queryExpression) => queryExpression,
261
+ visitFilter: (_fromType, filter) => filter,
262
+ visitExpression: (_fromType, expression) => expression,
263
+ visitEnums: (enums) => enums,
264
+ visitViewUnit: (fromType, unit, units) => (0, units_1.fixViewUnit)(schema, fromType, unit, units, { unitDefinitions, getDefaultUnitTypeForField }),
265
+ };
266
+ };
267
+ const replaceIdsWithNamesInBoardView = (schema, view) => visitView(view, replaceIdsWithNamesViewVisitor(schema));
268
+ exports.replaceIdsWithNamesInBoardView = replaceIdsWithNamesInBoardView;
269
+ const replaceNamesWithIdsInBoardView = (schema, view) => visitView(view, replaceNamesWithIdsViewVisitor(schema));
270
+ exports.replaceNamesWithIdsInBoardView = replaceNamesWithIdsInBoardView;
271
+ const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = (schema, view, ensureAxisInvariant = true) => {
272
+ const viewNew = visitView(view, deleteExpressionWithNotFoundFieldsOrTypesViewVisitor(schema));
273
+ return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant(viewNew) : viewNew;
274
+ };
275
+ exports.deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView;
276
+ const fixUserSelectedUnitsInBoardView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
277
+ return visitView(view, fixUserSelectedUnitsViewVisitor(schema, { unitDefinitions, getDefaultUnitTypeForField }));
278
+ };
279
+ exports.fixUserSelectedUnitsInBoardView = fixUserSelectedUnitsInBoardView;
280
+ const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, {
281
+ visitQueryExpression: (query) => query,
282
+ visitFilter: (_fromType, filter) => filter,
283
+ visitExpression: (_fromType, expression) => expression,
284
+ visitEnums: (enums) => enums,
285
+ visitContextExpression: (fromType, expression) => (0, utils_2.resetContextExpressionIfBroken)(schema, fromType, expression, defaultContextExpression),
286
+ });
287
+ exports.fixContextExpressionWithBrokenPath = fixContextExpressionWithBrokenPath;
288
+ const collectGarbage = (view) => {
289
+ return visitView(view, {
290
+ visitQueryExpression: (queryExpression) => queryExpression,
291
+ visitFilter: (_fromType, filter) => filter,
292
+ visitExpression: (fromType, expression) => expression,
293
+ visitEnums: (enums) => enums,
294
+ visitViewUnit: (fromType, unit) => (unit.checked ? unit : utils_2.REMOVE),
295
+ });
296
+ };
297
+ exports.collectGarbage = collectGarbage;
298
+ const enableHideWhenEmptyForCovers = (view) => {
299
+ return (0, immutability_helper_1.default)(view, {
300
+ "fibery/meta": {
301
+ items: {
302
+ $apply: (items) => items.map((item) => {
303
+ if (!item.coverExpression) {
304
+ return item;
305
+ }
306
+ return {
307
+ ...item,
308
+ coverHideWhenEmpty: true,
309
+ };
310
+ }),
311
+ },
312
+ },
313
+ });
314
+ };
315
+ exports.enableHideWhenEmptyForCovers = enableHideWhenEmptyForCovers;
316
+ const enableHideWhenEmptyForCheckedEditableUnits = (view) => {
317
+ return visitView(view, {
318
+ visitFilter: (_fromType, filter) => filter,
319
+ visitQueryExpression: (queryExpression) => queryExpression,
320
+ visitGroupByExpression: (groupBy) => groupBy,
321
+ visitExpression: (fromType, expression) => expression,
322
+ visitEnums: (enums) => enums,
323
+ visitViewUnit: (fromType, unit) => (0, units_1.enableHideWhenEmptyForCheckedEditableUnit)(unit),
324
+ });
325
+ };
326
+ exports.enableHideWhenEmptyForCheckedEditableUnits = enableHideWhenEmptyForCheckedEditableUnits;
@@ -0,0 +1,10 @@
1
+ export function replaceNamesWithIdsInCalendarView(schema: any, view: any): any;
2
+ export function replaceIdsWithNamesInCalendarView(schema: any, view: any): any;
3
+ export function deleteExpressionWithNotFoundFieldsOrTypesInCalendarView(schema: any, view: any): any;
4
+ export function fixUserSelectedUnitsInCalendarView(schema: any, view: any, { unitDefinitions, getDefaultUnitTypeForField }: {
5
+ unitDefinitions: any;
6
+ getDefaultUnitTypeForField: any;
7
+ }): any;
8
+ export function fixContextExpressionWithBrokenPath(schema: any, view: any, defaultContextExpression: any): any;
9
+ export function collectGarbage(view: any): any;
10
+ export function enableHideWhenEmptyForCheckedUnits(view: any): any;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInCalendarView = exports.deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = exports.replaceIdsWithNamesInCalendarView = exports.replaceNamesWithIdsInCalendarView = void 0;
7
+ const immutability_helper_1 = __importDefault(require("immutability-helper"));
8
+ const get_1 = __importDefault(require("lodash/get"));
9
+ const units_1 = require("./units");
10
+ const utils_1 = require("./utils");
11
+ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
12
+ "fibery/meta": {
13
+ items: {
14
+ $apply: (items) => items
15
+ .map((item) => {
16
+ const fromType = (0, get_1.default)(item, ["query", "q/from"]);
17
+ return fromType
18
+ ? (0, immutability_helper_1.default)(item, {
19
+ startExpression: {
20
+ $apply: (startExpression) => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression,
21
+ },
22
+ endExpression: {
23
+ $apply: (endExpression) => endExpression ? visitor.visitExpression(fromType, endExpression) : endExpression,
24
+ },
25
+ contextExpression: {
26
+ $apply: (contextExpression) => (0, utils_1.visitContextExpression)(fromType, contextExpression, visitor),
27
+ },
28
+ query: {
29
+ $apply: (query) => (query ? visitor.visitQueryExpression(query) : null),
30
+ },
31
+ filter: {
32
+ $apply: (filter) => (filter ? visitor.visitFilter(fromType, filter) : null),
33
+ },
34
+ units: {
35
+ $apply: (units) => units
36
+ ? units
37
+ .filter((unit) => Boolean(unit))
38
+ .map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
39
+ .filter((unit) => (0, utils_1.isUnitExpressionValid)(unit))
40
+ .map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
41
+ .filter((unit) => unit !== utils_1.REMOVE)
42
+ : undefined,
43
+ },
44
+ colorCoding: {
45
+ $apply: (colorCodings) => {
46
+ return (colorCodings &&
47
+ colorCodings
48
+ .map((colorCoding) => ({
49
+ ...colorCoding,
50
+ expression: visitor.visitExpression(fromType, colorCoding.expression),
51
+ }))
52
+ .filter((colorCoding) => colorCoding.expression !== null));
53
+ },
54
+ },
55
+ })
56
+ : item;
57
+ })
58
+ .filter((item) => {
59
+ const { query } = item;
60
+ return query ? item : null;
61
+ }),
62
+ },
63
+ },
64
+ });
65
+ const replaceNamesWithIdsInCalendarView = (schema, view) => {
66
+ return visitView(view, {
67
+ visitExpression: (fromType, expression) => (0, utils_1.replaceNamesWithIdsInExpression)(schema, fromType, expression),
68
+ visitFilter: (fromType, expression) => (0, utils_1.replaceNamesWithIdsInFilter)(schema, fromType, expression),
69
+ visitQueryExpression: (query) => (0, utils_1.replaceNamesWithIdsInQueryExpression)(schema, query),
70
+ });
71
+ };
72
+ exports.replaceNamesWithIdsInCalendarView = replaceNamesWithIdsInCalendarView;
73
+ const replaceIdsWithNamesInCalendarView = (schema, view) => {
74
+ return visitView(view, {
75
+ visitExpression: (fromType, expression) => (0, utils_1.replaceIdsWithNamesInExpression)(schema, fromType, expression),
76
+ visitFilter: (fromType, expression) => (0, utils_1.replaceIdsWithNamesInFilter)(schema, fromType, expression),
77
+ visitQueryExpression: (query) => (0, utils_1.replaceIdsWithNamesInQueryExpression)(schema, query),
78
+ });
79
+ };
80
+ exports.replaceIdsWithNamesInCalendarView = replaceIdsWithNamesInCalendarView;
81
+ const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView(view, {
82
+ visitQueryExpression: (queryExpression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression)(schema, queryExpression),
83
+ visitFilter: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInFilter)(schema, fromType, expression),
84
+ visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
85
+ });
86
+ exports.deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = deleteExpressionWithNotFoundFieldsOrTypesInCalendarView;
87
+ const fixUserSelectedUnitsInCalendarView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
88
+ return visitView(view, {
89
+ visitExpression: (_fromType, expression) => expression,
90
+ visitFilter: (_fromType, filter) => filter,
91
+ visitQueryExpression: (query) => query,
92
+ visitViewUnit: (fromType, unit, units) => (0, units_1.fixViewUnit)(schema, fromType, unit, units, { unitDefinitions, getDefaultUnitTypeForField }),
93
+ });
94
+ };
95
+ exports.fixUserSelectedUnitsInCalendarView = fixUserSelectedUnitsInCalendarView;
96
+ const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, {
97
+ visitQueryExpression: (query) => query,
98
+ visitFilter: (_fromType, filter) => filter,
99
+ visitExpression: (fromType, expression) => expression,
100
+ visitContextExpression: (fromType, expression) => (0, utils_1.resetContextExpressionIfBroken)(schema, fromType, expression, defaultContextExpression),
101
+ });
102
+ exports.fixContextExpressionWithBrokenPath = fixContextExpressionWithBrokenPath;
103
+ const collectGarbage = (view) => {
104
+ return visitView(view, {
105
+ visitExpression: (fromType, expression) => expression,
106
+ visitFilter: (_fromType, filter) => filter,
107
+ visitQueryExpression: (query) => query,
108
+ visitViewUnit: (fromType, unit) => (unit.checked ? unit : utils_1.REMOVE),
109
+ });
110
+ };
111
+ exports.collectGarbage = collectGarbage;
112
+ const enableHideWhenEmptyForCheckedUnits = (view) => {
113
+ return visitView(view, {
114
+ visitQueryExpression: (queryExpression) => queryExpression,
115
+ visitFilter: (_fromType, filter) => filter,
116
+ visitGroupByExpression: (groupBy) => groupBy,
117
+ visitExpression: (fromType, expression) => expression,
118
+ visitEnums: (enums) => enums,
119
+ visitViewUnit: (fromType, unit) => (0, units_1.enableHideWhenEmptyForCheckedEditableUnit)(unit),
120
+ });
121
+ };
122
+ exports.enableHideWhenEmptyForCheckedUnits = enableHideWhenEmptyForCheckedUnits;
@@ -0,0 +1,10 @@
1
+ export function replaceNamesWithIdsInFeedView(schema: any, view: any): any;
2
+ export function replaceIdsWithNamesInFeedView(schema: any, view: any): any;
3
+ export function deleteExpressionWithNotFoundFieldsOrTypesInFeedView(schema: any, view: any): any;
4
+ export function fixUserSelectedUnitsInFeedView(schema: any, view: any, { unitDefinitions, getDefaultUnitTypeForField }: {
5
+ unitDefinitions: any;
6
+ getDefaultUnitTypeForField: any;
7
+ }): any;
8
+ export function fixContextExpressionWithBrokenPath(schema: any, view: any, defaultContextExpression: any): any;
9
+ export function collectGarbage(view: any): any;
10
+ export function enableHideWhenEmptyForCheckedUnits(view: any): any;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInFeedView = exports.deleteExpressionWithNotFoundFieldsOrTypesInFeedView = exports.replaceIdsWithNamesInFeedView = exports.replaceNamesWithIdsInFeedView = void 0;
7
+ const immutability_helper_1 = __importDefault(require("immutability-helper"));
8
+ const get_1 = __importDefault(require("lodash/get"));
9
+ const units_1 = require("./units");
10
+ const utils_1 = require("./utils");
11
+ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
12
+ "fibery/meta": {
13
+ items: {
14
+ $apply: (items) => items
15
+ .map((item) => {
16
+ const fromType = (0, get_1.default)(item, ["query", "q/from"]);
17
+ return fromType
18
+ ? (0, immutability_helper_1.default)(item, {
19
+ postExpression: {
20
+ $apply: (postExpression) => postExpression ? visitor.visitExpression(fromType, postExpression) : postExpression,
21
+ },
22
+ contextExpression: {
23
+ $apply: (contextExpression) => (0, utils_1.visitContextExpression)(fromType, contextExpression, visitor),
24
+ },
25
+ query: {
26
+ $apply: (query) => (query ? visitor.visitQueryExpression(query) : null),
27
+ },
28
+ filter: {
29
+ $apply: (filter) => (filter ? visitor.visitFilter(fromType, filter) : null),
30
+ },
31
+ units: {
32
+ $apply: (units) => units
33
+ ? units
34
+ .filter((unit) => Boolean(unit))
35
+ .map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
36
+ .filter((unit) => (0, utils_1.isUnitExpressionValid)(unit))
37
+ .map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
38
+ .filter((unit) => unit !== utils_1.REMOVE)
39
+ : undefined,
40
+ },
41
+ colorCoding: {
42
+ $apply: (colorCodings) => {
43
+ return (colorCodings &&
44
+ colorCodings
45
+ .map((colorCoding) => ({
46
+ ...colorCoding,
47
+ expression: visitor.visitExpression(fromType, colorCoding.expression),
48
+ }))
49
+ .filter((colorCoding) => colorCoding.expression !== null));
50
+ },
51
+ },
52
+ })
53
+ : item;
54
+ })
55
+ .filter((item) => {
56
+ const { query } = item;
57
+ return query ? item : null;
58
+ }),
59
+ },
60
+ },
61
+ });
62
+ const replaceNamesWithIdsInFeedView = (schema, view) => {
63
+ return visitView(view, {
64
+ visitExpression: (fromType, expression) => (0, utils_1.replaceNamesWithIdsInExpression)(schema, fromType, expression),
65
+ visitFilter: (fromType, expression) => (0, utils_1.replaceNamesWithIdsInFilter)(schema, fromType, expression),
66
+ visitQueryExpression: (query) => (0, utils_1.replaceNamesWithIdsInQueryExpression)(schema, query),
67
+ });
68
+ };
69
+ exports.replaceNamesWithIdsInFeedView = replaceNamesWithIdsInFeedView;
70
+ const replaceIdsWithNamesInFeedView = (schema, view) => {
71
+ return visitView(view, {
72
+ visitExpression: (fromType, expression) => (0, utils_1.replaceIdsWithNamesInExpression)(schema, fromType, expression),
73
+ visitFilter: (fromType, expression) => (0, utils_1.replaceIdsWithNamesInFilter)(schema, fromType, expression),
74
+ visitQueryExpression: (query) => (0, utils_1.replaceIdsWithNamesInQueryExpression)(schema, query),
75
+ });
76
+ };
77
+ exports.replaceIdsWithNamesInFeedView = replaceIdsWithNamesInFeedView;
78
+ const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView(view, {
79
+ visitQueryExpression: (queryExpression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression)(schema, queryExpression),
80
+ visitFilter: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInFilter)(schema, fromType, expression),
81
+ visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
82
+ });
83
+ exports.deleteExpressionWithNotFoundFieldsOrTypesInFeedView = deleteExpressionWithNotFoundFieldsOrTypesInFeedView;
84
+ const fixUserSelectedUnitsInFeedView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
85
+ return visitView(view, {
86
+ visitExpression: (_fromType, expression) => expression,
87
+ visitFilter: (_fromType, filter) => filter,
88
+ visitQueryExpression: (query) => query,
89
+ visitViewUnit: (fromType, unit, units) => (0, units_1.fixViewUnit)(schema, fromType, unit, units, { unitDefinitions, getDefaultUnitTypeForField }),
90
+ });
91
+ };
92
+ exports.fixUserSelectedUnitsInFeedView = fixUserSelectedUnitsInFeedView;
93
+ const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, {
94
+ visitQueryExpression: (query) => query,
95
+ visitFilter: (_fromType, filter) => filter,
96
+ visitExpression: (_fromType, expression) => expression,
97
+ visitContextExpression: (fromType, expression) => (0, utils_1.resetContextExpressionIfBroken)(schema, fromType, expression, defaultContextExpression),
98
+ });
99
+ exports.fixContextExpressionWithBrokenPath = fixContextExpressionWithBrokenPath;
100
+ const collectGarbage = (view) => {
101
+ return visitView(view, {
102
+ visitExpression: (_fromType, expression) => expression,
103
+ visitFilter: (_fromType, filter) => filter,
104
+ visitQueryExpression: (query) => query,
105
+ visitViewUnit: (fromType, unit) => (unit.checked ? unit : utils_1.REMOVE),
106
+ });
107
+ };
108
+ exports.collectGarbage = collectGarbage;
109
+ const enableHideWhenEmptyForCheckedUnits = (view) => {
110
+ return visitView(view, {
111
+ visitQueryExpression: (queryExpression) => queryExpression,
112
+ visitGroupByExpression: (groupBy) => groupBy,
113
+ visitFilter: (_fromType, filter) => filter,
114
+ visitExpression: (_fromType, expression) => expression,
115
+ visitEnums: (enums) => enums,
116
+ visitViewUnit: (_fromType, unit) => (0, units_1.enableHideWhenEmptyForCheckedEditableUnit)(unit),
117
+ });
118
+ };
119
+ exports.enableHideWhenEmptyForCheckedUnits = enableHideWhenEmptyForCheckedUnits;
@@ -0,0 +1,3 @@
1
+ export function replaceNamesWithIdsInFormView(schema: any, view: any): any;
2
+ export function replaceIdsWithNamesInFormView(schema: any, view: any): any;
3
+ export function deleteExpressionWithNotFoundFieldsOrTypesInFormView(schema: any, view: any): any;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteExpressionWithNotFoundFieldsOrTypesInFormView = exports.replaceIdsWithNamesInFormView = exports.replaceNamesWithIdsInFormView = void 0;
4
+ const replaceNamesWithIdsInFormView = (schema, view) => {
5
+ const typeId = view["fibery/meta"]?.typeId;
6
+ const typeObject = Object.hasOwn(schema.typeObjectsByName, typeId) ? schema.typeObjectsByName[typeId] : null;
7
+ const fields = view["fibery/meta"]?.fields;
8
+ const fieldsInIdsTerms = fields &&
9
+ fields.map((field) => {
10
+ if (!typeObject || !Object.hasOwn(typeObject.fieldObjectsByName, field.id)) {
11
+ return field;
12
+ }
13
+ return { ...field, id: typeObject.fieldObjectsByName[field.id].id };
14
+ });
15
+ return {
16
+ ...view,
17
+ "fibery/meta": {
18
+ ...view["fibery/meta"],
19
+ typeId: typeObject ? typeObject.id : typeId,
20
+ fields: fieldsInIdsTerms || fields,
21
+ },
22
+ };
23
+ };
24
+ exports.replaceNamesWithIdsInFormView = replaceNamesWithIdsInFormView;
25
+ const replaceIdsWithNamesInFormView = (schema, view) => {
26
+ const typeId = view["fibery/meta"]?.typeId;
27
+ const typeObject = Object.hasOwn(schema.typeObjectsById, typeId) ? schema.typeObjectsById[typeId] : null;
28
+ const fields = view["fibery/meta"]?.fields;
29
+ const fieldsInNameTerms = fields &&
30
+ fields.map((field) => {
31
+ if (!typeObject || !Object.hasOwn(typeObject.fieldObjectsById, field.id)) {
32
+ return field;
33
+ }
34
+ return { ...field, id: typeObject.fieldObjectsById[field.id].name };
35
+ });
36
+ return {
37
+ ...view,
38
+ "fibery/meta": {
39
+ ...view["fibery/meta"],
40
+ typeId: typeObject ? typeObject.name : typeId,
41
+ fields: fieldsInNameTerms || fields,
42
+ },
43
+ };
44
+ };
45
+ exports.replaceIdsWithNamesInFormView = replaceIdsWithNamesInFormView;
46
+ const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
47
+ // we expect view in names terms here.
48
+ const typeName = view["fibery/meta"]?.typeId;
49
+ const typeObject = Object.hasOwn(schema.typeObjectsByName, typeName) ? schema.typeObjectsByName[typeName] : null;
50
+ const fields = view["fibery/meta"]?.fields;
51
+ const existingFields = fields && fields.filter((field) => typeObject && Object.hasOwn(typeObject.fieldObjectsByName, field.id));
52
+ return {
53
+ ...view,
54
+ "fibery/meta": {
55
+ ...view["fibery/meta"],
56
+ typeId: typeObject ? typeObject.name : typeName,
57
+ fields: existingFields || fields,
58
+ },
59
+ };
60
+ };
61
+ exports.deleteExpressionWithNotFoundFieldsOrTypesInFormView = deleteExpressionWithNotFoundFieldsOrTypesInFormView;