@fibery/views 25.1.4 → 26.0.0

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 (163) hide show
  1. package/lib/errors.d.ts +2 -3
  2. package/lib/field-utils/avatar.d.ts +8 -9
  3. package/lib/field-utils/back-references.d.ts +4 -5
  4. package/lib/field-utils/comments.d.ts +5 -6
  5. package/lib/field-utils/date-time.d.ts +7 -8
  6. package/lib/field-utils/enum-value.d.ts +6 -7
  7. package/lib/field-utils/file.d.ts +3 -4
  8. package/lib/field-utils/icon.d.ts +6 -7
  9. package/lib/field-utils/number.d.ts +11 -12
  10. package/lib/field-utils/reference-collection.d.ts +6 -7
  11. package/lib/field-utils/reference.d.ts +3 -4
  12. package/lib/field-utils/relation-view.d.ts +2 -3
  13. package/lib/field-utils/rich-text.d.ts +9 -10
  14. package/lib/field-utils/text.d.ts +9 -10
  15. package/lib/field-utils/user-active.d.ts +3 -4
  16. package/lib/field-utils/user-role.d.ts +3 -4
  17. package/lib/field-utils/workflow.d.ts +9 -10
  18. package/lib/filter.d.ts +29 -0
  19. package/lib/filter.js +0 -0
  20. package/lib/index.d.ts +57 -21
  21. package/lib/index.js +101 -94
  22. package/lib/meta-validation.d.ts +3 -4
  23. package/lib/private/board.d.ts +218 -14
  24. package/lib/private/board.js +138 -231
  25. package/lib/private/calendar.d.ts +213 -13
  26. package/lib/private/calendar.js +35 -81
  27. package/lib/private/feed.d.ts +211 -13
  28. package/lib/private/feed.js +34 -80
  29. package/lib/private/form.d.ts +52 -7
  30. package/lib/private/form.js +41 -48
  31. package/lib/private/map.d.ts +211 -13
  32. package/lib/private/map.js +34 -80
  33. package/lib/private/smart-folder.d.ts +118 -29
  34. package/lib/private/smart-folder.js +70 -148
  35. package/lib/private/timeline.d.ts +535 -31
  36. package/lib/private/timeline.js +158 -219
  37. package/lib/private/units.d.ts +3 -4
  38. package/lib/private/utils.d.ts +63 -57
  39. package/lib/private/utils.js +71 -49
  40. package/lib/refs.d.ts +19 -0
  41. package/lib/refs.js +0 -0
  42. package/lib/unit-definitions/avatar-collection.d.ts +29 -4
  43. package/lib/unit-definitions/avatar-collection.js +1 -1
  44. package/lib/unit-definitions/avatar-input.d.ts +49 -4
  45. package/lib/unit-definitions/avatar.d.ts +54 -4
  46. package/lib/unit-definitions/avatar.js +1 -1
  47. package/lib/unit-definitions/back-references-list.d.ts +31 -4
  48. package/lib/unit-definitions/back-references-list.js +1 -1
  49. package/lib/unit-definitions/bool-checkbox.d.ts +23 -4
  50. package/lib/unit-definitions/bool-checkbox.js +1 -1
  51. package/lib/unit-definitions/bool.d.ts +23 -4
  52. package/lib/unit-definitions/bool.js +1 -1
  53. package/lib/unit-definitions/collection-count.d.ts +31 -4
  54. package/lib/unit-definitions/color-input.d.ts +22 -4
  55. package/lib/unit-definitions/color-input.js +1 -1
  56. package/lib/unit-definitions/comments-list.d.ts +63 -4
  57. package/lib/unit-definitions/comments-list.js +1 -1
  58. package/lib/unit-definitions/date-range-combobox.d.ts +23 -4
  59. package/lib/unit-definitions/date-range-combobox.js +1 -1
  60. package/lib/unit-definitions/date-range.d.ts +23 -4
  61. package/lib/unit-definitions/date-range.js +1 -1
  62. package/lib/unit-definitions/date-time-combobox.d.ts +23 -4
  63. package/lib/unit-definitions/date-time-combobox.js +1 -1
  64. package/lib/unit-definitions/date.d.ts +23 -4
  65. package/lib/unit-definitions/date.js +1 -1
  66. package/lib/unit-definitions/email-input.d.ts +23 -4
  67. package/lib/unit-definitions/email.d.ts +23 -4
  68. package/lib/unit-definitions/emoji.d.ts +23 -4
  69. package/lib/unit-definitions/file-collection-count.d.ts +23 -4
  70. package/lib/unit-definitions/file-collection-count.js +1 -1
  71. package/lib/unit-definitions/file-compact-collection.d.ts +23 -4
  72. package/lib/unit-definitions/file-compact-collection.js +1 -1
  73. package/lib/unit-definitions/file-compact-reference.d.ts +27 -4
  74. package/lib/unit-definitions/file-reference.d.ts +23 -4
  75. package/lib/unit-definitions/file-reference.js +1 -1
  76. package/lib/unit-definitions/files-gallery.d.ts +23 -4
  77. package/lib/unit-definitions/files-gallery.js +1 -1
  78. package/lib/unit-definitions/files-l-list-item.d.ts +23 -4
  79. package/lib/unit-definitions/files-l-list-item.js +1 -1
  80. package/lib/unit-definitions/files-l-list.d.ts +23 -4
  81. package/lib/unit-definitions/files-l-list.js +1 -1
  82. package/lib/unit-definitions/files-list-item.d.ts +23 -4
  83. package/lib/unit-definitions/files-list-item.js +1 -1
  84. package/lib/unit-definitions/files-list.d.ts +23 -4
  85. package/lib/unit-definitions/files-list.js +1 -1
  86. package/lib/unit-definitions/geometry-preview.d.ts +23 -4
  87. package/lib/unit-definitions/icon-button.d.ts +28 -4
  88. package/lib/unit-definitions/icon-button.js +1 -1
  89. package/lib/unit-definitions/icon-input.d.ts +23 -4
  90. package/lib/unit-definitions/id.d.ts +32 -4
  91. package/lib/unit-definitions/index.js +2 -2
  92. package/lib/unit-definitions/json-input.d.ts +22 -4
  93. package/lib/unit-definitions/json-input.js +1 -1
  94. package/lib/unit-definitions/location-input.d.ts +23 -4
  95. package/lib/unit-definitions/location.d.ts +23 -4
  96. package/lib/unit-definitions/not-found.d.ts +6 -4
  97. package/lib/unit-definitions/number-input.d.ts +23 -4
  98. package/lib/unit-definitions/number-input.js +1 -1
  99. package/lib/unit-definitions/number.d.ts +27 -4
  100. package/lib/unit-definitions/phone-input.d.ts +23 -4
  101. package/lib/unit-definitions/phone.d.ts +23 -4
  102. package/lib/unit-definitions/progress-bar.d.ts +26 -4
  103. package/lib/unit-definitions/reference-collection-combobox.d.ts +19 -4
  104. package/lib/unit-definitions/reference-collection-combobox.js +1 -1
  105. package/lib/unit-definitions/reference-collection-list.d.ts +19 -4
  106. package/lib/unit-definitions/reference-collection-list.js +1 -1
  107. package/lib/unit-definitions/reference-collection-view.d.ts +19 -4
  108. package/lib/unit-definitions/reference-collection-view.js +1 -1
  109. package/lib/unit-definitions/reference-collection.d.ts +23 -4
  110. package/lib/unit-definitions/reference-collection.js +1 -1
  111. package/lib/unit-definitions/reference-combobox.d.ts +19 -4
  112. package/lib/unit-definitions/reference-combobox.js +1 -1
  113. package/lib/unit-definitions/reference-icon.d.ts +27 -4
  114. package/lib/unit-definitions/reference.d.ts +27 -4
  115. package/lib/unit-definitions/rich-text-document.d.ts +23 -4
  116. package/lib/unit-definitions/rich-text-document.js +1 -1
  117. package/lib/unit-definitions/rich-text-snippet.d.ts +25 -5
  118. package/lib/unit-definitions/single-location-preview.d.ts +23 -4
  119. package/lib/unit-definitions/text-input.d.ts +23 -4
  120. package/lib/unit-definitions/text-input.js +1 -1
  121. package/lib/unit-definitions/text.d.ts +23 -4
  122. package/lib/unit-definitions/text.js +1 -1
  123. package/lib/unit-definitions/title-input.d.ts +24 -4
  124. package/lib/unit-definitions/title.d.ts +27 -4
  125. package/lib/unit-definitions/type-badge-abbr.d.ts +15 -4
  126. package/lib/unit-definitions/type-badge.d.ts +15 -4
  127. package/lib/unit-definitions/type-icon.d.ts +15 -4
  128. package/lib/unit-definitions/url-input.d.ts +23 -4
  129. package/lib/unit-definitions/url.d.ts +23 -4
  130. package/lib/unit-definitions/user-button.d.ts +13 -4
  131. package/lib/unit-definitions/user-role-input.d.ts +26 -4
  132. package/lib/unit-definitions/user-role.d.ts +27 -4
  133. package/lib/unit-definitions/user-role.js +1 -1
  134. package/lib/unit-utils/access.d.ts +4 -5
  135. package/lib/unit-utils/can-edit-field.d.ts +4 -5
  136. package/lib/unit-utils/common.d.ts +16 -11
  137. package/lib/unit-utils/decimal.js +4 -4
  138. package/lib/unit-utils/dynamic-keys.d.ts +8 -9
  139. package/lib/unit-utils/enums.d.ts +4 -5
  140. package/lib/unit-utils/formatters.d.ts +15 -16
  141. package/lib/unit-utils/get-export-value.d.ts +18 -19
  142. package/lib/unit-utils/get-field-label.d.ts +4 -5
  143. package/lib/unit-utils/get-unmatched-unit-label.d.ts +2 -3
  144. package/lib/unit-utils/wrap-normalized-in-expression.d.ts +2 -3
  145. package/lib/units/board.d.ts +22 -25
  146. package/lib/units/board.js +2 -1
  147. package/lib/units/canvas/all-units-data-definitions.js +1 -1
  148. package/lib/units/canvas/index.d.ts +19 -24
  149. package/lib/units/canvas/type-badge-abbr.d.ts +13 -35
  150. package/lib/units/canvas/type-badge.d.ts +13 -35
  151. package/lib/units/default.d.ts +21 -22
  152. package/lib/units/default.js +2 -1
  153. package/lib/units/gallery.d.ts +5 -3
  154. package/lib/units/gantt.d.ts +23 -24
  155. package/lib/units/gantt.js +3 -2
  156. package/lib/units/get-unit-definitions-for-view-type.d.ts +4 -4
  157. package/lib/units/grid.d.ts +14 -25
  158. package/lib/units/grid.js +5 -4
  159. package/lib/units/list.d.ts +17 -26
  160. package/lib/units/list.js +2 -1
  161. package/lib/units/make-factory.d.ts +25 -27
  162. package/lib/units/types.d.ts +19 -13
  163. package/package.json +10 -10
@@ -1,17 +1,215 @@
1
- import { UnitDefinitions, ViewRecord } from "./utils.js";
2
- import { FieldObject, Schema } from "@fibery/schema";
3
- import { Expression } from "@fibery/expression-utils/src/types";
1
+ import { FilterGroup } from "../filter.js";
2
+ import { ColorCoding, UnitDefinitions, ViewVisitor } from "./utils.js";
3
+ import { FieldObject, Schema, TypeId, TypeName } from "@fibery/schema";
4
+ import { FieldExpression, Query } from "@fibery/expression-utils/src/types";
4
5
  import { Unit } from "@fibery/views/src/units/types";
5
6
  //#region src/private/map.d.ts
6
- declare const replaceNamesWithIdsInMapView: <V extends ViewRecord>(schema: Schema, view: V) => V;
7
- declare const replaceIdsWithNamesInMapView: <V extends ViewRecord>(schema: Schema, view: V) => V;
8
- declare const deleteExpressionWithNotFoundFieldsOrTypesInMapView: <V extends ViewRecord>(schema: Schema, view: V) => V;
9
- declare const fixUserSelectedUnitsInMapView: <V extends ViewRecord>(schema: Schema, view: V, { unitDefinitions, getDefaultUnitTypeForField }: {
7
+ export type MapItemShape<From extends string> = {
8
+ query?: Query<From> | null;
9
+ filter?: FilterGroup | null;
10
+ locationExpression?: FieldExpression | null;
11
+ contextExpression?: FieldExpression | null;
12
+ units?: Unit[] | null;
13
+ colorCoding?: ColorCoding[] | null;
14
+ };
15
+ type VisitedKeys = "query" | "filter" | "locationExpression" | "contextExpression" | "units" | "colorCoding";
16
+ export type VisitedMapItem<I extends MapItemShape<string>, To extends string> = Omit<I, VisitedKeys> & {
17
+ query: Query<To>;
18
+ filter: FilterGroup | null;
19
+ locationExpression: I["locationExpression"] | null;
20
+ contextExpression: I["contextExpression"] | null;
21
+ units: Unit[] | undefined;
22
+ colorCoding: I["colorCoding"];
23
+ };
24
+ export declare const visitView: <From extends string, To extends string, I extends MapItemShape<From>, M extends {
25
+ items: I[];
26
+ }, V extends {
27
+ "fibery/meta": M;
28
+ }>(view: V & {
29
+ "fibery/meta": M & {
30
+ items: I[];
31
+ };
32
+ }, visitor: ViewVisitor<From, To>) => Omit<V & {
33
+ "fibery/meta": M & {
34
+ items: I[];
35
+ };
36
+ }, "fibery/meta"> & {
37
+ "fibery/meta": Omit<M & {
38
+ items: I[];
39
+ }, "items"> & {
40
+ items: VisitedMapItem<I, To>[];
41
+ };
42
+ };
43
+ type MapViewShape<From extends string, I extends MapItemShape<From>, M extends {
44
+ items: I[];
45
+ }, V> = V & {
46
+ "fibery/meta": M & {
47
+ items: I[];
48
+ };
49
+ };
50
+ export declare const replaceNamesWithIdsInMapView: <I extends MapItemShape<TypeName | TypeId>, M extends {
51
+ items: I[];
52
+ }, V extends {
53
+ "fibery/meta": M;
54
+ }>(schema: Schema, view: MapViewShape<TypeName | TypeId, I, M, V>) => Omit<V & {
55
+ "fibery/meta": M & {
56
+ items: I[];
57
+ };
58
+ } & {
59
+ "fibery/meta": M & {
60
+ items: I[];
61
+ } & {
62
+ items: I[];
63
+ };
64
+ }, "fibery/meta"> & {
65
+ "fibery/meta": Omit<M & {
66
+ items: I[];
67
+ } & {
68
+ items: I[];
69
+ }, "items"> & {
70
+ items: VisitedMapItem<I, TypeId | TypeName>[];
71
+ };
72
+ };
73
+ export declare const replaceIdsWithNamesInMapView: <I extends MapItemShape<TypeName | TypeId>, M extends {
74
+ items: I[];
75
+ }, V extends {
76
+ "fibery/meta": M;
77
+ }>(schema: Schema, view: MapViewShape<TypeName | TypeId, I, M, V>) => Omit<V & {
78
+ "fibery/meta": M & {
79
+ items: I[];
80
+ };
81
+ } & {
82
+ "fibery/meta": M & {
83
+ items: I[];
84
+ } & {
85
+ items: I[];
86
+ };
87
+ }, "fibery/meta"> & {
88
+ "fibery/meta": Omit<M & {
89
+ items: I[];
90
+ } & {
91
+ items: I[];
92
+ }, "items"> & {
93
+ items: VisitedMapItem<I, TypeId | TypeName>[];
94
+ };
95
+ };
96
+ export declare const deleteExpressionWithNotFoundFieldsOrTypesInMapView: <I extends MapItemShape<string>, M extends {
97
+ items: I[];
98
+ }, V extends {
99
+ "fibery/meta": M;
100
+ }>(schema: Schema, view: MapViewShape<string, I, M, V>) => Omit<V & {
101
+ "fibery/meta": M & {
102
+ items: I[];
103
+ };
104
+ } & {
105
+ "fibery/meta": M & {
106
+ items: I[];
107
+ } & {
108
+ items: I[];
109
+ };
110
+ }, "fibery/meta"> & {
111
+ "fibery/meta": Omit<M & {
112
+ items: I[];
113
+ } & {
114
+ items: I[];
115
+ }, "items"> & {
116
+ items: VisitedMapItem<I, TypeName>[];
117
+ };
118
+ };
119
+ export declare const fixUserSelectedUnitsInMapView: <From extends string, I extends MapItemShape<From>, M extends {
120
+ items: I[];
121
+ }, V extends {
122
+ "fibery/meta": M;
123
+ }>(schema: Schema, view: MapViewShape<From, I, M, V>, { unitDefinitions, getDefaultUnitTypeForField }: {
10
124
  unitDefinitions: UnitDefinitions;
11
125
  getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
12
- }) => V;
13
- declare const fixContextExpressionWithBrokenPath: <V extends ViewRecord>(schema: Schema, view: V, defaultContextExpression: Expression) => V;
14
- declare const collectGarbage: <V extends ViewRecord>(view: V) => V;
15
- declare const enableHideWhenEmptyForCheckedUnits: <V extends ViewRecord>(view: V) => V;
16
- //#endregion
17
- export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInMapView, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInMapView, replaceIdsWithNamesInMapView, replaceNamesWithIdsInMapView };
126
+ }) => Omit<V & {
127
+ "fibery/meta": M & {
128
+ items: I[];
129
+ };
130
+ } & {
131
+ "fibery/meta": M & {
132
+ items: I[];
133
+ } & {
134
+ items: I[];
135
+ };
136
+ }, "fibery/meta"> & {
137
+ "fibery/meta": Omit<M & {
138
+ items: I[];
139
+ } & {
140
+ items: I[];
141
+ }, "items"> & {
142
+ items: VisitedMapItem<I, From>[];
143
+ };
144
+ };
145
+ export declare const fixContextExpressionWithBrokenPath: <From extends string, I extends MapItemShape<From>, M extends {
146
+ items: I[];
147
+ }, V extends {
148
+ "fibery/meta": M;
149
+ }>(schema: Schema, view: MapViewShape<From, I, M, V>, defaultContextExpression: FieldExpression) => Omit<V & {
150
+ "fibery/meta": M & {
151
+ items: I[];
152
+ };
153
+ } & {
154
+ "fibery/meta": M & {
155
+ items: I[];
156
+ } & {
157
+ items: I[];
158
+ };
159
+ }, "fibery/meta"> & {
160
+ "fibery/meta": Omit<M & {
161
+ items: I[];
162
+ } & {
163
+ items: I[];
164
+ }, "items"> & {
165
+ items: VisitedMapItem<I, From>[];
166
+ };
167
+ };
168
+ export declare const enableHideWhenEmptyForCheckedUnits: <From extends string, I extends MapItemShape<From>, M extends {
169
+ items: I[];
170
+ }, V extends {
171
+ "fibery/meta": M;
172
+ }>(view: MapViewShape<From, I, M, V>) => Omit<V & {
173
+ "fibery/meta": M & {
174
+ items: I[];
175
+ };
176
+ } & {
177
+ "fibery/meta": M & {
178
+ items: I[];
179
+ } & {
180
+ items: I[];
181
+ };
182
+ }, "fibery/meta"> & {
183
+ "fibery/meta": Omit<M & {
184
+ items: I[];
185
+ } & {
186
+ items: I[];
187
+ }, "items"> & {
188
+ items: VisitedMapItem<I, From>[];
189
+ };
190
+ };
191
+ /** @deprecated Drop unchecked units with `visitView(view, identityViewVisitor({visitViewUnit}))`. */
192
+ export declare const collectGarbage: <From extends string, I extends MapItemShape<From>, M extends {
193
+ items: I[];
194
+ }, V extends {
195
+ "fibery/meta": M;
196
+ }>(view: MapViewShape<From, I, M, V>) => Omit<V & {
197
+ "fibery/meta": M & {
198
+ items: I[];
199
+ };
200
+ } & {
201
+ "fibery/meta": M & {
202
+ items: I[];
203
+ } & {
204
+ items: I[];
205
+ };
206
+ }, "fibery/meta"> & {
207
+ "fibery/meta": Omit<M & {
208
+ items: I[];
209
+ } & {
210
+ items: I[];
211
+ }, "items"> & {
212
+ items: VisitedMapItem<I, From>[];
213
+ };
214
+ };
215
+ //#endregion
@@ -1,90 +1,44 @@
1
- import { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteExpressionWithNotFoundFieldsOrTypesInFilter, deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression, isUnitExpressionValid, replaceIdsWithNamesInExpression, replaceIdsWithNamesInFilter, replaceIdsWithNamesInQueryExpression, replaceNamesWithIdsInExpression, replaceNamesWithIdsInFilter, replaceNamesWithIdsInQueryExpression, resetContextExpressionIfBroken, visitContextExpression, visitViewUnit } from "./utils.js";
1
+ import { REMOVE, deleteNotFoundViewVisitor, identityViewVisitor, replaceIdsWithNamesViewVisitor, replaceNamesWithIdsViewVisitor, resetContextExpressionIfBroken, reuseIfUnchanged, visitColorCoding, visitContextExpression, visitUnits } from "./utils.js";
2
2
  import { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit } from "./units.js";
3
3
  import { truthy } from "@fibery/helpers/src/_";
4
- import get from "lodash/get.js";
5
4
  //#region src/private/map.ts
5
+ function visitItem(item, visitor) {
6
+ const { query, filter, locationExpression, contextExpression, units, colorCoding, ...rest } = item;
7
+ const fromType = query?.["q/from"];
8
+ if (!fromType) return query ? item : null;
9
+ const visitedQuery = visitor.visitQueryExpression(query);
10
+ if (!visitedQuery) return null;
11
+ return reuseIfUnchanged(item, {
12
+ ...rest,
13
+ locationExpression: locationExpression ? visitor.visitExpression(fromType, locationExpression) : locationExpression,
14
+ contextExpression: visitContextExpression(fromType, contextExpression, visitor),
15
+ query: visitedQuery,
16
+ filter: filter ? visitor.visitFilter(fromType, filter) : null,
17
+ units: units ? visitUnits(fromType, units.filter(truthy), visitor) : void 0,
18
+ colorCoding: colorCoding ? visitColorCoding(fromType, colorCoding, visitor) : colorCoding
19
+ });
20
+ }
6
21
  const visitView = (view, visitor) => {
7
- const meta = view["fibery/meta"];
22
+ const { "fibery/meta": meta, ...rest } = view;
23
+ const { items, ...metaRest } = meta;
8
24
  return {
9
- ...view,
25
+ ...rest,
10
26
  "fibery/meta": {
11
- ...meta,
12
- items: meta.items.map((item) => {
13
- const fromType = get(item, ["query", "q/from"]);
14
- if (!fromType) return item;
15
- const nextItem = {
16
- ...item,
17
- locationExpression: item.locationExpression ? visitor.visitExpression(fromType, item.locationExpression) : item.locationExpression,
18
- contextExpression: visitContextExpression(fromType, item.contextExpression, visitor),
19
- query: item.query ? visitor.visitQueryExpression(item.query) : null,
20
- filter: item.filter ? visitor.visitFilter(fromType, item.filter) : null,
21
- units: item.units ? item.units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE) : void 0,
22
- colorCoding: item.colorCoding && item.colorCoding.map((colorCoding) => ({
23
- ...colorCoding,
24
- expression: visitor.visitExpression(fromType, colorCoding.expression)
25
- })).filter((colorCoding) => colorCoding.expression !== null)
26
- };
27
- return Object.entries(nextItem).every(([key, value]) => Object.hasOwn(item, key) && item[key] === value) ? item : nextItem;
28
- }).filter((item) => {
29
- const { query } = item;
30
- return query ? item : null;
31
- })
27
+ ...metaRest,
28
+ items: items.map((item) => visitItem(item, visitor)).filter(truthy)
32
29
  }
33
30
  };
34
31
  };
35
- const replaceNamesWithIdsInMapView = (schema, view) => {
36
- return visitView(view, {
37
- visitQueryExpression: (query) => replaceNamesWithIdsInQueryExpression(schema, query),
38
- visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
39
- visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
40
- });
41
- };
42
- const replaceIdsWithNamesInMapView = (schema, view) => {
43
- return visitView(view, {
44
- visitQueryExpression: (query) => replaceIdsWithNamesInQueryExpression(schema, query),
45
- visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
46
- visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
47
- });
48
- };
49
- const deleteExpressionWithNotFoundFieldsOrTypesInMapView = (schema, view) => visitView(view, {
50
- visitQueryExpression: (queryExpression) => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
51
- visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
52
- visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
53
- });
54
- const fixUserSelectedUnitsInMapView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
55
- return visitView(view, {
56
- visitQueryExpression: (query) => query,
57
- visitFilter: (_fromType, filter) => filter,
58
- visitExpression: (_fromType, expression) => expression,
59
- visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
60
- unitDefinitions,
61
- getDefaultUnitTypeForField
62
- })
63
- });
64
- };
65
- const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, {
66
- visitExpression: (_fromType, expression) => expression,
67
- visitQueryExpression: (query) => query,
68
- visitFilter: (_fromType, filter) => filter,
69
- visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
70
- });
71
- const collectGarbage = (view) => {
72
- return visitView(view, {
73
- visitQueryExpression: (query) => query,
74
- visitFilter: (_fromType, filter) => filter,
75
- visitExpression: (_fromType, expression) => expression,
76
- visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE
77
- });
78
- };
79
- const enableHideWhenEmptyForCheckedUnits = (view) => {
80
- return visitView(view, {
81
- visitQueryExpression: (queryExpression) => queryExpression,
82
- visitGroupByExpression: (groupBy) => groupBy,
83
- visitFilter: (_fromType, filter) => filter,
84
- visitExpression: (_fromType, expression) => expression,
85
- visitEnums: (enums) => enums,
86
- visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
87
- });
88
- };
32
+ const replaceNamesWithIdsInMapView = (schema, view) => visitView(view, replaceNamesWithIdsViewVisitor(schema));
33
+ const replaceIdsWithNamesInMapView = (schema, view) => visitView(view, replaceIdsWithNamesViewVisitor(schema));
34
+ const deleteExpressionWithNotFoundFieldsOrTypesInMapView = (schema, view) => visitView(view, deleteNotFoundViewVisitor(schema));
35
+ const fixUserSelectedUnitsInMapView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => visitView(view, identityViewVisitor({ visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
36
+ unitDefinitions,
37
+ getDefaultUnitTypeForField
38
+ }) }));
39
+ const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, identityViewVisitor({ visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression) }));
40
+ const enableHideWhenEmptyForCheckedUnits = (view) => visitView(view, identityViewVisitor({ visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit) }));
41
+ /** @deprecated Drop unchecked units with `visitView(view, identityViewVisitor({visitViewUnit}))`. */
42
+ const collectGarbage = (view) => visitView(view, identityViewVisitor({ visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE }));
89
43
  //#endregion
90
- export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInMapView, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInMapView, replaceIdsWithNamesInMapView, replaceNamesWithIdsInMapView };
44
+ export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInMapView, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInMapView, replaceIdsWithNamesInMapView, replaceNamesWithIdsInMapView, visitView };
@@ -1,33 +1,122 @@
1
- import { UnitDefinitions, ViewRecord } from "./utils.js";
2
- import { FieldObject, Schema } from "@fibery/schema";
3
- import { Expression } from "@fibery/expression-utils/src/types";
1
+ import { FilterGroup } from "../filter.js";
2
+ import { ColorCoding, GroupByExpression, UnitDefinitions, ViewVisitor } from "./utils.js";
3
+ import { FieldObject, Schema, TypeId, TypeName } from "@fibery/schema";
4
+ import { Expression, FieldExpression, Query } from "@fibery/expression-utils/src/types";
4
5
  import { Unit } from "@fibery/views/src/units/types";
5
6
  //#region src/private/smart-folder.d.ts
6
- type GroupByEntry = {
7
- expression: Expression;
8
- [k: string]: unknown;
9
- };
10
- type GroupByExpression = Record<string, GroupByEntry>;
11
- declare const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression: (schema: Schema, groupByExpression: GroupByExpression | null, fromType: string, removedItems: number[]) => any;
12
- declare const replaceIdsWithNamesInGroupByExpression: (schema: Schema, groupByExpression: GroupByExpression | null, fromType: string) => {
13
- [k: string]: {
14
- expression: any;
15
- };
16
- } | null;
17
- declare const replaceNamesWithIdsInGroupByExpression: (schema: Schema, groupByExpression: GroupByExpression | null, fromType: string) => {
18
- [k: string]: {
19
- expression: any;
20
- };
21
- } | null;
22
- declare const replaceNamesWithIdsInSmartFolder: <V extends ViewRecord>(schema: Schema, smartFolder: V) => V;
23
- declare const replaceIdsWithNamesInSmartFolder: <V extends ViewRecord>(schema: Schema, smartFolder: V) => V;
24
- declare const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder: <V extends ViewRecord>(schema: Schema, smartFolder: V) => V;
25
- declare const fixContextExpressionWithBrokenPath: <V extends ViewRecord>(schema: Schema, view: V, defaultContextExpression: Expression) => V;
26
- declare const fixUserSelectedUnitsInSmartFolder: <V extends ViewRecord>(schema: Schema, view: V, { unitDefinitions, getDefaultUnitTypeForField }: {
7
+ export type SmartFolderItemShape<From extends string> = {
8
+ query?: Query<From> | null;
9
+ filter?: FilterGroup | null;
10
+ contextExpression?: FieldExpression | null;
11
+ units?: Unit[] | null;
12
+ groupBy?: GroupByExpression<FieldExpression> | null;
13
+ groupingExpression?: GroupByExpression<FieldExpression> | [string] | null;
14
+ colorCoding?: ColorCoding[] | null;
15
+ };
16
+ type VisitedItemKeys = keyof SmartFolderItemShape<string>;
17
+ export type VisitedSmartFolderItem<I extends SmartFolderItemShape<string>, To extends string> = Omit<I, VisitedItemKeys> & {
18
+ query: Query<To>;
19
+ filter: FilterGroup | null;
20
+ contextExpression: I["contextExpression"] | null;
21
+ units: Unit[] | undefined;
22
+ groupBy?: I["groupBy"] | null;
23
+ groupingExpression?: I["groupingExpression"] | null;
24
+ colorCoding: ColorCoding[] | undefined;
25
+ };
26
+ export type SmartFolderMetaShape<I, C> = {
27
+ items?: I[];
28
+ columnOrderWithIds?: string[];
29
+ pinnedColumnsWithIds?: string[];
30
+ columnAggFunc?: Record<string, C>;
31
+ };
32
+ type SmartFolderShape<I, C, M, V> = V & {
33
+ "fibery/meta": M & SmartFolderMetaShape<I, C>;
34
+ };
35
+ export declare const visitSmartFolder: <From extends string, To extends string, I extends SmartFolderItemShape<From>, C, M extends SmartFolderMetaShape<I, C>, V extends {
36
+ "fibery/meta": M;
37
+ }>(smartFolder: SmartFolderShape<I, C, M, V>, visitor: ViewVisitor<From, To>) => Omit<SmartFolderShape<I, C, M, V>, "fibery/meta"> & {
38
+ "fibery/meta": Omit<M & SmartFolderMetaShape<I, C>, "columnAggFunc" | "columnOrderWithIds" | "items" | "pinnedColumnsWithIds"> & {
39
+ items: VisitedSmartFolderItem<I, To>[];
40
+ columnOrderWithIds: string[] | undefined;
41
+ pinnedColumnsWithIds: string[] | undefined;
42
+ columnAggFunc: Record<string, C> | undefined;
43
+ };
44
+ };
45
+ export declare const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression: <E extends Expression>(schema: Schema, groupByExpression: GroupByExpression<E> | null, fromType: string, removedItems: number[]) => GroupByExpression<E> | null;
46
+ export declare const replaceIdsWithNamesInGroupByExpression: <E extends Expression>(schema: Schema, groupByExpression: GroupByExpression<E> | null, fromType: string) => GroupByExpression<E> | null;
47
+ export declare const replaceNamesWithIdsInGroupByExpression: <E extends Expression>(schema: Schema, groupByExpression: GroupByExpression<E> | null, fromType: string) => GroupByExpression<E> | null;
48
+ export declare const replaceNamesWithIdsInSmartFolder: <I extends SmartFolderItemShape<TypeName | TypeId>, C, M extends SmartFolderMetaShape<I, C>, V extends {
49
+ "fibery/meta": M;
50
+ }>(schema: Schema, smartFolder: SmartFolderShape<I, C, M, V>) => Omit<SmartFolderShape<I, C, M, V>, "fibery/meta"> & {
51
+ "fibery/meta": Omit<M & SmartFolderMetaShape<I, C>, "columnAggFunc" | "columnOrderWithIds" | "items" | "pinnedColumnsWithIds"> & {
52
+ items: VisitedSmartFolderItem<I, TypeId | TypeName>[];
53
+ columnOrderWithIds: string[] | undefined;
54
+ pinnedColumnsWithIds: string[] | undefined;
55
+ columnAggFunc: Record<string, C> | undefined;
56
+ };
57
+ };
58
+ export declare const replaceIdsWithNamesInSmartFolder: <I extends SmartFolderItemShape<TypeName | TypeId>, C, M extends SmartFolderMetaShape<I, C>, V extends {
59
+ "fibery/meta": M;
60
+ }>(schema: Schema, smartFolder: SmartFolderShape<I, C, M, V>) => Omit<SmartFolderShape<I, C, M, V>, "fibery/meta"> & {
61
+ "fibery/meta": Omit<M & SmartFolderMetaShape<I, C>, "columnAggFunc" | "columnOrderWithIds" | "items" | "pinnedColumnsWithIds"> & {
62
+ items: VisitedSmartFolderItem<I, TypeId | TypeName>[];
63
+ columnOrderWithIds: string[] | undefined;
64
+ pinnedColumnsWithIds: string[] | undefined;
65
+ columnAggFunc: Record<string, C> | undefined;
66
+ };
67
+ };
68
+ export declare const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder: <I extends SmartFolderItemShape<string>, C, M extends SmartFolderMetaShape<I, C>, V extends {
69
+ "fibery/meta": M;
70
+ }>(schema: Schema, smartFolder: SmartFolderShape<I, C, M, V>) => Omit<SmartFolderShape<I, C, M, V>, "fibery/meta"> & {
71
+ "fibery/meta": Omit<M & SmartFolderMetaShape<I, C>, "columnAggFunc" | "columnOrderWithIds" | "items" | "pinnedColumnsWithIds"> & {
72
+ items: VisitedSmartFolderItem<I, TypeName>[];
73
+ columnOrderWithIds: string[] | undefined;
74
+ pinnedColumnsWithIds: string[] | undefined;
75
+ columnAggFunc: Record<string, C> | undefined;
76
+ };
77
+ };
78
+ export declare const fixContextExpressionWithBrokenPath: <From extends string, I extends SmartFolderItemShape<From>, C, M extends SmartFolderMetaShape<I, C>, V extends {
79
+ "fibery/meta": M;
80
+ }>(schema: Schema, view: SmartFolderShape<I, C, M, V>, defaultContextExpression: FieldExpression) => Omit<SmartFolderShape<I, C, M, V>, "fibery/meta"> & {
81
+ "fibery/meta": Omit<M & SmartFolderMetaShape<I, C>, "columnAggFunc" | "columnOrderWithIds" | "items" | "pinnedColumnsWithIds"> & {
82
+ items: VisitedSmartFolderItem<I, From>[];
83
+ columnOrderWithIds: string[] | undefined;
84
+ pinnedColumnsWithIds: string[] | undefined;
85
+ columnAggFunc: Record<string, C> | undefined;
86
+ };
87
+ };
88
+ export declare const fixUserSelectedUnitsInSmartFolder: <From extends string, I extends SmartFolderItemShape<From>, C, M extends SmartFolderMetaShape<I, C>, V extends {
89
+ "fibery/type": string;
90
+ "fibery/meta": M;
91
+ }>(schema: Schema, view: SmartFolderShape<I, C, M, V>, { unitDefinitions, getDefaultUnitTypeForField }: {
27
92
  unitDefinitions: UnitDefinitions;
28
93
  getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
29
- }) => V;
30
- declare const collectGarbage: <V extends ViewRecord>(view: V) => V;
31
- declare const enableHideWhenEmptyForCheckedUnits: <V extends ViewRecord>(view: V) => V;
32
- //#endregion
33
- export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression, deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInSmartFolder, replaceIdsWithNamesInGroupByExpression, replaceIdsWithNamesInSmartFolder, replaceNamesWithIdsInGroupByExpression, replaceNamesWithIdsInSmartFolder };
94
+ }) => Omit<SmartFolderShape<I, C, M, V>, "fibery/meta"> & {
95
+ "fibery/meta": Omit<M & SmartFolderMetaShape<I, C>, "columnAggFunc" | "columnOrderWithIds" | "items" | "pinnedColumnsWithIds"> & {
96
+ items: VisitedSmartFolderItem<I, From>[];
97
+ columnOrderWithIds: string[] | undefined;
98
+ pinnedColumnsWithIds: string[] | undefined;
99
+ columnAggFunc: Record<string, C> | undefined;
100
+ };
101
+ };
102
+ export declare const enableHideWhenEmptyForCheckedUnits: <From extends string, I extends SmartFolderItemShape<From>, C, M extends SmartFolderMetaShape<I, C>, V extends {
103
+ "fibery/meta": M;
104
+ }>(view: SmartFolderShape<I, C, M, V>) => Omit<SmartFolderShape<I, C, M, V>, "fibery/meta"> & {
105
+ "fibery/meta": Omit<M & SmartFolderMetaShape<I, C>, "columnAggFunc" | "columnOrderWithIds" | "items" | "pinnedColumnsWithIds"> & {
106
+ items: VisitedSmartFolderItem<I, From>[];
107
+ columnOrderWithIds: string[] | undefined;
108
+ pinnedColumnsWithIds: string[] | undefined;
109
+ columnAggFunc: Record<string, C> | undefined;
110
+ };
111
+ };
112
+ export declare const collectGarbage: <From extends string, I extends SmartFolderItemShape<From>, C, M extends SmartFolderMetaShape<I, C>, V extends {
113
+ "fibery/meta": M;
114
+ }>(view: SmartFolderShape<I, C, M, V>) => Omit<SmartFolderShape<I, C, M, V>, "fibery/meta"> & {
115
+ "fibery/meta": Omit<M & SmartFolderMetaShape<I, C>, "columnAggFunc" | "columnOrderWithIds" | "items" | "pinnedColumnsWithIds"> & {
116
+ items: VisitedSmartFolderItem<I, From>[];
117
+ columnOrderWithIds: string[] | undefined;
118
+ pinnedColumnsWithIds: string[] | undefined;
119
+ columnAggFunc: Record<string, C> | undefined;
120
+ };
121
+ };
122
+ //#endregion