@fibery/views 19.0.0 → 19.1.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 (195) hide show
  1. package/lib/src/errors.d.ts +2 -0
  2. package/lib/src/errors.js +6 -0
  3. package/lib/src/field-utils/avatar.d.ts +1 -1
  4. package/lib/src/field-utils/avatar.js +1 -1
  5. package/lib/src/field-utils/back-references.d.ts +1 -1
  6. package/lib/src/field-utils/comments.d.ts +1 -1
  7. package/lib/src/field-utils/date-time.d.ts +5 -5
  8. package/lib/src/field-utils/date-time.js +1 -1
  9. package/lib/src/field-utils/enum-value.d.ts +1 -1
  10. package/lib/src/field-utils/file.d.ts +1 -1
  11. package/lib/src/field-utils/file.js +1 -1
  12. package/lib/src/field-utils/icon.d.ts +1 -1
  13. package/lib/src/field-utils/number.d.ts +1 -1
  14. package/lib/src/field-utils/reference-collection.d.ts +2 -2
  15. package/lib/src/field-utils/reference-collection.js +4 -4
  16. package/lib/src/field-utils/reference.d.ts +2 -2
  17. package/lib/src/field-utils/reference.js +4 -4
  18. package/lib/src/field-utils/relation-view.d.ts +1 -1
  19. package/lib/src/field-utils/rich-text.d.ts +2 -2
  20. package/lib/src/field-utils/rich-text.js +1 -1
  21. package/lib/src/field-utils/text.d.ts +1 -1
  22. package/lib/src/field-utils/user-active.d.ts +2 -2
  23. package/lib/src/field-utils/user-role.d.ts +1 -1
  24. package/lib/src/field-utils/workflow.d.ts +2 -2
  25. package/lib/src/index.d.ts +30 -16
  26. package/lib/src/index.js +7 -2
  27. package/lib/src/meta-validation.d.ts +10 -0
  28. package/lib/src/meta-validation.js +78 -0
  29. package/lib/src/private/board.d.ts +15 -11
  30. package/lib/src/private/board.js +8 -7
  31. package/lib/src/private/calendar.d.ts +14 -10
  32. package/lib/src/private/calendar.js +4 -3
  33. package/lib/src/private/feed.d.ts +14 -10
  34. package/lib/src/private/feed.js +4 -3
  35. package/lib/src/private/form.d.ts +25 -3
  36. package/lib/src/private/form.js +3 -3
  37. package/lib/src/private/map.d.ts +14 -10
  38. package/lib/src/private/map.js +4 -3
  39. package/lib/src/private/smart-folder.d.ts +23 -15
  40. package/lib/src/private/smart-folder.js +16 -13
  41. package/lib/src/private/timeline.d.ts +39 -10
  42. package/lib/src/private/timeline.js +8 -6
  43. package/lib/src/private/units.d.ts +10 -6
  44. package/lib/src/private/units.js +32 -24
  45. package/lib/src/private/utils.d.ts +64 -17
  46. package/lib/src/private/utils.js +26 -20
  47. package/lib/src/truthy.d.ts +1 -0
  48. package/lib/src/truthy.js +7 -0
  49. package/lib/src/unit-definitions/avatar-collection.d.ts +1 -1
  50. package/lib/src/unit-definitions/avatar-collection.js +5 -10
  51. package/lib/src/unit-definitions/avatar-input.d.ts +1 -1
  52. package/lib/src/unit-definitions/avatar-input.js +1 -1
  53. package/lib/src/unit-definitions/avatar.d.ts +1 -1
  54. package/lib/src/unit-definitions/avatar.js +5 -7
  55. package/lib/src/unit-definitions/back-references-list.d.ts +1 -1
  56. package/lib/src/unit-definitions/back-references-list.js +3 -3
  57. package/lib/src/unit-definitions/bool-checkbox.d.ts +1 -1
  58. package/lib/src/unit-definitions/bool-checkbox.js +2 -2
  59. package/lib/src/unit-definitions/bool.d.ts +1 -1
  60. package/lib/src/unit-definitions/bool.js +1 -1
  61. package/lib/src/unit-definitions/collection-count.d.ts +1 -1
  62. package/lib/src/unit-definitions/collection-count.js +4 -2
  63. package/lib/src/unit-definitions/color-input.d.ts +1 -1
  64. package/lib/src/unit-definitions/color-input.js +1 -1
  65. package/lib/src/unit-definitions/comments-list.d.ts +1 -1
  66. package/lib/src/unit-definitions/comments-list.js +1 -1
  67. package/lib/src/unit-definitions/date-range-combobox.d.ts +1 -1
  68. package/lib/src/unit-definitions/date-range-combobox.js +1 -1
  69. package/lib/src/unit-definitions/date-range.d.ts +1 -1
  70. package/lib/src/unit-definitions/date-range.js +1 -1
  71. package/lib/src/unit-definitions/date-time-combobox.d.ts +1 -1
  72. package/lib/src/unit-definitions/date-time-combobox.js +2 -2
  73. package/lib/src/unit-definitions/date.d.ts +1 -1
  74. package/lib/src/unit-definitions/date.js +2 -2
  75. package/lib/src/unit-definitions/email-input.d.ts +1 -1
  76. package/lib/src/unit-definitions/email-input.js +1 -1
  77. package/lib/src/unit-definitions/email.d.ts +1 -1
  78. package/lib/src/unit-definitions/email.js +1 -1
  79. package/lib/src/unit-definitions/emoji.d.ts +1 -1
  80. package/lib/src/unit-definitions/emoji.js +1 -1
  81. package/lib/src/unit-definitions/file-collection-count.d.ts +1 -1
  82. package/lib/src/unit-definitions/file-collection-count.js +11 -9
  83. package/lib/src/unit-definitions/file-compact-collection.d.ts +1 -1
  84. package/lib/src/unit-definitions/file-compact-collection.js +11 -9
  85. package/lib/src/unit-definitions/file-compact-reference.d.ts +1 -1
  86. package/lib/src/unit-definitions/file-compact-reference.js +3 -12
  87. package/lib/src/unit-definitions/file-reference.d.ts +1 -1
  88. package/lib/src/unit-definitions/file-reference.js +8 -6
  89. package/lib/src/unit-definitions/files-gallery.d.ts +1 -1
  90. package/lib/src/unit-definitions/files-gallery.js +11 -9
  91. package/lib/src/unit-definitions/files-l-list-item.d.ts +1 -1
  92. package/lib/src/unit-definitions/files-l-list-item.js +8 -6
  93. package/lib/src/unit-definitions/files-l-list.d.ts +1 -1
  94. package/lib/src/unit-definitions/files-l-list.js +11 -9
  95. package/lib/src/unit-definitions/files-list-item.d.ts +1 -1
  96. package/lib/src/unit-definitions/files-list-item.js +8 -6
  97. package/lib/src/unit-definitions/files-list.d.ts +1 -1
  98. package/lib/src/unit-definitions/files-list.js +11 -9
  99. package/lib/src/unit-definitions/geometry-preview.d.ts +1 -1
  100. package/lib/src/unit-definitions/geometry-preview.js +1 -1
  101. package/lib/src/unit-definitions/icon-button.d.ts +1 -1
  102. package/lib/src/unit-definitions/icon-button.js +1 -1
  103. package/lib/src/unit-definitions/icon-input.d.ts +1 -1
  104. package/lib/src/unit-definitions/icon-input.js +1 -1
  105. package/lib/src/unit-definitions/id.d.ts +1 -1
  106. package/lib/src/unit-definitions/json-input.d.ts +1 -1
  107. package/lib/src/unit-definitions/json-input.js +1 -1
  108. package/lib/src/unit-definitions/location-input.d.ts +1 -1
  109. package/lib/src/unit-definitions/location-input.js +1 -1
  110. package/lib/src/unit-definitions/location.d.ts +1 -1
  111. package/lib/src/unit-definitions/location.js +1 -1
  112. package/lib/src/unit-definitions/not-found.d.ts +1 -1
  113. package/lib/src/unit-definitions/number-input.d.ts +1 -1
  114. package/lib/src/unit-definitions/number-input.js +2 -2
  115. package/lib/src/unit-definitions/number.d.ts +1 -1
  116. package/lib/src/unit-definitions/number.js +2 -4
  117. package/lib/src/unit-definitions/phone-input.d.ts +1 -1
  118. package/lib/src/unit-definitions/phone-input.js +1 -1
  119. package/lib/src/unit-definitions/phone.d.ts +1 -1
  120. package/lib/src/unit-definitions/phone.js +1 -1
  121. package/lib/src/unit-definitions/progress-bar.d.ts +1 -1
  122. package/lib/src/unit-definitions/progress-bar.js +1 -4
  123. package/lib/src/unit-definitions/reference-collection-combobox.d.ts +1 -1
  124. package/lib/src/unit-definitions/reference-collection-combobox.js +1 -1
  125. package/lib/src/unit-definitions/reference-collection-list.d.ts +1 -1
  126. package/lib/src/unit-definitions/reference-collection-list.js +1 -1
  127. package/lib/src/unit-definitions/reference-collection-view.d.ts +1 -1
  128. package/lib/src/unit-definitions/reference-collection-view.js +1 -1
  129. package/lib/src/unit-definitions/reference-collection.d.ts +1 -1
  130. package/lib/src/unit-definitions/reference-collection.js +3 -3
  131. package/lib/src/unit-definitions/reference-combobox.d.ts +1 -1
  132. package/lib/src/unit-definitions/reference-combobox.js +1 -1
  133. package/lib/src/unit-definitions/reference-icon.d.ts +1 -1
  134. package/lib/src/unit-definitions/reference-icon.js +1 -1
  135. package/lib/src/unit-definitions/reference.d.ts +1 -1
  136. package/lib/src/unit-definitions/reference.js +1 -1
  137. package/lib/src/unit-definitions/rich-text-document.d.ts +1 -1
  138. package/lib/src/unit-definitions/rich-text-document.js +2 -2
  139. package/lib/src/unit-definitions/rich-text-snippet.d.ts +2 -1
  140. package/lib/src/unit-definitions/rich-text-snippet.js +6 -11
  141. package/lib/src/unit-definitions/single-location-preview.d.ts +1 -1
  142. package/lib/src/unit-definitions/single-location-preview.js +1 -1
  143. package/lib/src/unit-definitions/text-input.d.ts +1 -1
  144. package/lib/src/unit-definitions/text-input.js +2 -2
  145. package/lib/src/unit-definitions/text.d.ts +1 -1
  146. package/lib/src/unit-definitions/text.js +2 -2
  147. package/lib/src/unit-definitions/title-input.d.ts +1 -1
  148. package/lib/src/unit-definitions/title.d.ts +1 -1
  149. package/lib/src/unit-definitions/type-badge-abbr.d.ts +1 -1
  150. package/lib/src/unit-definitions/type-badge.d.ts +1 -1
  151. package/lib/src/unit-definitions/type-icon.d.ts +1 -1
  152. package/lib/src/unit-definitions/url-input.d.ts +1 -1
  153. package/lib/src/unit-definitions/url-input.js +1 -1
  154. package/lib/src/unit-definitions/url.d.ts +1 -1
  155. package/lib/src/unit-definitions/url.js +1 -1
  156. package/lib/src/unit-definitions/user-button.d.ts +1 -1
  157. package/lib/src/unit-definitions/user-role-input.d.ts +1 -1
  158. package/lib/src/unit-definitions/user-role-input.js +1 -1
  159. package/lib/src/unit-definitions/user-role.d.ts +1 -1
  160. package/lib/src/unit-definitions/user-role.js +1 -1
  161. package/lib/src/unit-utils/access.d.ts +2 -2
  162. package/lib/src/unit-utils/can-edit-field.d.ts +2 -2
  163. package/lib/src/unit-utils/common.d.ts +3 -3
  164. package/lib/src/unit-utils/common.js +1 -1
  165. package/lib/src/unit-utils/enums.d.ts +2 -2
  166. package/lib/src/unit-utils/formatters.d.ts +2 -2
  167. package/lib/src/unit-utils/get-export-value.d.ts +4 -4
  168. package/lib/src/unit-utils/get-export-value.js +3 -3
  169. package/lib/src/unit-utils/get-field-label.d.ts +2 -2
  170. package/lib/src/unit-utils/get-unmatched-unit-label.d.ts +1 -1
  171. package/lib/src/unit-utils/schema.d.ts +1 -1
  172. package/lib/src/unit-utils/wrap-normalized-in-expression.d.ts +3 -0
  173. package/lib/src/unit-utils/wrap-normalized-in-expression.js +14 -0
  174. package/lib/src/units/board.d.ts +5 -5
  175. package/lib/src/units/board.js +1 -1
  176. package/lib/src/units/canvas/index.d.ts +4 -4
  177. package/lib/src/units/canvas/index.js +1 -1
  178. package/lib/src/units/canvas/type-badge-abbr.d.ts +1 -1
  179. package/lib/src/units/canvas/type-badge.d.ts +1 -1
  180. package/lib/src/units/default.d.ts +5 -5
  181. package/lib/src/units/default.js +1 -1
  182. package/lib/src/units/gallery.d.ts +1 -1
  183. package/lib/src/units/gantt.d.ts +5 -5
  184. package/lib/src/units/gantt.js +1 -1
  185. package/lib/src/units/get-unit-definitions-for-view-type.js +4 -4
  186. package/lib/src/units/grid.d.ts +4 -4
  187. package/lib/src/units/grid.js +7 -7
  188. package/lib/src/units/list.d.ts +5 -5
  189. package/lib/src/units/list.js +1 -1
  190. package/lib/src/units/make-factory.d.ts +4 -5
  191. package/lib/src/units/make-factory.js +26 -15
  192. package/lib/src/units/types.d.ts +5 -5
  193. package/package.json +18 -18
  194. package/lib/jest.config.cjs +0 -34
  195. package/lib/jest.config.d.cts +0 -3
@@ -3,12 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.replaceNamesWithIdsInUnitGroupKey = exports.replaceIdsWithNamesInUnitGroupKey = exports.getFieldObjectsById = exports.isUnitExpressionValid = exports.resetContextExpressionIfBroken = exports.deleteExpressionWithNotFoundFieldsOrTypesInExpression = exports.replaceNamesWithIdsInQueryExpression = exports.replaceNamesWithIdsInFilter = exports.replaceIdsWithNamesInFilter = exports.replaceIdsWithNamesInQueryExpression = exports.visitContextExpression = exports.visitViewUnit = exports.replaceIdsWithNamesInExpression = exports.replaceNamesWithIdsInExpression = exports.deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = exports.deleteExpressionWithNotFoundFieldsOrTypesInFilter = exports.REMOVE = void 0;
6
+ exports.replaceNamesWithIdsInUnitGroupKey = exports.replaceIdsWithNamesInUnitGroupKey = exports.getFieldObjectsById = exports.isUnitExpressionValid = exports.resetContextExpressionIfBroken = exports.deleteExpressionWithNotFoundFieldsOrTypesInExpression = exports.replaceNamesWithIdsInQueryExpression = exports.replaceNamesWithIdsInFilter = exports.replaceIdsWithNamesInFilter = exports.replaceIdsWithNamesInQueryExpression = exports.visitContextExpression = exports.visitViewUnit = exports.replaceIdsWithNamesInExpression = exports.replaceNamesWithIdsInExpression = exports.deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = exports.deleteExpressionWithNotFoundFieldsOrTypesInFilter = exports.skipRemove = exports.REMOVE = void 0;
7
7
  const visitors_1 = require("@fibery/expression-utils/src/visitors");
8
8
  const pickBy_1 = __importDefault(require("lodash/pickBy"));
9
+ const truthy_1 = require("../truthy");
9
10
  // Return this symbol from a visitor callback to remove the node from the
10
11
  // output. Not supported in all places, add support as needed.
11
12
  exports.REMOVE = Symbol("remove");
13
+ const skipRemove = (unit) => unit !== exports.REMOVE;
14
+ exports.skipRemove = skipRemove;
12
15
  function visitDeleteExpressionInFilterGroup(filter, visitExpression) {
13
16
  if (filter.kind !== "group") {
14
17
  return null;
@@ -18,19 +21,20 @@ function visitDeleteExpressionInFilterGroup(filter, visitExpression) {
18
21
  if (nestedFilter.kind === "group") {
19
22
  return visitFilterGroup(nestedFilter, visitExpression);
20
23
  }
21
- const expression = nestedFilter.value.expression ? visitExpression(nestedFilter.value.expression) : null;
24
+ const leaf = nestedFilter;
25
+ const expression = leaf.value.expression ? visitExpression(leaf.value.expression) : null;
22
26
  if (!expression) {
23
27
  return null;
24
28
  }
25
29
  return {
26
- ...nestedFilter,
30
+ ...leaf,
27
31
  value: {
28
- ...nestedFilter.value,
32
+ ...leaf.value,
29
33
  expression: expression,
30
34
  },
31
35
  };
32
36
  })
33
- .filter(Boolean);
37
+ .filter(truthy_1.truthy);
34
38
  if (value.length === 0) {
35
39
  return null;
36
40
  }
@@ -81,16 +85,15 @@ const replaceIdsWithNamesInExpression = (schema, fromTypeId, expression) => {
81
85
  };
82
86
  exports.replaceIdsWithNamesInExpression = replaceIdsWithNamesInExpression;
83
87
  const visitViewUnit = (fromType, unit, visitor) => {
88
+ if (unit.kind === "user-button") {
89
+ return unit;
90
+ }
84
91
  const { expression } = unit;
85
- if (expression) {
86
- return {
87
- ...unit,
88
- ...{
89
- expression: visitor.visitExpression(fromType, expression),
90
- },
91
- };
92
+ if (!expression) {
93
+ return unit;
92
94
  }
93
- return unit;
95
+ // visitExpression preserves string[] shape; null results are filtered by isUnitExpressionValid downstream
96
+ return { ...unit, expression: visitor.visitExpression(fromType, expression) };
94
97
  };
95
98
  exports.visitViewUnit = visitViewUnit;
96
99
  const visitContextExpression = (fromType, contextExpression, visitor) => {
@@ -122,21 +125,23 @@ const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
122
125
  return queryExpression;
123
126
  };
124
127
  exports.replaceIdsWithNamesInQueryExpression = replaceIdsWithNamesInQueryExpression;
125
- function visitFilterGroup(filter, visitExpression, type) {
128
+ function visitFilterGroup(filter, visitExpression, _type) {
126
129
  if (filter.kind !== "group") {
127
130
  return null;
128
131
  }
132
+ const group = filter;
129
133
  return {
130
- ...filter,
131
- value: filter.value.map((nestedFilter) => {
134
+ ...group,
135
+ value: group.value.map((nestedFilter) => {
132
136
  if (nestedFilter.kind === "group") {
133
137
  return visitFilterGroup(nestedFilter, visitExpression);
134
138
  }
139
+ const leaf = nestedFilter;
135
140
  return {
136
- ...nestedFilter,
141
+ ...leaf,
137
142
  value: {
138
- ...nestedFilter.value,
139
- expression: nestedFilter.value.expression ? visitExpression(nestedFilter.value.expression) : null,
143
+ ...leaf.value,
144
+ expression: leaf.value.expression ? visitExpression(leaf.value.expression) : null,
140
145
  },
141
146
  };
142
147
  }),
@@ -203,7 +208,8 @@ const isUnitExpressionValid = (unit) => {
203
208
  };
204
209
  exports.isUnitExpressionValid = isUnitExpressionValid;
205
210
  const getFieldObjectsById = (smartFolder, schema) => {
206
- const types = smartFolder["fibery/meta"].items.map((item) => item.query["q/from"]);
211
+ const meta = smartFolder["fibery/meta"];
212
+ const types = meta.items.map((item) => item.query["q/from"]);
207
213
  return types.reduce((acc, type) => {
208
214
  if (!Object.hasOwn(schema.typeObjectsById, type)) {
209
215
  return acc;
@@ -0,0 +1 @@
1
+ export declare const truthy: <T>(x: T | null | undefined | false) => x is T;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.truthy = void 0;
4
+ const truthy = (x) => {
5
+ return Boolean(x);
6
+ };
7
+ exports.truthy = truthy;
@@ -1,2 +1,2 @@
1
- import { UnitDataDefinition, FieldUnit } from "../units/types";
1
+ import type { UnitDataDefinition, FieldUnit } from "../units/types";
2
2
  export declare const AvatarCollection: UnitDataDefinition<FieldUnit>;
@@ -4,12 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AvatarCollection = void 0;
7
- const compact_1 = __importDefault(require("lodash/compact"));
8
7
  const utils_1 = require("@fibery/expression-utils/src/utils");
9
8
  const select_1 = require("@fibery/query-utils/src/select");
10
- const get_export_value_1 = require("../unit-utils/get-export-value");
9
+ const compact_1 = __importDefault(require("lodash/compact"));
11
10
  const avatar_1 = require("../field-utils/avatar");
12
11
  const common_1 = require("../unit-utils/common");
12
+ const get_export_value_1 = require("../unit-utils/get-export-value");
13
+ const get_field_label_1 = require("../unit-utils/get-field-label");
13
14
  const type = "avatar-collection";
14
15
  exports.AvatarCollection = {
15
16
  type,
@@ -18,9 +19,7 @@ exports.AvatarCollection = {
18
19
  return (0, common_1.canEditFieldExpression)(typeObject, expression);
19
20
  },
20
21
  getLabel({ typeObject, unit }) {
21
- const { expression } = unit;
22
- const fieldObject = (0, utils_1.getFieldObjectByFieldExpression)({ typeObject, expression });
23
- return `Avatar of ${fieldObject.title}`;
22
+ return `Avatar of ${(0, get_field_label_1.getFieldLabel)({ typeObject, unit })}`;
24
23
  },
25
24
  makeUnit: (0, common_1.makeUnitMethod)(type),
26
25
  getQuerySelect({ typeObject, unit: { expression } }) {
@@ -51,9 +50,5 @@ exports.AvatarCollection = {
51
50
  calculateErrors: common_1.calculateUnitExpressionErrors,
52
51
  getExportValue: get_export_value_1.getReferenceCollectionExportValue,
53
52
  canExport: () => true,
54
- getExportLabel: ({ unit, typeObject }) => {
55
- const { expression } = unit;
56
- const fieldObject = (0, utils_1.getFieldObjectByFieldExpression)({ typeObject, expression });
57
- return fieldObject.title;
58
- },
53
+ getExportLabel: get_field_label_1.getFieldLabel,
59
54
  };
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const AvatarInput: UnitDataDefinition<FieldUnit>;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AvatarInput = void 0;
4
- const avatar_1 = require("./avatar");
5
4
  const common_1 = require("../unit-utils/common");
5
+ const avatar_1 = require("./avatar");
6
6
  const type = "avatar-input";
7
7
  exports.AvatarInput = {
8
8
  ...avatar_1.Avatar,
@@ -1,2 +1,2 @@
1
- import { UnitDataDefinition, FieldUnit } from "../units/types";
1
+ import type { UnitDataDefinition, FieldUnit } from "../units/types";
2
2
  export declare const Avatar: UnitDataDefinition<FieldUnit>;
@@ -4,12 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Avatar = void 0;
7
- const compact_1 = __importDefault(require("lodash/compact"));
8
- const select_1 = require("@fibery/query-utils/src/select");
9
7
  const utils_1 = require("@fibery/expression-utils/src/utils");
8
+ const select_1 = require("@fibery/query-utils/src/select");
9
+ const compact_1 = __importDefault(require("lodash/compact"));
10
10
  const avatar_1 = require("../field-utils/avatar");
11
11
  const common_1 = require("../unit-utils/common");
12
12
  const get_export_value_1 = require("../unit-utils/get-export-value");
13
+ const get_field_label_1 = require("../unit-utils/get-field-label");
13
14
  const type = "avatar";
14
15
  const getSelfAvatarSelectQuery = (typeObject) => (0, avatar_1.getAvatarSelectQuery)({ typeObject }) || {};
15
16
  exports.Avatar = {
@@ -24,12 +25,9 @@ exports.Avatar = {
24
25
  getLabel({ typeObject, unit }) {
25
26
  const { expression } = unit;
26
27
  if (expression) {
27
- const fieldObject = (0, utils_1.getFieldObjectByFieldExpression)({
28
- typeObject,
29
- expression,
30
- });
28
+ const fieldObject = (0, utils_1.getFieldObjectByFieldExpression)({ typeObject, expression });
31
29
  if ((0, avatar_1.isAvatarExtensionEnabledType)(fieldObject.typeObject)) {
32
- return `Avatar of ${fieldObject.title}`;
30
+ return `Avatar of ${(0, get_field_label_1.getFieldLabel)({ typeObject, unit })}`;
33
31
  }
34
32
  }
35
33
  return "Avatar";
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const BackReferencesList: UnitDataDefinition<FieldUnit>;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BackReferencesList = void 0;
4
- const query_1 = require("@fibery/query-utils/src/query");
5
4
  const utils_1 = require("@fibery/expression-utils/src/utils");
5
+ const query_1 = require("@fibery/query-utils/src/query");
6
6
  const back_references_1 = require("../field-utils/back-references");
7
- const common_1 = require("../unit-utils/common");
8
7
  const can_edit_field_1 = require("../unit-utils/can-edit-field");
9
- const get_field_label_1 = require("../unit-utils/get-field-label");
8
+ const common_1 = require("../unit-utils/common");
10
9
  const get_export_value_1 = require("../unit-utils/get-export-value");
10
+ const get_field_label_1 = require("../unit-utils/get-field-label");
11
11
  const type = "back-references-list";
12
12
  const getQuerySelect = (fieldObject) => {
13
13
  const { name, typeObject } = fieldObject;
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const BoolCheckbox: UnitDataDefinition<FieldUnit>;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BoolCheckbox = void 0;
4
4
  const query_1 = require("@fibery/query-utils/src/query");
5
- const common_1 = require("../unit-utils/common");
6
5
  const can_edit_field_1 = require("../unit-utils/can-edit-field");
7
- const get_field_label_1 = require("../unit-utils/get-field-label");
6
+ const common_1 = require("../unit-utils/common");
8
7
  const get_export_value_1 = require("../unit-utils/get-export-value");
8
+ const get_field_label_1 = require("../unit-utils/get-field-label");
9
9
  const type = "bool-checkbox";
10
10
  exports.BoolCheckbox = {
11
11
  type,
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const Bool: UnitDataDefinition<FieldUnit>;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Bool = void 0;
4
4
  const query_1 = require("@fibery/query-utils/src/query");
5
5
  const can_edit_field_1 = require("../unit-utils/can-edit-field");
6
- const get_field_label_1 = require("../unit-utils/get-field-label");
7
6
  const common_1 = require("../unit-utils/common");
8
7
  const get_export_value_1 = require("../unit-utils/get-export-value");
8
+ const get_field_label_1 = require("../unit-utils/get-field-label");
9
9
  const type = "bool";
10
10
  exports.Bool = {
11
11
  type,
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const CollectionCount: UnitDataDefinition<FieldUnit>;
@@ -4,6 +4,7 @@ exports.CollectionCount = void 0;
4
4
  const utils_1 = require("@fibery/expression-utils/src/utils");
5
5
  const reference_collection_1 = require("../field-utils/reference-collection");
6
6
  const common_1 = require("../unit-utils/common");
7
+ const get_field_label_1 = require("../unit-utils/get-field-label");
7
8
  const type = "collection-count";
8
9
  exports.CollectionCount = {
9
10
  type,
@@ -13,10 +14,11 @@ exports.CollectionCount = {
13
14
  getLabel({ typeObject, unit }) {
14
15
  const { expression } = unit;
15
16
  const fieldObject = (0, utils_1.getFieldObjectByFieldExpression)({ typeObject, expression });
17
+ const label = (0, get_field_label_1.getFieldLabel)({ typeObject, unit });
16
18
  if (fieldObject.name === "comments/comments") {
17
- return fieldObject.title;
19
+ return label;
18
20
  }
19
- return `${fieldObject.title} Count`;
21
+ return `${label} Count`;
20
22
  },
21
23
  getQuerySelect({ unit: { expression } }) {
22
24
  const countKey = (0, reference_collection_1.getCountKey)(expression.join("/"));
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const ColorInput: UnitDataDefinition<FieldUnit>;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ColorInput = void 0;
4
4
  const query_1 = require("@fibery/query-utils/src/query");
5
- const common_1 = require("../unit-utils/common");
6
5
  const can_edit_field_1 = require("../unit-utils/can-edit-field");
6
+ const common_1 = require("../unit-utils/common");
7
7
  const get_field_label_1 = require("../unit-utils/get-field-label");
8
8
  const type = "color-input";
9
9
  exports.ColorInput = {
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const CommentsList: UnitDataDefinition<FieldUnit>;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommentsList = void 0;
4
4
  const utils_1 = require("@fibery/expression-utils/src/utils");
5
5
  const comments_1 = require("../field-utils/comments");
6
+ const can_edit_field_1 = require("../unit-utils/can-edit-field");
6
7
  const common_1 = require("../unit-utils/common");
7
8
  const get_export_value_1 = require("../unit-utils/get-export-value");
8
- const can_edit_field_1 = require("../unit-utils/can-edit-field");
9
9
  const get_field_label_1 = require("../unit-utils/get-field-label");
10
10
  const type = "comments-list";
11
11
  exports.CommentsList = {
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const DateRangeCombobox: UnitDataDefinition<FieldUnit>;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DateRangeCombobox = void 0;
4
4
  const query_1 = require("@fibery/query-utils/src/query");
5
+ const can_edit_field_1 = require("../unit-utils/can-edit-field");
5
6
  const common_1 = require("../unit-utils/common");
6
7
  const get_export_value_1 = require("../unit-utils/get-export-value");
7
8
  const get_field_label_1 = require("../unit-utils/get-field-label");
8
- const can_edit_field_1 = require("../unit-utils/can-edit-field");
9
9
  const type = "date-range-combobox";
10
10
  exports.DateRangeCombobox = {
11
11
  type,
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const DateRange: UnitDataDefinition<FieldUnit>;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DateRange = void 0;
4
4
  const query_1 = require("@fibery/query-utils/src/query");
5
+ const can_edit_field_1 = require("../unit-utils/can-edit-field");
5
6
  const common_1 = require("../unit-utils/common");
6
7
  const get_export_value_1 = require("../unit-utils/get-export-value");
7
- const can_edit_field_1 = require("../unit-utils/can-edit-field");
8
8
  const get_field_label_1 = require("../unit-utils/get-field-label");
9
9
  const type = "date-range";
10
10
  exports.DateRange = {
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const DateTimeCombobox: UnitDataDefinition<FieldUnit>;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DateTimeCombobox = void 0;
4
4
  const query_1 = require("@fibery/query-utils/src/query");
5
+ const can_edit_field_1 = require("../unit-utils/can-edit-field");
5
6
  const common_1 = require("../unit-utils/common");
6
- const get_field_label_1 = require("../unit-utils/get-field-label");
7
7
  const get_export_value_1 = require("../unit-utils/get-export-value");
8
- const can_edit_field_1 = require("../unit-utils/can-edit-field");
8
+ const get_field_label_1 = require("../unit-utils/get-field-label");
9
9
  const type = "date-time-combobox";
10
10
  exports.DateTimeCombobox = {
11
11
  type,
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const Date: UnitDataDefinition<FieldUnit>;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Date = void 0;
4
4
  const query_1 = require("@fibery/query-utils/src/query");
5
- const common_1 = require("../unit-utils/common");
6
5
  const can_edit_field_1 = require("../unit-utils/can-edit-field");
7
- const get_field_label_1 = require("../unit-utils/get-field-label");
6
+ const common_1 = require("../unit-utils/common");
8
7
  const get_export_value_1 = require("../unit-utils/get-export-value");
8
+ const get_field_label_1 = require("../unit-utils/get-field-label");
9
9
  const type = "date";
10
10
  exports.Date = {
11
11
  type,
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const EmailInput: UnitDataDefinition<FieldUnit>;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EmailInput = void 0;
4
- const text_input_1 = require("./text-input");
5
4
  const common_1 = require("../unit-utils/common");
5
+ const text_input_1 = require("./text-input");
6
6
  const type = "email-input";
7
7
  exports.EmailInput = {
8
8
  ...text_input_1.TextInput,
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const Email: UnitDataDefinition<FieldUnit>;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Email = void 0;
4
- const text_1 = require("./text");
5
4
  const common_1 = require("../unit-utils/common");
5
+ const text_1 = require("./text");
6
6
  const type = "email";
7
7
  exports.Email = {
8
8
  type,
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const Emoji: UnitDataDefinition<FieldUnit>;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Emoji = void 0;
4
- const text_1 = require("./text");
5
4
  const common_1 = require("../unit-utils/common");
5
+ const text_1 = require("./text");
6
6
  const type = "emoji";
7
7
  exports.Emoji = {
8
8
  type,
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const FileCollectionCount: UnitDataDefinition<FieldUnit>;
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileCollectionCount = void 0;
4
4
  const utils_1 = require("@fibery/expression-utils/src/utils");
5
+ const select_1 = require("@fibery/query-utils/src/select");
5
6
  const file_1 = require("../field-utils/file");
6
- const common_1 = require("../unit-utils/common");
7
7
  const can_edit_field_1 = require("../unit-utils/can-edit-field");
8
- const get_field_label_1 = require("../unit-utils/get-field-label");
8
+ const common_1 = require("../unit-utils/common");
9
9
  const get_export_value_1 = require("../unit-utils/get-export-value");
10
+ const get_field_label_1 = require("../unit-utils/get-field-label");
11
+ const wrap_normalized_in_expression_1 = require("../unit-utils/wrap-normalized-in-expression");
10
12
  const type = "file-collection-count";
11
13
  exports.FileCollectionCount = {
12
14
  type,
@@ -16,14 +18,14 @@ exports.FileCollectionCount = {
16
18
  calculateErrors: common_1.calculateUnitExpressionErrors,
17
19
  makeUnit: (0, common_1.makeUnitMethod)(type),
18
20
  getQuerySelect({ typeObject, unit: { expression } }) {
19
- const fieldObject = (0, utils_1.getFieldObjectByFieldExpression)({ typeObject, expression });
20
- return {
21
- [fieldObject.name]: {
22
- "q/from": [fieldObject.name],
23
- "q/limit": "q/no-limit",
24
- "q/select": (0, file_1.getFilesSelect)(fieldObject),
25
- },
21
+ const fieldObjects = (0, utils_1.getFieldObjectsByFieldExpression)({ typeObject, expression });
22
+ const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
23
+ const collectionNormalized = {
24
+ "q/from": null,
25
+ "q/limit": "q/no-limit",
26
+ "q/select": (0, select_1.normalizeSelect)((0, file_1.getFilesSelect)(terminalFieldObject)),
26
27
  };
28
+ return (0, select_1.denormalizeSelect)((0, wrap_normalized_in_expression_1.wrapNormalizedInExpression)(collectionNormalized, fieldObjects, expression));
27
29
  },
28
30
  getExportValue: get_export_value_1.getExportValue,
29
31
  canExport: () => true,
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const FileCompactCollection: UnitDataDefinition<FieldUnit>;
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileCompactCollection = void 0;
4
4
  const utils_1 = require("@fibery/expression-utils/src/utils");
5
+ const select_1 = require("@fibery/query-utils/src/select");
5
6
  const file_1 = require("../field-utils/file");
7
+ const can_edit_field_1 = require("../unit-utils/can-edit-field");
6
8
  const common_1 = require("../unit-utils/common");
7
- const get_field_label_1 = require("../unit-utils/get-field-label");
8
9
  const get_export_value_1 = require("../unit-utils/get-export-value");
9
- const can_edit_field_1 = require("../unit-utils/can-edit-field");
10
+ const get_field_label_1 = require("../unit-utils/get-field-label");
11
+ const wrap_normalized_in_expression_1 = require("../unit-utils/wrap-normalized-in-expression");
10
12
  const type = "file-compact-collection";
11
13
  exports.FileCompactCollection = {
12
14
  type,
@@ -16,14 +18,14 @@ exports.FileCompactCollection = {
16
18
  calculateErrors: common_1.calculateUnitExpressionErrors,
17
19
  makeUnit: (0, common_1.makeUnitMethod)(type),
18
20
  getQuerySelect({ typeObject, unit: { expression } }) {
19
- const fieldObject = (0, utils_1.getFieldObjectByFieldExpression)({ typeObject, expression });
20
- return {
21
- [fieldObject.name]: {
22
- "q/from": [fieldObject.name],
23
- "q/limit": "q/no-limit",
24
- "q/select": (0, file_1.getFilesSelect)(fieldObject),
25
- },
21
+ const fieldObjects = (0, utils_1.getFieldObjectsByFieldExpression)({ typeObject, expression });
22
+ const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
23
+ const collectionNormalized = {
24
+ "q/from": null,
25
+ "q/limit": "q/no-limit",
26
+ "q/select": (0, select_1.normalizeSelect)((0, file_1.getFilesSelect)(terminalFieldObject)),
26
27
  };
28
+ return (0, select_1.denormalizeSelect)((0, wrap_normalized_in_expression_1.wrapNormalizedInExpression)(collectionNormalized, fieldObjects, expression));
27
29
  },
28
30
  getExportValue: get_export_value_1.getExportValue,
29
31
  canExport: () => true,
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const FileCompactReference: UnitDataDefinition<FieldUnit>;
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileCompactReference = void 0;
4
- const select_1 = require("@fibery/query-utils/src/select");
5
4
  const utils_1 = require("@fibery/expression-utils/src/utils");
5
+ const select_1 = require("@fibery/query-utils/src/select");
6
6
  const reference_1 = require("../field-utils/reference");
7
7
  const common_1 = require("../unit-utils/common");
8
8
  const get_export_value_1 = require("../unit-utils/get-export-value");
9
9
  const get_field_label_1 = require("../unit-utils/get-field-label");
10
+ const wrap_normalized_in_expression_1 = require("../unit-utils/wrap-normalized-in-expression");
10
11
  const type = "file-compact-reference";
11
12
  exports.FileCompactReference = {
12
13
  type,
@@ -23,17 +24,7 @@ exports.FileCompactReference = {
23
24
  const fieldObjects = (0, utils_1.getFieldObjectsByFieldExpression)({ typeObject, expression });
24
25
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
25
26
  const innerNormalized = (0, reference_1.getReferenceFieldNormalizedSelectClause)(terminalFieldObject, expression);
26
- const nested = [...expression].reverse().reduce((inner, field, reversedIndex) => {
27
- const originalIndex = expression.length - 1 - reversedIndex;
28
- const isTerminal = originalIndex === expression.length - 1;
29
- if (!isTerminal) {
30
- const { idField } = fieldObjects[originalIndex].typeObject;
31
- const innerWithId = idField ? { [idField]: idField, ...inner } : inner;
32
- return { [field]: innerWithId };
33
- }
34
- return { [field]: inner };
35
- }, innerNormalized);
36
- return (0, select_1.denormalizeSelect)(nested);
27
+ return (0, select_1.denormalizeSelect)((0, wrap_normalized_in_expression_1.wrapNormalizedInExpression)(innerNormalized, fieldObjects, expression));
37
28
  },
38
29
  calculateErrors({ typeObject, unit }) {
39
30
  return (0, common_1.calculateUnitExpressionErrors)({ typeObject, unit });
@@ -1,2 +1,2 @@
1
- import { FieldUnit, UnitDataDefinition } from "../units/types";
1
+ import type { FieldUnit, UnitDataDefinition } from "../units/types";
2
2
  export declare const FileReference: UnitDataDefinition<FieldUnit>;