@fibery/views 25.1.5 → 26.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 (168) 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-collection.js +1 -1
  12. package/lib/field-utils/reference.d.ts +3 -4
  13. package/lib/field-utils/reference.js +1 -1
  14. package/lib/field-utils/relation-view.d.ts +2 -3
  15. package/lib/field-utils/rich-text.d.ts +9 -10
  16. package/lib/field-utils/text.d.ts +9 -10
  17. package/lib/field-utils/user-active.d.ts +3 -4
  18. package/lib/field-utils/user-role.d.ts +3 -4
  19. package/lib/field-utils/workflow.d.ts +9 -10
  20. package/lib/filter.d.ts +29 -0
  21. package/lib/filter.js +0 -0
  22. package/lib/index.d.ts +57 -21
  23. package/lib/index.js +101 -94
  24. package/lib/meta-validation.d.ts +3 -4
  25. package/lib/private/board.d.ts +218 -14
  26. package/lib/private/board.js +139 -231
  27. package/lib/private/calendar.d.ts +213 -13
  28. package/lib/private/calendar.js +35 -81
  29. package/lib/private/feed.d.ts +211 -13
  30. package/lib/private/feed.js +34 -80
  31. package/lib/private/form.d.ts +52 -7
  32. package/lib/private/form.js +41 -48
  33. package/lib/private/map.d.ts +211 -13
  34. package/lib/private/map.js +34 -80
  35. package/lib/private/smart-folder.d.ts +118 -29
  36. package/lib/private/smart-folder.js +70 -148
  37. package/lib/private/timeline.d.ts +535 -31
  38. package/lib/private/timeline.js +158 -219
  39. package/lib/private/units.d.ts +3 -4
  40. package/lib/private/utils.d.ts +63 -57
  41. package/lib/private/utils.js +71 -49
  42. package/lib/refs.d.ts +19 -0
  43. package/lib/refs.js +0 -0
  44. package/lib/unit-definitions/avatar-collection.d.ts +29 -4
  45. package/lib/unit-definitions/avatar-collection.js +1 -1
  46. package/lib/unit-definitions/avatar-input.d.ts +49 -4
  47. package/lib/unit-definitions/avatar.d.ts +54 -4
  48. package/lib/unit-definitions/avatar.js +1 -1
  49. package/lib/unit-definitions/back-references-list.d.ts +31 -4
  50. package/lib/unit-definitions/back-references-list.js +2 -2
  51. package/lib/unit-definitions/bool-checkbox.d.ts +23 -4
  52. package/lib/unit-definitions/bool-checkbox.js +1 -1
  53. package/lib/unit-definitions/bool.d.ts +23 -4
  54. package/lib/unit-definitions/bool.js +1 -1
  55. package/lib/unit-definitions/collection-count.d.ts +31 -4
  56. package/lib/unit-definitions/collection-count.js +1 -1
  57. package/lib/unit-definitions/color-input.d.ts +22 -4
  58. package/lib/unit-definitions/color-input.js +1 -1
  59. package/lib/unit-definitions/comments-list.d.ts +63 -4
  60. package/lib/unit-definitions/comments-list.js +2 -2
  61. package/lib/unit-definitions/date-range-combobox.d.ts +23 -4
  62. package/lib/unit-definitions/date-range-combobox.js +1 -1
  63. package/lib/unit-definitions/date-range.d.ts +23 -4
  64. package/lib/unit-definitions/date-range.js +1 -1
  65. package/lib/unit-definitions/date-time-combobox.d.ts +23 -4
  66. package/lib/unit-definitions/date-time-combobox.js +1 -1
  67. package/lib/unit-definitions/date.d.ts +23 -4
  68. package/lib/unit-definitions/date.js +1 -1
  69. package/lib/unit-definitions/email-input.d.ts +23 -4
  70. package/lib/unit-definitions/email.d.ts +23 -4
  71. package/lib/unit-definitions/emoji.d.ts +23 -4
  72. package/lib/unit-definitions/file-collection-count.d.ts +23 -4
  73. package/lib/unit-definitions/file-collection-count.js +2 -2
  74. package/lib/unit-definitions/file-compact-collection.d.ts +23 -4
  75. package/lib/unit-definitions/file-compact-collection.js +2 -2
  76. package/lib/unit-definitions/file-compact-reference.d.ts +27 -4
  77. package/lib/unit-definitions/file-compact-reference.js +1 -1
  78. package/lib/unit-definitions/file-reference.d.ts +23 -4
  79. package/lib/unit-definitions/file-reference.js +2 -2
  80. package/lib/unit-definitions/files-gallery.d.ts +23 -4
  81. package/lib/unit-definitions/files-gallery.js +2 -2
  82. package/lib/unit-definitions/files-l-list-item.d.ts +23 -4
  83. package/lib/unit-definitions/files-l-list-item.js +2 -2
  84. package/lib/unit-definitions/files-l-list.d.ts +23 -4
  85. package/lib/unit-definitions/files-l-list.js +2 -2
  86. package/lib/unit-definitions/files-list-item.d.ts +23 -4
  87. package/lib/unit-definitions/files-list-item.js +2 -2
  88. package/lib/unit-definitions/files-list.d.ts +23 -4
  89. package/lib/unit-definitions/files-list.js +2 -2
  90. package/lib/unit-definitions/geometry-preview.d.ts +23 -4
  91. package/lib/unit-definitions/icon-button.d.ts +28 -4
  92. package/lib/unit-definitions/icon-button.js +1 -1
  93. package/lib/unit-definitions/icon-input.d.ts +23 -4
  94. package/lib/unit-definitions/id.d.ts +32 -4
  95. package/lib/unit-definitions/json-input.d.ts +22 -4
  96. package/lib/unit-definitions/json-input.js +1 -1
  97. package/lib/unit-definitions/location-input.d.ts +23 -4
  98. package/lib/unit-definitions/location.d.ts +23 -4
  99. package/lib/unit-definitions/not-found.d.ts +6 -4
  100. package/lib/unit-definitions/number-input.d.ts +23 -4
  101. package/lib/unit-definitions/number-input.js +1 -1
  102. package/lib/unit-definitions/number.d.ts +27 -4
  103. package/lib/unit-definitions/phone-input.d.ts +23 -4
  104. package/lib/unit-definitions/phone.d.ts +23 -4
  105. package/lib/unit-definitions/progress-bar.d.ts +26 -4
  106. package/lib/unit-definitions/reference-collection-combobox.d.ts +19 -4
  107. package/lib/unit-definitions/reference-collection-combobox.js +1 -1
  108. package/lib/unit-definitions/reference-collection-list.d.ts +19 -4
  109. package/lib/unit-definitions/reference-collection-list.js +1 -1
  110. package/lib/unit-definitions/reference-collection-view.d.ts +19 -4
  111. package/lib/unit-definitions/reference-collection-view.js +1 -1
  112. package/lib/unit-definitions/reference-collection.d.ts +23 -4
  113. package/lib/unit-definitions/reference-collection.js +2 -2
  114. package/lib/unit-definitions/reference-combobox.d.ts +19 -4
  115. package/lib/unit-definitions/reference-combobox.js +1 -1
  116. package/lib/unit-definitions/reference-icon.d.ts +27 -4
  117. package/lib/unit-definitions/reference.d.ts +27 -4
  118. package/lib/unit-definitions/reference.js +1 -1
  119. package/lib/unit-definitions/rich-text-document.d.ts +23 -4
  120. package/lib/unit-definitions/rich-text-document.js +2 -2
  121. package/lib/unit-definitions/rich-text-snippet.d.ts +25 -5
  122. package/lib/unit-definitions/single-location-preview.d.ts +23 -4
  123. package/lib/unit-definitions/text-input.d.ts +23 -4
  124. package/lib/unit-definitions/text-input.js +1 -1
  125. package/lib/unit-definitions/text.d.ts +23 -4
  126. package/lib/unit-definitions/text.js +1 -1
  127. package/lib/unit-definitions/title-input.d.ts +24 -4
  128. package/lib/unit-definitions/title.d.ts +27 -4
  129. package/lib/unit-definitions/type-badge-abbr.d.ts +15 -4
  130. package/lib/unit-definitions/type-badge.d.ts +15 -4
  131. package/lib/unit-definitions/type-icon.d.ts +15 -4
  132. package/lib/unit-definitions/url-input.d.ts +23 -4
  133. package/lib/unit-definitions/url.d.ts +23 -4
  134. package/lib/unit-definitions/user-button.d.ts +13 -4
  135. package/lib/unit-definitions/user-role-input.d.ts +26 -4
  136. package/lib/unit-definitions/user-role.d.ts +27 -4
  137. package/lib/unit-definitions/user-role.js +2 -2
  138. package/lib/unit-utils/access.d.ts +4 -5
  139. package/lib/unit-utils/can-edit-field.d.ts +4 -5
  140. package/lib/unit-utils/common.d.ts +16 -11
  141. package/lib/unit-utils/decimal.js +4 -4
  142. package/lib/unit-utils/dynamic-keys.d.ts +8 -9
  143. package/lib/unit-utils/enums.d.ts +4 -5
  144. package/lib/unit-utils/formatters.d.ts +15 -16
  145. package/lib/unit-utils/formatters.js +2 -2
  146. package/lib/unit-utils/get-export-value.d.ts +18 -19
  147. package/lib/unit-utils/get-field-label.d.ts +4 -5
  148. package/lib/unit-utils/get-unmatched-unit-label.d.ts +2 -3
  149. package/lib/unit-utils/wrap-normalized-in-expression.d.ts +2 -3
  150. package/lib/units/board.d.ts +22 -25
  151. package/lib/units/board.js +2 -1
  152. package/lib/units/canvas/index.d.ts +19 -24
  153. package/lib/units/canvas/type-badge-abbr.d.ts +13 -35
  154. package/lib/units/canvas/type-badge.d.ts +13 -35
  155. package/lib/units/default.d.ts +21 -22
  156. package/lib/units/default.js +2 -1
  157. package/lib/units/gallery.d.ts +5 -3
  158. package/lib/units/gantt.d.ts +23 -24
  159. package/lib/units/gantt.js +3 -2
  160. package/lib/units/get-unit-definitions-for-view-type.d.ts +4 -4
  161. package/lib/units/grid.d.ts +14 -25
  162. package/lib/units/grid.js +2 -1
  163. package/lib/units/list.d.ts +17 -26
  164. package/lib/units/list.js +2 -1
  165. package/lib/units/make-factory.d.ts +25 -27
  166. package/lib/units/make-factory.js +3 -3
  167. package/lib/units/types.d.ts +19 -13
  168. package/package.json +8 -8
@@ -4,17 +4,26 @@ import pickBy from "lodash/pickBy.js";
4
4
  //#region src/private/utils.ts
5
5
  const REMOVE = Symbol("remove");
6
6
  const skipRemove = (unit) => unit !== REMOVE;
7
- function visitDeleteExpressionInFilterGroup(filter, visitExpression) {
7
+ const typeObjectById = (schema, id) => schema.getTypeObjectById(id);
8
+ const typeObjectByName = (schema, name) => schema.getTypeObjectByName(name);
9
+ const visitColorCoding = (fromType, colorCoding, visitor) => colorCoding.flatMap((entry) => {
10
+ const expression = visitor.visitExpression(fromType, entry.expression);
11
+ return expression === null ? [] : [{
12
+ ...entry,
13
+ expression
14
+ }];
15
+ });
16
+ const reuseIfUnchanged = (prev, next) => Object.keys(prev).length === Object.keys(next).length && Object.entries(next).every(([key, value]) => Object.hasOwn(prev, key) && Reflect.get(prev, key) === value) ? prev : next;
17
+ const pruneFilterGroup = (filter, visitExpression) => {
8
18
  if (filter.kind !== "group") return null;
9
19
  const value = filter.value.map((nestedFilter) => {
10
- if (nestedFilter.kind === "group") return visitFilterGroup(nestedFilter, visitExpression);
11
- const leaf = nestedFilter;
12
- const expression = leaf.value.expression ? visitExpression(leaf.value.expression) : null;
20
+ if (nestedFilter.kind === "group") return pruneFilterGroup(nestedFilter, visitExpression);
21
+ const expression = nestedFilter.value.expression ? visitExpression(nestedFilter.value.expression) : null;
13
22
  if (!expression) return null;
14
23
  return {
15
- ...leaf,
24
+ ...nestedFilter,
16
25
  value: {
17
- ...leaf.value,
26
+ ...nestedFilter.value,
18
27
  expression
19
28
  }
20
29
  };
@@ -24,20 +33,21 @@ function visitDeleteExpressionInFilterGroup(filter, visitExpression) {
24
33
  ...filter,
25
34
  value
26
35
  };
27
- }
28
- const deleteExpressionWithNotFoundFieldsOrTypesInFilter = (schema, fromType, filter) => {
29
- return visitDeleteExpressionInFilterGroup(filter, (expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression));
30
36
  };
37
+ const deleteExpressionWithNotFoundFieldsOrTypesInFilter = (schema, fromType, filter) => pruneFilterGroup(filter, (expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression));
31
38
  const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, queryExpression) => {
32
39
  const { "q/from": fromExpression, "q/where": whereExpression, "q/order-by": orderByExpression } = queryExpression;
33
40
  const typeObject = schema.getTypeObjectByName(fromExpression);
34
41
  if (!typeObject) return null;
35
42
  const visitor = deleteExpressionsWithNotFoundFieldsVisitor(typeObject);
36
- return pickBy({
37
- ...queryExpression,
38
- ...whereExpression ? { "q/where": visitor.visitExpression(whereExpression) } : null,
39
- ...orderByExpression ? { "q/order-by": visitor.visitOrderByExpression(orderByExpression) } : null
40
- });
43
+ return {
44
+ ...pickBy({
45
+ ...queryExpression,
46
+ ...whereExpression ? { "q/where": visitor.visitExpression(whereExpression) } : null,
47
+ ...orderByExpression ? { "q/order-by": visitor.visitOrderByExpression(orderByExpression) } : null
48
+ }),
49
+ "q/from": typeObject.name
50
+ };
41
51
  };
42
52
  const replaceNamesWithIdsInExpression = (schema, fromType, expression) => {
43
53
  const typeObject = schema.getTypeObjectByName(fromType);
@@ -53,18 +63,23 @@ const visitViewUnit = (fromType, unit, visitor) => {
53
63
  if (unit.kind === "user-button") return unit;
54
64
  const { expression } = unit;
55
65
  if (!expression) return unit;
56
- return {
66
+ const nextExpression = visitor.visitExpression(fromType, expression);
67
+ return nextExpression ? {
57
68
  ...unit,
58
- expression: visitor.visitExpression(fromType, expression)
69
+ expression: nextExpression
70
+ } : {
71
+ ...unit,
72
+ expression: null
59
73
  };
60
74
  };
75
+ const visitUnits = (fromType, units, visitor) => units.map((unit) => visitViewUnit(fromType, unit, visitor)).filter(truthy).filter(isUnitExpressionValid).map((unit, idx, visited) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, visited) : unit).filter(skipRemove);
61
76
  const visitContextExpression = (fromType, contextExpression, visitor) => {
62
- const visitContextExpression = visitor.visitContextExpression ? visitor.visitContextExpression : visitor.visitExpression;
63
- return contextExpression ? visitContextExpression(fromType, contextExpression) : contextExpression;
77
+ if (!contextExpression) return contextExpression;
78
+ return visitor.visitContextExpression ? visitor.visitContextExpression(fromType, contextExpression) : visitor.visitExpression(fromType, contextExpression);
64
79
  };
65
80
  const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
66
81
  const { "q/from": fromExpression, "q/where": whereExpression, "q/order-by": orderByExpression } = queryExpression;
67
- const typeObject = schema.getTypeObjectById(fromExpression);
82
+ const typeObject = typeObjectById(schema, fromExpression);
68
83
  if (!typeObject) return queryExpression;
69
84
  const visitor = replaceIdsWithNamesVisitor(typeObject);
70
85
  return {
@@ -74,39 +89,31 @@ const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
74
89
  ...orderByExpression ? { "q/order-by": visitor.visitOrderByExpression(orderByExpression) } : null
75
90
  };
76
91
  };
77
- function visitFilterGroup(filter, visitExpression, _type) {
78
- if (filter.kind !== "group") return null;
79
- const group = filter;
80
- return {
81
- ...group,
82
- value: group.value.map((nestedFilter) => {
83
- if (nestedFilter.kind === "group") return visitFilterGroup(nestedFilter, visitExpression);
84
- const leaf = nestedFilter;
85
- return {
86
- ...leaf,
87
- value: {
88
- ...leaf.value,
89
- expression: leaf.value.expression ? visitExpression(leaf.value.expression) : null
90
- }
91
- };
92
- })
93
- };
94
- }
92
+ const visitFilterGroup = (filter, visitExpression) => ({
93
+ ...filter,
94
+ value: filter.value.map((nestedFilter) => nestedFilter.kind === "group" ? visitFilterGroup(nestedFilter, visitExpression) : {
95
+ ...nestedFilter,
96
+ value: {
97
+ ...nestedFilter.value,
98
+ expression: nestedFilter.value.expression ? visitExpression(nestedFilter.value.expression) : nestedFilter.value.expression
99
+ }
100
+ })
101
+ });
95
102
  const replaceIdsWithNamesInFilter = (schema, fromType, filter) => {
96
103
  const typeObject = schema.getTypeObjectById(fromType);
97
104
  if (!typeObject) return filter;
98
105
  const visitor = replaceIdsWithNamesVisitor(typeObject);
99
- return filter ? visitFilterGroup(filter, (expression) => visitor.visitExpression(expression), "ids") : null;
106
+ return filter && filter.kind === "group" ? visitFilterGroup(filter, (expression) => visitor.visitExpression(expression)) : null;
100
107
  };
101
108
  const replaceNamesWithIdsInFilter = (schema, fromType, filter) => {
102
109
  const typeObject = schema.getTypeObjectByName(fromType);
103
110
  if (!typeObject) return filter;
104
111
  const visitor = replaceNamesWithIdsVisitor(typeObject);
105
- return filter ? visitFilterGroup(filter, (expression) => visitor.visitExpression(expression), "names") : null;
112
+ return filter && filter.kind === "group" ? visitFilterGroup(filter, (expression) => visitor.visitExpression(expression)) : null;
106
113
  };
107
114
  const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
108
115
  const { "q/from": fromExpression, "q/where": whereExpression, "q/order-by": orderByExpression } = queryExpression;
109
- const typeObject = schema.getTypeObjectByName(fromExpression);
116
+ const typeObject = typeObjectByName(schema, fromExpression);
110
117
  if (!typeObject) return queryExpression;
111
118
  const visitor = replaceNamesWithIdsVisitor(typeObject);
112
119
  return {
@@ -122,15 +129,9 @@ const deleteExpressionWithNotFoundFieldsOrTypesInExpression = (schema, fromType,
122
129
  return deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitExpression(expression);
123
130
  };
124
131
  const resetContextExpressionIfBroken = (schema, fromType, expression, defaultExpression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression) || defaultExpression;
125
- const isUnitExpressionValid = (unit) => {
126
- if (Object.hasOwn(unit, "expression")) {
127
- const { expression } = unit;
128
- return expression !== null;
129
- }
130
- return true;
131
- };
132
+ const isUnitExpressionValid = (unit) => !("expression" in unit) || unit.expression !== null;
132
133
  const getFieldObjectsById = (smartFolder, schema) => {
133
- return smartFolder["fibery/meta"].items.map((item) => item.query["q/from"]).reduce((acc, type) => {
134
+ return (smartFolder["fibery/meta"].items ?? []).map((item) => item.query?.["q/from"]).filter(truthy).reduce((acc, type) => {
134
135
  const typeObject = schema.getTypeObjectById(type);
135
136
  if (!typeObject) return acc;
136
137
  for (const fieldObject of typeObject.fieldObjects) acc[fieldObject.id] = fieldObject;
@@ -163,5 +164,26 @@ const replaceNamesWithIdsInUnitGroupKey = (unitGroupKey, schema) => {
163
164
  return `${unitType}_${fieldObject.id}`;
164
165
  }).filter(Boolean).join("|");
165
166
  };
167
+ const replaceIdsWithNamesViewVisitor = (schema) => ({
168
+ visitQueryExpression: (query) => replaceIdsWithNamesInQueryExpression(schema, query),
169
+ visitFilter: (fromType, filter) => replaceIdsWithNamesInFilter(schema, fromType, filter),
170
+ visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
171
+ });
172
+ const replaceNamesWithIdsViewVisitor = (schema) => ({
173
+ visitQueryExpression: (query) => replaceNamesWithIdsInQueryExpression(schema, query),
174
+ visitFilter: (fromType, filter) => replaceNamesWithIdsInFilter(schema, fromType, filter),
175
+ visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
176
+ });
177
+ const deleteNotFoundViewVisitor = (schema) => ({
178
+ visitQueryExpression: (query) => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, query),
179
+ visitFilter: (fromType, filter) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, filter),
180
+ visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
181
+ });
182
+ const identityViewVisitor = (overrides = {}) => ({
183
+ visitQueryExpression: (query) => query,
184
+ visitFilter: (_fromType, filter) => filter,
185
+ visitExpression: (_fromType, expression) => expression,
186
+ ...overrides
187
+ });
166
188
  //#endregion
167
- export { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteExpressionWithNotFoundFieldsOrTypesInFilter, deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression, getFieldObjectsById, isUnitExpressionValid, replaceIdsWithNamesInExpression, replaceIdsWithNamesInFilter, replaceIdsWithNamesInQueryExpression, replaceIdsWithNamesInUnitGroupKey, replaceNamesWithIdsInExpression, replaceNamesWithIdsInFilter, replaceNamesWithIdsInQueryExpression, replaceNamesWithIdsInUnitGroupKey, resetContextExpressionIfBroken, skipRemove, visitContextExpression, visitViewUnit };
189
+ export { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteExpressionWithNotFoundFieldsOrTypesInFilter, deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression, deleteNotFoundViewVisitor, getFieldObjectsById, identityViewVisitor, isUnitExpressionValid, replaceIdsWithNamesInExpression, replaceIdsWithNamesInFilter, replaceIdsWithNamesInQueryExpression, replaceIdsWithNamesInUnitGroupKey, replaceIdsWithNamesViewVisitor, replaceNamesWithIdsInExpression, replaceNamesWithIdsInFilter, replaceNamesWithIdsInQueryExpression, replaceNamesWithIdsInUnitGroupKey, replaceNamesWithIdsViewVisitor, resetContextExpressionIfBroken, reuseIfUnchanged, skipRemove, typeObjectById, typeObjectByName, visitColorCoding, visitContextExpression, visitUnits, visitViewUnit };
package/lib/refs.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { FieldId, FieldName, TypeId, TypeName } from "@fibery/schema";
2
+ //#region src/refs.d.ts
3
+ export type Refs = {
4
+ type: string;
5
+ field: string;
6
+ };
7
+ export type IdRefs = {
8
+ type: TypeId;
9
+ field: FieldId;
10
+ };
11
+ export type NameRefs = {
12
+ type: TypeName;
13
+ field: FieldName;
14
+ };
15
+ export type MixedRefs = {
16
+ type: TypeName | TypeId;
17
+ field: FieldName | FieldId;
18
+ };
19
+ //#endregion
package/lib/refs.js ADDED
File without changes
@@ -1,5 +1,30 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types.js";
1
+ import { ExpressionFieldUnit, UnitExpression } from "../units/types.js";
2
+ import { calculateUnitExpressionErrors } from "../unit-utils/common.js";
3
+ import { getReferenceCollectionExportValue } from "../unit-utils/get-export-value.js";
4
+ import { getFieldLabel } from "../unit-utils/get-field-label.js";
2
5
  //#region src/unit-definitions/avatar-collection.d.ts
3
- declare const AvatarCollection: UnitDataDefinition<FieldUnit>;
4
- //#endregion
5
- export { AvatarCollection };
6
+ export declare const AvatarCollection: {
7
+ type: "avatar-collection";
8
+ name: string;
9
+ canEdit({ typeObject, unit: { expression } }: {
10
+ typeObject: import("@fibery/schema").TypeObject;
11
+ unit: ExpressionFieldUnit;
12
+ }): boolean;
13
+ getLabel({ typeObject, unit }: {
14
+ typeObject: import("@fibery/schema").TypeObject;
15
+ unit: ExpressionFieldUnit;
16
+ }): string;
17
+ makeUnit: ({ expression }?: {
18
+ expression?: UnitExpression;
19
+ }) => ExpressionFieldUnit;
20
+ getQuerySelect({ typeObject, unit: { expression } }: {
21
+ typeObject: import("@fibery/schema").TypeObject;
22
+ unit: ExpressionFieldUnit;
23
+ schema: import("@fibery/schema").Schema;
24
+ }): Record<string, unknown>;
25
+ calculateErrors: typeof calculateUnitExpressionErrors;
26
+ getExportValue: typeof getReferenceCollectionExportValue;
27
+ canExport: () => true;
28
+ getExportLabel: typeof getFieldLabel;
29
+ };
30
+ //#endregion
@@ -3,8 +3,8 @@ import { generateAccessCheckQueryExpression } from "../unit-utils/access.js";
3
3
  import { calculateUnitExpressionErrors, canEditFieldExpression, makeUnitMethod } from "../unit-utils/common.js";
4
4
  import { getReferenceCollectionExportValue } from "../unit-utils/get-export-value.js";
5
5
  import { getFieldLabel } from "../unit-utils/get-field-label.js";
6
- import { truthy } from "@fibery/helpers/src/_";
7
6
  import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
7
+ import { truthy } from "@fibery/helpers/src/_";
8
8
  import { mergeDenormalizedSelects, toSelectMapClause } from "@fibery/query-utils/src/select";
9
9
  //#region src/unit-definitions/avatar-collection.ts
10
10
  const type = "avatar-collection";
@@ -1,5 +1,50 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types.js";
1
+ import { NumberDisplaySettings } from "../field-utils/number.js";
2
+ import { ExpressionFieldUnit, UnitExpression } from "../units/types.js";
3
+ import { calculateUnitExpressionErrors } from "../unit-utils/common.js";
2
4
  //#region src/unit-definitions/avatar-input.d.ts
3
- declare const AvatarInput: UnitDataDefinition<FieldUnit>;
4
- //#endregion
5
- export { AvatarInput };
5
+ export declare const AvatarInput: {
6
+ canEdit({ typeObject, unit: { expression } }: {
7
+ typeObject: import("@fibery/schema").TypeObject;
8
+ unit: ExpressionFieldUnit;
9
+ }): boolean;
10
+ getLabel({ typeObject, unit }: {
11
+ typeObject: import("@fibery/schema").TypeObject;
12
+ unit: ExpressionFieldUnit;
13
+ }): string;
14
+ getQuerySelect({ typeObject, unit: { expression } }: {
15
+ typeObject: import("@fibery/schema").TypeObject;
16
+ unit: ExpressionFieldUnit;
17
+ schema: import("@fibery/schema").Schema;
18
+ }): import("@fibery/schema").Select | {
19
+ [x: string]: "__NOTHING_INTERESTING__TitleField__" | "fibery/id" | {
20
+ "q/from": import("@fibery/schema").FieldName[];
21
+ "q/limit": string;
22
+ "q/select": import("@fibery/schema").Select;
23
+ };
24
+ "fibery/id": "fibery/id";
25
+ __NOTHING_INTERESTING__TitleField__: "__NOTHING_INTERESTING__TitleField__";
26
+ } | {
27
+ "fibery/id"?: undefined;
28
+ __NOTHING_INTERESTING__TitleField__?: undefined;
29
+ };
30
+ calculateErrors: typeof calculateUnitExpressionErrors;
31
+ getExportValue: ({ typeObject, unit, object }: {
32
+ typeObject: import("@fibery/schema").TypeObject;
33
+ unit: ExpressionFieldUnit;
34
+ object: import("@fibery/expression-utils/src/types").FiberyObject;
35
+ displaySettings: NumberDisplaySettings;
36
+ }) => string | null | undefined;
37
+ canExport: ({ unit }: {
38
+ unit: ExpressionFieldUnit;
39
+ }) => boolean;
40
+ getExportLabel: ({ unit, typeObject }: {
41
+ typeObject: import("@fibery/schema").TypeObject;
42
+ unit: ExpressionFieldUnit;
43
+ }) => string;
44
+ type: "avatar-input";
45
+ name: string;
46
+ makeUnit: ({ expression }?: {
47
+ expression?: UnitExpression;
48
+ }) => ExpressionFieldUnit;
49
+ };
50
+ //#endregion
@@ -1,5 +1,55 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types.js";
1
+ import { NumberDisplaySettings } from "../field-utils/number.js";
2
+ import { ExpressionFieldUnit, UnitExpression } from "../units/types.js";
3
+ import { calculateUnitExpressionErrors } from "../unit-utils/common.js";
4
+ import { TypeObject } from "@fibery/schema";
2
5
  //#region src/unit-definitions/avatar.d.ts
3
- declare const Avatar: UnitDataDefinition<FieldUnit>;
4
- //#endregion
5
- export { Avatar };
6
+ export declare const Avatar: {
7
+ type: "avatar";
8
+ name: string;
9
+ canEdit({ typeObject, unit: { expression } }: {
10
+ typeObject: TypeObject;
11
+ unit: ExpressionFieldUnit;
12
+ }): boolean;
13
+ getLabel({ typeObject, unit }: {
14
+ typeObject: TypeObject;
15
+ unit: ExpressionFieldUnit;
16
+ }): string;
17
+ makeUnit(args?: {
18
+ expression: UnitExpression;
19
+ }): {
20
+ type: "avatar";
21
+ kind: "field";
22
+ expression: string[];
23
+ };
24
+ getQuerySelect({ typeObject, unit: { expression } }: {
25
+ typeObject: TypeObject;
26
+ unit: ExpressionFieldUnit;
27
+ schema: import("@fibery/schema").Schema;
28
+ }): import("@fibery/schema").Select | {
29
+ [x: string]: "__NOTHING_INTERESTING__TitleField__" | "fibery/id" | {
30
+ "q/from": import("@fibery/schema").FieldName[];
31
+ "q/limit": string;
32
+ "q/select": import("@fibery/schema").Select;
33
+ };
34
+ "fibery/id": "fibery/id";
35
+ __NOTHING_INTERESTING__TitleField__: "__NOTHING_INTERESTING__TitleField__";
36
+ } | {
37
+ "fibery/id"?: undefined;
38
+ __NOTHING_INTERESTING__TitleField__?: undefined;
39
+ };
40
+ calculateErrors: typeof calculateUnitExpressionErrors;
41
+ getExportValue: ({ typeObject, unit, object }: {
42
+ typeObject: TypeObject;
43
+ unit: ExpressionFieldUnit;
44
+ object: import("@fibery/expression-utils/src/types").FiberyObject;
45
+ displaySettings: NumberDisplaySettings;
46
+ }) => string | null | undefined;
47
+ canExport: ({ unit }: {
48
+ unit: ExpressionFieldUnit;
49
+ }) => boolean;
50
+ getExportLabel: ({ unit, typeObject }: {
51
+ typeObject: TypeObject;
52
+ unit: ExpressionFieldUnit;
53
+ }) => string;
54
+ };
55
+ //#endregion
@@ -3,8 +3,8 @@ import { generateAccessCheckQueryExpression } from "../unit-utils/access.js";
3
3
  import { calculateUnitExpressionErrors, canEditFieldExpression } from "../unit-utils/common.js";
4
4
  import { getReferenceExportValue } from "../unit-utils/get-export-value.js";
5
5
  import { getFieldLabel } from "../unit-utils/get-field-label.js";
6
- import { truthy } from "@fibery/helpers/src/_";
7
6
  import { assertIsValidExpression, getFieldObjectByFieldExpression, getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
7
+ import { truthy } from "@fibery/helpers/src/_";
8
8
  import { denormalizeSelect, mergeDenormalizedSelects, normalizeSelect, toSelectMapClause } from "@fibery/query-utils/src/select";
9
9
  //#region src/unit-definitions/avatar.ts
10
10
  const type = "avatar";
@@ -1,5 +1,32 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types.js";
1
+ import { EntityLinkProjection } from "../field-utils/back-references.js";
2
+ import { ExpressionFieldUnit, UnitExpression } from "../units/types.js";
3
+ import { calculateUnitExpressionErrors } from "../unit-utils/common.js";
4
+ import { getExportValue } from "../unit-utils/get-export-value.js";
5
+ import { getFieldLabel } from "../unit-utils/get-field-label.js";
6
+ import { canEditField } from "../unit-utils/can-edit-field.js";
2
7
  //#region src/unit-definitions/back-references-list.d.ts
3
- declare const BackReferencesList: UnitDataDefinition<FieldUnit>;
4
- //#endregion
5
- export { BackReferencesList };
8
+ export declare const BackReferencesList: {
9
+ type: "back-references-list";
10
+ name: string;
11
+ canEdit: typeof canEditField;
12
+ makeUnit: ({ expression }?: {
13
+ expression?: UnitExpression;
14
+ }) => ExpressionFieldUnit;
15
+ getLabel: typeof getFieldLabel;
16
+ getQuerySelect: ({ typeObject, unit }: {
17
+ typeObject: import("@fibery/schema").TypeObject;
18
+ unit: ExpressionFieldUnit;
19
+ schema: import("@fibery/schema").Schema;
20
+ }) => {
21
+ [x: string]: {
22
+ "q/from": import("@fibery/schema").FieldName[];
23
+ "q/select": import("@fibery/expression-utils/src/types").Projection<EntityLinkProjection>;
24
+ "q/order-by": import("@fibery/schema").OrderBy | undefined;
25
+ "q/limit": string;
26
+ };
27
+ };
28
+ calculateErrors: typeof calculateUnitExpressionErrors;
29
+ getExportValue: typeof getExportValue;
30
+ canExport: () => true;
31
+ };
32
+ //#endregion
@@ -1,8 +1,8 @@
1
- import { getEntityLinksListSelect } from "../field-utils/back-references.js";
2
1
  import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
2
+ import { canEditField } from "../unit-utils/can-edit-field.js";
3
3
  import { getExportValue } from "../unit-utils/get-export-value.js";
4
4
  import { getFieldLabel } from "../unit-utils/get-field-label.js";
5
- import { canEditField } from "../unit-utils/can-edit-field.js";
5
+ import { getEntityLinksListSelect } from "../field-utils/back-references.js";
6
6
  import { getFieldObjectByFieldExpression } from "@fibery/expression-utils/src/utils";
7
7
  import { calculateDefaultOrderBy } from "@fibery/query-utils/src/query";
8
8
  //#region src/unit-definitions/back-references-list.ts
@@ -1,5 +1,24 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types.js";
1
+ import { ExpressionFieldUnit, UnitExpression } from "../units/types.js";
2
+ import { calculateUnitExpressionErrors } from "../unit-utils/common.js";
3
+ import { getExportValue } from "../unit-utils/get-export-value.js";
4
+ import { getFieldLabel } from "../unit-utils/get-field-label.js";
5
+ import { canEditField } from "../unit-utils/can-edit-field.js";
2
6
  //#region src/unit-definitions/bool-checkbox.d.ts
3
- declare const BoolCheckbox: UnitDataDefinition<FieldUnit>;
4
- //#endregion
5
- export { BoolCheckbox };
7
+ export declare const BoolCheckbox: {
8
+ type: "bool-checkbox";
9
+ name: string;
10
+ canEdit: typeof canEditField;
11
+ getLabel: typeof getFieldLabel;
12
+ makeUnit: ({ expression }?: {
13
+ expression?: UnitExpression;
14
+ }) => ExpressionFieldUnit;
15
+ getQuerySelect({ typeObject, unit: { expression } }: {
16
+ typeObject: import("@fibery/schema").TypeObject;
17
+ unit: ExpressionFieldUnit;
18
+ schema: import("@fibery/schema").Schema;
19
+ }): import("@fibery/schema").Select;
20
+ calculateErrors: typeof calculateUnitExpressionErrors;
21
+ getExportValue: typeof getExportValue;
22
+ canExport: () => true;
23
+ };
24
+ //#endregion
@@ -1,7 +1,7 @@
1
1
  import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
2
+ import { canEditField } from "../unit-utils/can-edit-field.js";
2
3
  import { getExportValue } from "../unit-utils/get-export-value.js";
3
4
  import { getFieldLabel } from "../unit-utils/get-field-label.js";
4
- import { canEditField } from "../unit-utils/can-edit-field.js";
5
5
  import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
6
6
  //#region src/unit-definitions/bool-checkbox.ts
7
7
  const type = "bool-checkbox";
@@ -1,5 +1,24 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types.js";
1
+ import { ExpressionFieldUnit, UnitExpression } from "../units/types.js";
2
+ import { calculateUnitExpressionErrors } from "../unit-utils/common.js";
3
+ import { getExportValue } from "../unit-utils/get-export-value.js";
4
+ import { getFieldLabel } from "../unit-utils/get-field-label.js";
5
+ import { canEditField } from "../unit-utils/can-edit-field.js";
2
6
  //#region src/unit-definitions/bool.d.ts
3
- declare const Bool: UnitDataDefinition<FieldUnit>;
4
- //#endregion
5
- export { Bool };
7
+ export declare const Bool: {
8
+ type: "bool";
9
+ name: string;
10
+ canEdit: typeof canEditField;
11
+ getLabel: typeof getFieldLabel;
12
+ makeUnit: ({ expression }?: {
13
+ expression?: UnitExpression;
14
+ }) => ExpressionFieldUnit;
15
+ getQuerySelect({ typeObject, unit: { expression } }: {
16
+ typeObject: import("@fibery/schema").TypeObject;
17
+ unit: ExpressionFieldUnit;
18
+ schema: import("@fibery/schema").Schema;
19
+ }): import("@fibery/schema").Select;
20
+ calculateErrors: typeof calculateUnitExpressionErrors;
21
+ getExportValue: typeof getExportValue;
22
+ canExport: () => true;
23
+ };
24
+ //#endregion
@@ -1,7 +1,7 @@
1
1
  import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
2
+ import { canEditField } from "../unit-utils/can-edit-field.js";
2
3
  import { getExportValue } from "../unit-utils/get-export-value.js";
3
4
  import { getFieldLabel } from "../unit-utils/get-field-label.js";
4
- import { canEditField } from "../unit-utils/can-edit-field.js";
5
5
  import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
6
6
  //#region src/unit-definitions/bool.ts
7
7
  const type = "bool";
@@ -1,5 +1,32 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types.js";
1
+ import { NumberDisplaySettings } from "../field-utils/number.js";
2
+ import { ExpressionFieldUnit, UnitExpression } from "../units/types.js";
3
+ import { calculateUnitExpressionErrors } from "../unit-utils/common.js";
2
4
  //#region src/unit-definitions/collection-count.d.ts
3
- declare const CollectionCount: UnitDataDefinition<FieldUnit>;
4
- //#endregion
5
- export { CollectionCount };
5
+ export declare const CollectionCount: {
6
+ type: "collection-count";
7
+ name: string;
8
+ canEdit: () => false;
9
+ makeUnit: ({ expression }?: {
10
+ expression?: UnitExpression;
11
+ }) => ExpressionFieldUnit;
12
+ getLabel({ typeObject, unit }: {
13
+ typeObject: import("@fibery/schema").TypeObject;
14
+ unit: ExpressionFieldUnit;
15
+ }): string;
16
+ getQuerySelect({ unit: { expression } }: {
17
+ typeObject: import("@fibery/schema").TypeObject;
18
+ unit: ExpressionFieldUnit;
19
+ schema: import("@fibery/schema").Schema;
20
+ }): {
21
+ [x: string]: (string | string[])[];
22
+ };
23
+ calculateErrors: typeof calculateUnitExpressionErrors;
24
+ getExportValue: ({ object, unit }: {
25
+ typeObject: import("@fibery/schema").TypeObject;
26
+ unit: ExpressionFieldUnit;
27
+ object: import("@fibery/expression-utils/src/types").FiberyObject;
28
+ displaySettings: NumberDisplaySettings;
29
+ }) => unknown;
30
+ canExport: () => true;
31
+ };
32
+ //#endregion
@@ -1,6 +1,6 @@
1
- import { getCountKey, makeCollectionCountExpression } from "../field-utils/reference-collection.js";
2
1
  import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
3
2
  import { getFieldLabel } from "../unit-utils/get-field-label.js";
3
+ import { getCountKey, makeCollectionCountExpression } from "../field-utils/reference-collection.js";
4
4
  import { getFieldObjectByFieldExpression } from "@fibery/expression-utils/src/utils";
5
5
  //#region src/unit-definitions/collection-count.ts
6
6
  const type = "collection-count";
@@ -1,5 +1,23 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types.js";
1
+ import { ExpressionFieldUnit, UnitExpression } from "../units/types.js";
2
+ import { calculateUnitExpressionErrors } from "../unit-utils/common.js";
3
+ import { getFieldLabel } from "../unit-utils/get-field-label.js";
4
+ import { canEditField } from "../unit-utils/can-edit-field.js";
2
5
  //#region src/unit-definitions/color-input.d.ts
3
- declare const ColorInput: UnitDataDefinition<FieldUnit>;
4
- //#endregion
5
- export { ColorInput };
6
+ export declare const ColorInput: {
7
+ type: "color-input";
8
+ name: string;
9
+ canEdit: typeof canEditField;
10
+ makeUnit: ({ expression }?: {
11
+ expression?: UnitExpression;
12
+ }) => ExpressionFieldUnit;
13
+ getLabel: typeof getFieldLabel;
14
+ getQuerySelect({ typeObject, unit: { expression } }: {
15
+ typeObject: import("@fibery/schema").TypeObject;
16
+ unit: ExpressionFieldUnit;
17
+ schema: import("@fibery/schema").Schema;
18
+ }): import("@fibery/schema").Select;
19
+ calculateErrors: typeof calculateUnitExpressionErrors;
20
+ getExportValue: () => null;
21
+ canExport: () => false;
22
+ };
23
+ //#endregion
@@ -1,6 +1,6 @@
1
1
  import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
2
- import { getFieldLabel } from "../unit-utils/get-field-label.js";
3
2
  import { canEditField } from "../unit-utils/can-edit-field.js";
3
+ import { getFieldLabel } from "../unit-utils/get-field-label.js";
4
4
  import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
5
5
  //#region src/unit-definitions/color-input.ts
6
6
  const type = "color-input";