@fibery/views 18.0.4 → 19.0.1

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 (63) hide show
  1. package/lib/src/field-utils/reference-collection.d.ts +5 -10
  2. package/lib/src/field-utils/reference-collection.js +41 -19
  3. package/lib/src/field-utils/rich-text.d.ts +5 -4
  4. package/lib/src/field-utils/rich-text.js +22 -11
  5. package/lib/src/index.d.ts +28 -16
  6. package/lib/src/index.js +1 -1
  7. package/lib/src/private/board.d.ts +15 -11
  8. package/lib/src/private/board.js +8 -7
  9. package/lib/src/private/calendar.d.ts +14 -10
  10. package/lib/src/private/calendar.js +4 -3
  11. package/lib/src/private/feed.d.ts +14 -10
  12. package/lib/src/private/feed.js +4 -3
  13. package/lib/src/private/form.d.ts +25 -3
  14. package/lib/src/private/form.js +3 -3
  15. package/lib/src/private/map.d.ts +14 -10
  16. package/lib/src/private/map.js +4 -3
  17. package/lib/src/private/smart-folder.d.ts +23 -15
  18. package/lib/src/private/smart-folder.js +16 -13
  19. package/lib/src/private/timeline.d.ts +39 -10
  20. package/lib/src/private/timeline.js +8 -6
  21. package/lib/src/private/units.d.ts +10 -6
  22. package/lib/src/private/units.js +43 -22
  23. package/lib/src/private/utils.d.ts +64 -17
  24. package/lib/src/private/utils.js +26 -20
  25. package/lib/src/truthy.d.ts +1 -0
  26. package/lib/src/truthy.js +7 -0
  27. package/lib/src/unit-definitions/avatar-collection.js +24 -19
  28. package/lib/src/unit-definitions/avatar.js +23 -15
  29. package/lib/src/unit-definitions/collection-count.js +7 -7
  30. package/lib/src/unit-definitions/file-collection-count.js +9 -7
  31. package/lib/src/unit-definitions/file-compact-collection.js +9 -7
  32. package/lib/src/unit-definitions/file-compact-reference.js +5 -4
  33. package/lib/src/unit-definitions/file-reference.js +6 -4
  34. package/lib/src/unit-definitions/files-gallery.js +9 -7
  35. package/lib/src/unit-definitions/files-l-list-item.js +6 -4
  36. package/lib/src/unit-definitions/files-l-list.js +9 -7
  37. package/lib/src/unit-definitions/files-list-item.js +6 -4
  38. package/lib/src/unit-definitions/files-list.js +9 -7
  39. package/lib/src/unit-definitions/number.js +2 -4
  40. package/lib/src/unit-definitions/progress-bar.js +1 -4
  41. package/lib/src/unit-definitions/reference-collection.js +4 -3
  42. package/lib/src/unit-definitions/reference.js +17 -5
  43. package/lib/src/unit-definitions/rich-text-snippet.d.ts +1 -0
  44. package/lib/src/unit-definitions/rich-text-snippet.js +6 -11
  45. package/lib/src/unit-utils/decimal.js +10 -6
  46. package/lib/src/unit-utils/get-export-value.d.ts +1 -1
  47. package/lib/src/unit-utils/get-export-value.js +2 -1
  48. package/lib/src/unit-utils/get-field-label.js +2 -2
  49. package/lib/src/unit-utils/wrap-normalized-in-expression.d.ts +3 -0
  50. package/lib/src/unit-utils/wrap-normalized-in-expression.js +14 -0
  51. package/lib/src/units/board.d.ts +6 -3
  52. package/lib/src/units/canvas/index.d.ts +6 -3
  53. package/lib/src/units/default.d.ts +6 -3
  54. package/lib/src/units/gantt.d.ts +6 -3
  55. package/lib/src/units/grid.d.ts +6 -3
  56. package/lib/src/units/grid.js +4 -0
  57. package/lib/src/units/list.d.ts +6 -3
  58. package/lib/src/units/make-factory.d.ts +10 -9
  59. package/lib/src/units/make-factory.js +26 -10
  60. package/lib/src/units/types.d.ts +1 -1
  61. package/package.json +26 -26
  62. package/lib/jest.config.d.ts +0 -2
  63. package/lib/jest.config.js +0 -32
@@ -1,18 +1,13 @@
1
1
  import { FieldObject } from "@fibery/schema";
2
2
  import { QueryLimit } from "@fibery/expression-utils/src/types";
3
3
  export declare const REFERENCE_COLLECTION_LIMIT = 1000;
4
- export declare const makeCollectionCountExpression: (field: string) => (string | string[])[];
4
+ export declare const makeCollectionCountExpression: (field: string | string[]) => (string | string[])[];
5
5
  export declare const getCountKey: (field: string) => string;
6
6
  export declare const getCollectionCountSelect: (field: string) => {
7
7
  [x: string]: (string | string[])[];
8
8
  };
9
- export declare const calculateReferenceCollectionQuery: ({ fieldObject, limit, }: {
10
- fieldObject: FieldObject;
9
+ export declare const calculateReferenceCollectionQuery: ({ fieldObjects, expression, limit, }: {
10
+ fieldObjects: FieldObject[];
11
+ expression: string[];
11
12
  limit: QueryLimit;
12
- }) => {
13
- [x: string]: {
14
- "q/from": string[];
15
- "q/select": any;
16
- "q/limit": QueryLimit;
17
- };
18
- };
13
+ }) => Record<string, unknown>;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.calculateReferenceCollectionQuery = exports.getCollectionCountSelect = exports.getCountKey = exports.makeCollectionCountExpression = exports.REFERENCE_COLLECTION_LIMIT = void 0;
7
+ const last_1 = __importDefault(require("lodash/last"));
7
8
  const compact_1 = __importDefault(require("lodash/compact"));
8
9
  const select_1 = require("@fibery/query-utils/src/select");
9
10
  const dynamic_keys_1 = require("../unit-utils/dynamic-keys");
@@ -13,7 +14,10 @@ const avatar_1 = require("./avatar");
13
14
  const icon_1 = require("./icon");
14
15
  const file_1 = require("./file");
15
16
  exports.REFERENCE_COLLECTION_LIMIT = 1000;
16
- const makeCollectionCountExpression = (field) => ["q/count", [field, "fibery/id"]];
17
+ const makeCollectionCountExpression = (field) => [
18
+ "q/count",
19
+ [...(Array.isArray(field) ? field : [field]), "fibery/id"],
20
+ ];
17
21
  exports.makeCollectionCountExpression = makeCollectionCountExpression;
18
22
  const getCountKey = (field) => (0, dynamic_keys_1.makeDynamicKey)(dynamic_keys_1.collectionCountKeyPrefix, field);
19
23
  exports.getCountKey = getCountKey;
@@ -21,25 +25,43 @@ const getCollectionCountSelect = (field) => ({
21
25
  [(0, exports.getCountKey)(field)]: (0, exports.makeCollectionCountExpression)(field),
22
26
  });
23
27
  exports.getCollectionCountSelect = getCollectionCountSelect;
24
- const calculateReferenceCollectionQuery = ({ fieldObject, limit, }) => {
25
- return {
26
- [fieldObject.name]: {
27
- "q/from": [fieldObject.name],
28
- "q/select": (0, select_1.mergeDenormalizedSelects)((0, compact_1.default)([
29
- (0, select_1.toSelectMapClause)((0, compact_1.default)([
30
- fieldObject.typeObject.idField,
31
- fieldObject.typeObject.titleField,
32
- // keep public id - required to build Links
33
- fieldObject.typeObject.publicIdField,
34
- ])),
35
- (0, access_1.generateAccessCheckQueryExpression)({ typeObject: fieldObject.typeObject }),
36
- (0, avatar_1.getAvatarSelectQuery)({ typeObject: fieldObject.typeObject }),
37
- (0, icon_1.getEntityIconSelect)({ typeObject: fieldObject.typeObject }),
38
- fieldObject.type === "fibery/file" && (0, file_1.getFilesSelect)(fieldObject),
39
- (0, enums_1.getEnumIconColorQuery)({ typeObject: fieldObject.typeObject }),
28
+ const calculateReferenceCollectionQuery = ({ fieldObjects, expression, limit, }) => {
29
+ const fieldObject = (0, last_1.default)(fieldObjects);
30
+ if (!fieldObject) {
31
+ return {};
32
+ }
33
+ const collectionSubQuery = {
34
+ "q/from": expression,
35
+ "q/select": (0, select_1.mergeDenormalizedSelects)((0, compact_1.default)([
36
+ (0, select_1.toSelectMapClause)((0, compact_1.default)([
37
+ fieldObject.typeObject.idField,
38
+ fieldObject.typeObject.titleField,
39
+ // keep public id - required to build Links
40
+ fieldObject.typeObject.publicIdField,
40
41
  ])),
41
- "q/limit": limit,
42
- },
42
+ (0, access_1.generateAccessCheckQueryExpression)({ typeObject: fieldObject.typeObject }),
43
+ (0, avatar_1.getAvatarSelectQuery)({ typeObject: fieldObject.typeObject }),
44
+ (0, icon_1.getEntityIconSelect)({ typeObject: fieldObject.typeObject }),
45
+ fieldObject.type === "fibery/file" && (0, file_1.getFilesSelect)(fieldObject),
46
+ (0, enums_1.getEnumIconColorQuery)({ typeObject: fieldObject.typeObject }),
47
+ ])),
48
+ "q/limit": limit,
43
49
  };
50
+ // Wrap the collection query in intermediate reference fields (innermost to outermost).
51
+ // For each intermediate field, include its entity's id so normalizr can normalize it.
52
+ return [...expression].reverse().reduce((inner, field, reversedIndex) => {
53
+ const originalIndex = expression.length - 1 - reversedIndex;
54
+ const isTerminal = originalIndex === expression.length - 1;
55
+ if (!isTerminal) {
56
+ const pathToField = expression.slice(0, originalIndex + 1);
57
+ const { idField } = fieldObjects[originalIndex].typeObject;
58
+ // `inner` already has the next field keyed, so spread it rather than re-keying it.
59
+ const innerForField = idField
60
+ ? { [idField]: [...pathToField, idField], ...inner }
61
+ : { ...inner };
62
+ return { [field]: innerForField };
63
+ }
64
+ return { [field]: inner };
65
+ }, collectionSubQuery);
44
66
  };
45
67
  exports.calculateReferenceCollectionQuery = calculateReferenceCollectionQuery;
@@ -1,9 +1,10 @@
1
- import { FieldObject, TypeObject } from "@fibery/schema";
1
+ import { TypeObject } from "@fibery/schema";
2
+ import type { FieldExpression } from "@fibery/expression-utils/src/types";
2
3
  import { FieldUnit } from "../units/types";
3
4
  export declare const hasAccessToSecretKey: string;
4
- export declare const getHasAccessToSecretExpr: (fieldObject: FieldObject) => (string | string[])[];
5
- export declare const getHasAccessToSecret: (fieldObject: FieldObject) => {
6
- [hasAccessToSecretKey]: (string | string[])[];
5
+ export declare const getHasAccessToSecretExpr: (expression: FieldExpression) => (string | (string | import("@fibery/expression-utils/src/types").MultiFieldAccess)[])[];
6
+ export declare const getHasAccessToSecret: (expression: FieldExpression) => {
7
+ [hasAccessToSecretKey]: (string | (string | import("@fibery/expression-utils/src/types").MultiFieldAccess)[])[];
7
8
  };
8
9
  export declare function getRichTextQuerySelect({ typeObject, unit: { expression }, includeSnippet, }: {
9
10
  typeObject: TypeObject;
@@ -6,22 +6,33 @@ const select_1 = require("@fibery/query-utils/src/select");
6
6
  const utils_1 = require("@fibery/expression-utils/src/utils");
7
7
  const dynamic_keys_1 = require("../unit-utils/dynamic-keys");
8
8
  exports.hasAccessToSecretKey = (0, dynamic_keys_1.makeDynamicKey)(dynamic_keys_1.hasAccessToSecretKeyPrefix);
9
- const getHasAccessToSecretExpr = (fieldObject) => [
9
+ const getHasAccessToSecretExpr = (expression) => [
10
10
  "q/access?",
11
- [fieldObject.name, "Collaboration~Documents/secret"],
11
+ [...expression, "Collaboration~Documents/secret"],
12
12
  ];
13
13
  exports.getHasAccessToSecretExpr = getHasAccessToSecretExpr;
14
- const getHasAccessToSecret = (fieldObject) => ({
15
- [exports.hasAccessToSecretKey]: (0, exports.getHasAccessToSecretExpr)(fieldObject),
14
+ const getHasAccessToSecret = (expression) => ({
15
+ [exports.hasAccessToSecretKey]: (0, exports.getHasAccessToSecretExpr)(expression),
16
16
  });
17
17
  exports.getHasAccessToSecret = getHasAccessToSecret;
18
18
  function getRichTextQuerySelect({ typeObject, unit: { expression }, includeSnippet, }) {
19
- const fieldObject = (0, utils_1.getFieldObjectByFieldExpression)({ typeObject, expression });
20
- return (0, select_1.denormalizeSelect)({
21
- [fieldObject.name]: (0, select_1.normalizeSelect)({
22
- ...(0, exports.getHasAccessToSecret)(fieldObject),
23
- ...(0, select_1.toSelectMapClause)([typeObject.idField, "Collaboration~Documents/secret"]),
24
- ...(includeSnippet ? (0, select_1.toSelectMapClause)([typeObject.idField, "Collaboration~Documents/Snippet"]) : {}),
25
- }),
19
+ const fieldObjects = (0, utils_1.getFieldObjectsByFieldExpression)({ typeObject, expression });
20
+ const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
21
+ const { typeObject: terminalTypeObject } = terminalFieldObject;
22
+ const innerNormalized = (0, select_1.normalizeSelect)({
23
+ ...(0, exports.getHasAccessToSecret)(expression),
24
+ ...(0, select_1.toSelectMapClause)([terminalTypeObject.idField, "Collaboration~Documents/secret"]),
25
+ ...(includeSnippet ? (0, select_1.toSelectMapClause)([terminalTypeObject.idField, "Collaboration~Documents/Snippet"]) : {}),
26
26
  });
27
+ const nested = [...expression].reverse().reduce((inner, field, reversedIndex) => {
28
+ const originalIndex = expression.length - 1 - reversedIndex;
29
+ const isTerminal = originalIndex === expression.length - 1;
30
+ if (!isTerminal) {
31
+ const { idField } = fieldObjects[originalIndex].typeObject;
32
+ const innerWithId = idField ? { [idField]: idField, ...inner } : inner;
33
+ return { [field]: innerWithId };
34
+ }
35
+ return { [field]: inner };
36
+ }, innerNormalized);
37
+ return (0, select_1.denormalizeSelect)(nested);
27
38
  }
@@ -1,16 +1,28 @@
1
- export function deleteExpressionWithNotFoundFieldsOrTypesInView(schema: any, view: any, ensureAxisInvariant?: boolean): any;
2
- export function fixUserSelectedUnits(schema: any, view: any, { unitDefinitions, getDefaultUnitTypeForField }: {
3
- unitDefinitions: any;
4
- getDefaultUnitTypeForField: any;
5
- }): any;
6
- export function fixContextExpressionWithBrokenPath(schema: any, view: any, defaultContextExpression: any): any;
7
- export function collectGarbage(schema: any, view: any): any;
8
- export function replaceNamesWithIdsInView(schema: any, view: any): any;
9
- export function replaceIdsWithNamesInView(schema: any, view: any): any;
10
- export function getViewCardTypes({ "fibery/meta": { items } }: {
11
- "fibery/meta": {
12
- items: any;
13
- };
14
- }): any;
15
- export function migrateHideWhenEmptyToUnitsLevel(view: any): any;
16
- export { deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder, replaceIdsWithNamesInSmartFolder, replaceNamesWithIdsInSmartFolder } from "./private/smart-folder";
1
+ import type { Expression } from "@fibery/expression-utils/src/types";
2
+ import type { FieldObject, Schema } from "@fibery/schema";
3
+ import type { UnitDefinitions, ViewRecord } from "./private/utils";
4
+ import type { Unit } from "./units/types";
5
+ export { deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder, replaceIdsWithNamesInSmartFolder, replaceNamesWithIdsInSmartFolder, } from "./private/smart-folder";
6
+ export declare const deleteExpressionWithNotFoundFieldsOrTypesInView: (schema: Schema, view: ViewRecord, ensureAxisInvariant?: boolean) => any;
7
+ export declare const fixUserSelectedUnits: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
8
+ unitDefinitions: UnitDefinitions;
9
+ getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
10
+ }) => any;
11
+ export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
12
+ /**
13
+ * Removes garbage from view's meta to reduce the size.
14
+ */
15
+ export declare const collectGarbage: (schema: Schema, view: ViewRecord) => unknown;
16
+ export declare const replaceNamesWithIdsInView: (schema: Schema, view: ViewRecord) => any;
17
+ export declare const replaceIdsWithNamesInView: (schema: Schema, view: ViewRecord) => any;
18
+ type ViewMeta = {
19
+ items: {
20
+ query: {
21
+ "q/from": string;
22
+ };
23
+ }[];
24
+ };
25
+ export declare const getViewCardTypes: ({ "fibery/meta": { items } }: {
26
+ "fibery/meta": ViewMeta;
27
+ }) => string[];
28
+ export declare const migrateHideWhenEmptyToUnitsLevel: (view: ViewRecord) => any;
package/lib/src/index.js CHANGED
@@ -80,7 +80,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInView = (schema, view, ensureAxi
80
80
  }
81
81
  };
82
82
  exports.deleteExpressionWithNotFoundFieldsOrTypesInView = deleteExpressionWithNotFoundFieldsOrTypesInView;
83
- const fixUserSelectedUnits = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
83
+ const fixUserSelectedUnits = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
84
84
  switch (view["fibery/type"]) {
85
85
  case "board":
86
86
  case "gallery":
@@ -1,11 +1,15 @@
1
- export function replaceIdsWithNamesInBoardView(schema: any, view: any): any;
2
- export function replaceNamesWithIdsInBoardView(schema: any, view: any): any;
3
- export function deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView(schema: any, view: any, ensureAxisInvariant?: boolean): any;
4
- export function fixUserSelectedUnitsInBoardView(schema: any, view: any, { unitDefinitions, getDefaultUnitTypeForField }: {
5
- unitDefinitions: any;
6
- getDefaultUnitTypeForField: any;
7
- }): any;
8
- export function fixContextExpressionWithBrokenPath(schema: any, view: any, defaultContextExpression: any): any;
9
- export function collectGarbage(view: any): any;
10
- export function enableHideWhenEmptyForCovers(view: any): any;
11
- export function enableHideWhenEmptyForCheckedEditableUnits(view: any): any;
1
+ import type { Expression } from "@fibery/expression-utils/src/types";
2
+ import type { FieldObject, Schema } from "@fibery/schema";
3
+ import type { UnitDefinitions, ViewRecord } from "./utils";
4
+ import { Unit } from "@fibery/views/src/units/types";
5
+ export declare const replaceIdsWithNamesInBoardView: (schema: Schema, view: ViewRecord) => any;
6
+ export declare const replaceNamesWithIdsInBoardView: (schema: Schema, view: ViewRecord) => any;
7
+ export declare const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView: (schema: Schema, view: ViewRecord, ensureAxisInvariant?: boolean) => any;
8
+ export declare const fixUserSelectedUnitsInBoardView: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
9
+ unitDefinitions: UnitDefinitions;
10
+ getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
11
+ }) => any;
12
+ export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
13
+ export declare const collectGarbage: (view: ViewRecord) => any;
14
+ export declare const enableHideWhenEmptyForCovers: (view: ViewRecord) => any;
15
+ export declare const enableHideWhenEmptyForCheckedEditableUnits: (view: ViewRecord) => any;
@@ -11,6 +11,7 @@ const get_1 = __importDefault(require("lodash/get"));
11
11
  const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
12
12
  const set_1 = __importDefault(require("lodash/set"));
13
13
  const some_1 = __importDefault(require("lodash/some"));
14
+ const truthy_1 = require("../truthy");
14
15
  const units_1 = require("./units");
15
16
  const utils_2 = require("./utils");
16
17
  const visitQueryExpressionHolder = (queryHolder, visitor) => {
@@ -49,11 +50,11 @@ const visitAxisUnits = (axis, fromType, visitor) => {
49
50
  units: {
50
51
  $apply: (units) => units
51
52
  ? units
52
- .filter((unit) => Boolean(unit))
53
+ .filter(truthy_1.truthy)
53
54
  .map((unit) => (0, utils_2.visitViewUnit)(fromType, unit, visitor))
54
- .filter((unit) => (0, utils_2.isUnitExpressionValid)(unit))
55
+ .filter(utils_2.isUnitExpressionValid)
55
56
  .map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
56
- .filter((unit) => unit !== utils_2.REMOVE)
57
+ .filter(utils_2.skipRemove)
57
58
  : undefined,
58
59
  },
59
60
  })
@@ -161,9 +162,9 @@ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
161
162
  units: {
162
163
  $apply: (units) => units
163
164
  ? units
164
- .filter((unit) => Boolean(unit))
165
+ .filter(truthy_1.truthy)
165
166
  .map((unit) => (0, utils_2.visitViewUnit)(fromType, unit, visitor))
166
- .filter((unit) => (0, utils_2.isUnitExpressionValid)(unit))
167
+ .filter(utils_2.isUnitExpressionValid)
167
168
  .map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
168
169
  .filter((unit) => unit !== utils_2.REMOVE)
169
170
  : undefined,
@@ -255,7 +256,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = (schema) => {
255
256
  };
256
257
  return visitor;
257
258
  };
258
- const fixUserSelectedUnitsViewVisitor = (schema, { unitDefinitions, getDefaultUnitTypeForField }) => {
259
+ const fixUserSelectedUnitsViewVisitor = (schema, { unitDefinitions, getDefaultUnitTypeForField, }) => {
259
260
  return {
260
261
  visitQueryExpression: (queryExpression) => queryExpression,
261
262
  visitFilter: (_fromType, filter) => filter,
@@ -273,7 +274,7 @@ const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = (schema, v
273
274
  return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant(viewNew) : viewNew;
274
275
  };
275
276
  exports.deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView;
276
- const fixUserSelectedUnitsInBoardView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
277
+ const fixUserSelectedUnitsInBoardView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
277
278
  return visitView(view, fixUserSelectedUnitsViewVisitor(schema, { unitDefinitions, getDefaultUnitTypeForField }));
278
279
  };
279
280
  exports.fixUserSelectedUnitsInBoardView = fixUserSelectedUnitsInBoardView;
@@ -1,10 +1,14 @@
1
- export function replaceNamesWithIdsInCalendarView(schema: any, view: any): any;
2
- export function replaceIdsWithNamesInCalendarView(schema: any, view: any): any;
3
- export function deleteExpressionWithNotFoundFieldsOrTypesInCalendarView(schema: any, view: any): any;
4
- export function fixUserSelectedUnitsInCalendarView(schema: any, view: any, { unitDefinitions, getDefaultUnitTypeForField }: {
5
- unitDefinitions: any;
6
- getDefaultUnitTypeForField: any;
7
- }): any;
8
- export function fixContextExpressionWithBrokenPath(schema: any, view: any, defaultContextExpression: any): any;
9
- export function collectGarbage(view: any): any;
10
- export function enableHideWhenEmptyForCheckedUnits(view: any): any;
1
+ import type { Expression } from "@fibery/expression-utils/src/types";
2
+ import type { FieldObject, Schema } from "@fibery/schema";
3
+ import type { UnitDefinitions, ViewRecord } from "./utils";
4
+ import { Unit } from "@fibery/views/src/units/types";
5
+ export declare const replaceNamesWithIdsInCalendarView: (schema: Schema, view: ViewRecord) => any;
6
+ export declare const replaceIdsWithNamesInCalendarView: (schema: Schema, view: ViewRecord) => any;
7
+ export declare const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView: (schema: Schema, view: ViewRecord) => any;
8
+ export declare const fixUserSelectedUnitsInCalendarView: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
9
+ unitDefinitions: UnitDefinitions;
10
+ getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
11
+ }) => any;
12
+ export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
13
+ export declare const collectGarbage: (view: ViewRecord) => any;
14
+ export declare const enableHideWhenEmptyForCheckedUnits: (view: ViewRecord) => any;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInCalendarView = exports.deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = exports.replaceIdsWithNamesInCalendarView = exports.replaceNamesWithIdsInCalendarView = void 0;
7
7
  const immutability_helper_1 = __importDefault(require("immutability-helper"));
8
8
  const get_1 = __importDefault(require("lodash/get"));
9
+ const truthy_1 = require("../truthy");
9
10
  const units_1 = require("./units");
10
11
  const utils_1 = require("./utils");
11
12
  const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
@@ -34,9 +35,9 @@ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
34
35
  units: {
35
36
  $apply: (units) => units
36
37
  ? units
37
- .filter((unit) => Boolean(unit))
38
+ .filter(truthy_1.truthy)
38
39
  .map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
39
- .filter((unit) => (0, utils_1.isUnitExpressionValid)(unit))
40
+ .filter(utils_1.isUnitExpressionValid)
40
41
  .map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
41
42
  .filter((unit) => unit !== utils_1.REMOVE)
42
43
  : undefined,
@@ -84,7 +85,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) =
84
85
  visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
85
86
  });
86
87
  exports.deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = deleteExpressionWithNotFoundFieldsOrTypesInCalendarView;
87
- const fixUserSelectedUnitsInCalendarView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
88
+ const fixUserSelectedUnitsInCalendarView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
88
89
  return visitView(view, {
89
90
  visitExpression: (_fromType, expression) => expression,
90
91
  visitFilter: (_fromType, filter) => filter,
@@ -1,10 +1,14 @@
1
- export function replaceNamesWithIdsInFeedView(schema: any, view: any): any;
2
- export function replaceIdsWithNamesInFeedView(schema: any, view: any): any;
3
- export function deleteExpressionWithNotFoundFieldsOrTypesInFeedView(schema: any, view: any): any;
4
- export function fixUserSelectedUnitsInFeedView(schema: any, view: any, { unitDefinitions, getDefaultUnitTypeForField }: {
5
- unitDefinitions: any;
6
- getDefaultUnitTypeForField: any;
7
- }): any;
8
- export function fixContextExpressionWithBrokenPath(schema: any, view: any, defaultContextExpression: any): any;
9
- export function collectGarbage(view: any): any;
10
- export function enableHideWhenEmptyForCheckedUnits(view: any): any;
1
+ import type { Expression } from "@fibery/expression-utils/src/types";
2
+ import type { FieldObject, Schema } from "@fibery/schema";
3
+ import type { UnitDefinitions, ViewRecord } from "./utils";
4
+ import { Unit } from "@fibery/views/src/units/types";
5
+ export declare const replaceNamesWithIdsInFeedView: (schema: Schema, view: ViewRecord) => any;
6
+ export declare const replaceIdsWithNamesInFeedView: (schema: Schema, view: ViewRecord) => any;
7
+ export declare const deleteExpressionWithNotFoundFieldsOrTypesInFeedView: (schema: Schema, view: ViewRecord) => any;
8
+ export declare const fixUserSelectedUnitsInFeedView: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
9
+ unitDefinitions: UnitDefinitions;
10
+ getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
11
+ }) => any;
12
+ export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
13
+ export declare const collectGarbage: (view: ViewRecord) => any;
14
+ export declare const enableHideWhenEmptyForCheckedUnits: (view: ViewRecord) => any;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInFeedView = exports.deleteExpressionWithNotFoundFieldsOrTypesInFeedView = exports.replaceIdsWithNamesInFeedView = exports.replaceNamesWithIdsInFeedView = void 0;
7
7
  const immutability_helper_1 = __importDefault(require("immutability-helper"));
8
8
  const get_1 = __importDefault(require("lodash/get"));
9
+ const truthy_1 = require("../truthy");
9
10
  const units_1 = require("./units");
10
11
  const utils_1 = require("./utils");
11
12
  const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
@@ -31,9 +32,9 @@ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
31
32
  units: {
32
33
  $apply: (units) => units
33
34
  ? units
34
- .filter((unit) => Boolean(unit))
35
+ .filter(truthy_1.truthy)
35
36
  .map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
36
- .filter((unit) => (0, utils_1.isUnitExpressionValid)(unit))
37
+ .filter(utils_1.isUnitExpressionValid)
37
38
  .map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
38
39
  .filter((unit) => unit !== utils_1.REMOVE)
39
40
  : undefined,
@@ -81,7 +82,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => vi
81
82
  visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
82
83
  });
83
84
  exports.deleteExpressionWithNotFoundFieldsOrTypesInFeedView = deleteExpressionWithNotFoundFieldsOrTypesInFeedView;
84
- const fixUserSelectedUnitsInFeedView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
85
+ const fixUserSelectedUnitsInFeedView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
85
86
  return visitView(view, {
86
87
  visitExpression: (_fromType, expression) => expression,
87
88
  visitFilter: (_fromType, filter) => filter,
@@ -1,3 +1,25 @@
1
- export function replaceNamesWithIdsInFormView(schema: any, view: any): any;
2
- export function replaceIdsWithNamesInFormView(schema: any, view: any): any;
3
- export function deleteExpressionWithNotFoundFieldsOrTypesInFormView(schema: any, view: any): any;
1
+ import type { Schema } from "@fibery/schema";
2
+ import type { ViewRecord } from "./utils";
3
+ type FormField = {
4
+ id: string;
5
+ [k: string]: unknown;
6
+ };
7
+ export declare const replaceNamesWithIdsInFormView: (schema: Schema, view: ViewRecord) => {
8
+ "fibery/meta": {
9
+ typeId: string | undefined;
10
+ fields: FormField[] | undefined;
11
+ };
12
+ };
13
+ export declare const replaceIdsWithNamesInFormView: (schema: Schema, view: ViewRecord) => {
14
+ "fibery/meta": {
15
+ typeId: string | undefined;
16
+ fields: FormField[] | undefined;
17
+ };
18
+ };
19
+ export declare const deleteExpressionWithNotFoundFieldsOrTypesInFormView: (schema: Schema, view: ViewRecord) => {
20
+ "fibery/meta": {
21
+ typeId: string | undefined;
22
+ fields: FormField[] | undefined;
23
+ };
24
+ };
25
+ export {};
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteExpressionWithNotFoundFieldsOrTypesInFormView = exports.replaceIdsWithNamesInFormView = exports.replaceNamesWithIdsInFormView = void 0;
4
4
  const replaceNamesWithIdsInFormView = (schema, view) => {
5
5
  const typeId = view["fibery/meta"]?.typeId;
6
- const typeObject = Object.hasOwn(schema.typeObjectsByName, typeId) ? schema.typeObjectsByName[typeId] : null;
6
+ const typeObject = typeId && Object.hasOwn(schema.typeObjectsByName, typeId) ? schema.typeObjectsByName[typeId] : null;
7
7
  const fields = view["fibery/meta"]?.fields;
8
8
  const fieldsInIdsTerms = fields &&
9
9
  fields.map((field) => {
@@ -24,7 +24,7 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
24
24
  exports.replaceNamesWithIdsInFormView = replaceNamesWithIdsInFormView;
25
25
  const replaceIdsWithNamesInFormView = (schema, view) => {
26
26
  const typeId = view["fibery/meta"]?.typeId;
27
- const typeObject = Object.hasOwn(schema.typeObjectsById, typeId) ? schema.typeObjectsById[typeId] : null;
27
+ const typeObject = typeId && Object.hasOwn(schema.typeObjectsById, typeId) ? schema.typeObjectsById[typeId] : null;
28
28
  const fields = view["fibery/meta"]?.fields;
29
29
  const fieldsInNameTerms = fields &&
30
30
  fields.map((field) => {
@@ -46,7 +46,7 @@ exports.replaceIdsWithNamesInFormView = replaceIdsWithNamesInFormView;
46
46
  const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
47
47
  // we expect view in names terms here.
48
48
  const typeName = view["fibery/meta"]?.typeId;
49
- const typeObject = Object.hasOwn(schema.typeObjectsByName, typeName) ? schema.typeObjectsByName[typeName] : null;
49
+ const typeObject = typeName && Object.hasOwn(schema.typeObjectsByName, typeName) ? schema.typeObjectsByName[typeName] : null;
50
50
  const fields = view["fibery/meta"]?.fields;
51
51
  const existingFields = fields && fields.filter((field) => typeObject && Object.hasOwn(typeObject.fieldObjectsByName, field.id));
52
52
  return {
@@ -1,10 +1,14 @@
1
- export function replaceNamesWithIdsInMapView(schema: any, view: any): any;
2
- export function replaceIdsWithNamesInMapView(schema: any, view: any): any;
3
- export function deleteExpressionWithNotFoundFieldsOrTypesInMapView(schema: any, view: any): any;
4
- export function fixUserSelectedUnitsInMapView(schema: any, view: any, { unitDefinitions, getDefaultUnitTypeForField }: {
5
- unitDefinitions: any;
6
- getDefaultUnitTypeForField: any;
7
- }): any;
8
- export function fixContextExpressionWithBrokenPath(schema: any, view: any, defaultContextExpression: any): any;
9
- export function collectGarbage(view: any): any;
10
- export function enableHideWhenEmptyForCheckedUnits(view: any): any;
1
+ import type { Expression } from "@fibery/expression-utils/src/types";
2
+ import type { FieldObject, Schema } from "@fibery/schema";
3
+ import type { UnitDefinitions, ViewRecord } from "./utils";
4
+ import { Unit } from "@fibery/views/src/units/types";
5
+ export declare const replaceNamesWithIdsInMapView: (schema: Schema, view: ViewRecord) => any;
6
+ export declare const replaceIdsWithNamesInMapView: (schema: Schema, view: ViewRecord) => any;
7
+ export declare const deleteExpressionWithNotFoundFieldsOrTypesInMapView: (schema: Schema, view: ViewRecord) => any;
8
+ export declare const fixUserSelectedUnitsInMapView: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
9
+ unitDefinitions: UnitDefinitions;
10
+ getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
11
+ }) => any;
12
+ export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
13
+ export declare const collectGarbage: (view: ViewRecord) => any;
14
+ export declare const enableHideWhenEmptyForCheckedUnits: (view: ViewRecord) => any;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInMapView = exports.deleteExpressionWithNotFoundFieldsOrTypesInMapView = exports.replaceIdsWithNamesInMapView = exports.replaceNamesWithIdsInMapView = void 0;
7
7
  const immutability_helper_1 = __importDefault(require("immutability-helper"));
8
8
  const get_1 = __importDefault(require("lodash/get"));
9
+ const truthy_1 = require("../truthy");
9
10
  const units_1 = require("./units");
10
11
  const utils_1 = require("./utils");
11
12
  const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
@@ -31,9 +32,9 @@ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
31
32
  units: {
32
33
  $apply: (units) => units
33
34
  ? units
34
- .filter((unit) => Boolean(unit))
35
+ .filter(truthy_1.truthy)
35
36
  .map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
36
- .filter((unit) => (0, utils_1.isUnitExpressionValid)(unit))
37
+ .filter(utils_1.isUnitExpressionValid)
37
38
  .map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
38
39
  .filter((unit) => unit !== utils_1.REMOVE)
39
40
  : undefined,
@@ -81,7 +82,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInMapView = (schema, view) => vis
81
82
  visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
82
83
  });
83
84
  exports.deleteExpressionWithNotFoundFieldsOrTypesInMapView = deleteExpressionWithNotFoundFieldsOrTypesInMapView;
84
- const fixUserSelectedUnitsInMapView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
85
+ const fixUserSelectedUnitsInMapView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
85
86
  return visitView(view, {
86
87
  visitQueryExpression: (query) => query,
87
88
  visitFilter: (_fromType, filter) => filter,
@@ -1,23 +1,31 @@
1
- export function deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression(schema: any, groupByExpression: any, fromType: any, removedItems: any): {
2
- [k: string]: any;
3
- } | null;
4
- export function replaceIdsWithNamesInGroupByExpression(schema: any, groupByExpression: any, fromType: any): {
1
+ import type { Expression } from "@fibery/expression-utils/src/types";
2
+ import type { FieldObject, Schema } from "@fibery/schema";
3
+ import type { UnitDefinitions, ViewRecord } from "./utils";
4
+ import { Unit } from "@fibery/views/src/units/types";
5
+ type GroupByEntry = {
6
+ expression: Expression;
7
+ [k: string]: unknown;
8
+ };
9
+ type GroupByExpression = Record<string, GroupByEntry>;
10
+ export declare const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression: (schema: Schema, groupByExpression: GroupByExpression | null, fromType: string, removedItems: number[]) => any;
11
+ export declare const replaceIdsWithNamesInGroupByExpression: (schema: Schema, groupByExpression: GroupByExpression | null, fromType: string) => {
5
12
  [k: string]: {
6
13
  expression: any;
7
14
  };
8
15
  } | null;
9
- export function replaceNamesWithIdsInGroupByExpression(schema: any, groupByExpression: any, fromType: any): {
16
+ export declare const replaceNamesWithIdsInGroupByExpression: (schema: Schema, groupByExpression: GroupByExpression | null, fromType: string) => {
10
17
  [k: string]: {
11
18
  expression: any;
12
19
  };
13
20
  } | null;
14
- export function replaceNamesWithIdsInSmartFolder(schema: any, smartFolder: any): any;
15
- export function replaceIdsWithNamesInSmartFolder(schema: any, smartFolder: any): any;
16
- export function deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder(schema: any, smartFolder: any): any;
17
- export function fixContextExpressionWithBrokenPath(schema: any, view: any, defaultContextExpression: any): any;
18
- export function fixUserSelectedUnitsInSmartFolder(schema: any, view: any, { unitDefinitions, getDefaultUnitTypeForField }: {
19
- unitDefinitions: any;
20
- getDefaultUnitTypeForField: any;
21
- }): any;
22
- export function collectGarbage(view: any): any;
23
- export function enableHideWhenEmptyForCheckedUnits(view: any): any;
21
+ export declare const replaceNamesWithIdsInSmartFolder: (schema: Schema, smartFolder: ViewRecord) => any;
22
+ export declare const replaceIdsWithNamesInSmartFolder: (schema: Schema, smartFolder: ViewRecord) => any;
23
+ export declare const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder: (schema: Schema, smartFolder: ViewRecord) => any;
24
+ export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
25
+ export declare const fixUserSelectedUnitsInSmartFolder: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
26
+ unitDefinitions: UnitDefinitions;
27
+ getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
28
+ }) => any;
29
+ export declare const collectGarbage: (view: ViewRecord) => any;
30
+ export declare const enableHideWhenEmptyForCheckedUnits: (view: ViewRecord) => any;
31
+ export {};