@fibery/views 25.1.4 → 26.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/errors.d.ts +2 -3
- package/lib/field-utils/avatar.d.ts +8 -9
- package/lib/field-utils/back-references.d.ts +4 -5
- package/lib/field-utils/comments.d.ts +5 -6
- package/lib/field-utils/date-time.d.ts +7 -8
- package/lib/field-utils/enum-value.d.ts +6 -7
- package/lib/field-utils/file.d.ts +3 -4
- package/lib/field-utils/icon.d.ts +6 -7
- package/lib/field-utils/number.d.ts +11 -12
- package/lib/field-utils/reference-collection.d.ts +6 -7
- package/lib/field-utils/reference.d.ts +3 -4
- package/lib/field-utils/relation-view.d.ts +2 -3
- package/lib/field-utils/rich-text.d.ts +9 -10
- package/lib/field-utils/text.d.ts +9 -10
- package/lib/field-utils/user-active.d.ts +3 -4
- package/lib/field-utils/user-role.d.ts +3 -4
- package/lib/field-utils/workflow.d.ts +9 -10
- package/lib/filter.d.ts +29 -0
- package/lib/filter.js +0 -0
- package/lib/index.d.ts +57 -21
- package/lib/index.js +101 -94
- package/lib/meta-validation.d.ts +3 -4
- package/lib/private/board.d.ts +218 -14
- package/lib/private/board.js +138 -231
- package/lib/private/calendar.d.ts +213 -13
- package/lib/private/calendar.js +35 -81
- package/lib/private/feed.d.ts +211 -13
- package/lib/private/feed.js +34 -80
- package/lib/private/form.d.ts +52 -7
- package/lib/private/form.js +41 -48
- package/lib/private/map.d.ts +211 -13
- package/lib/private/map.js +34 -80
- package/lib/private/smart-folder.d.ts +118 -29
- package/lib/private/smart-folder.js +70 -148
- package/lib/private/timeline.d.ts +535 -31
- package/lib/private/timeline.js +158 -219
- package/lib/private/units.d.ts +3 -4
- package/lib/private/utils.d.ts +63 -57
- package/lib/private/utils.js +71 -49
- package/lib/refs.d.ts +19 -0
- package/lib/refs.js +0 -0
- package/lib/unit-definitions/avatar-collection.d.ts +29 -4
- package/lib/unit-definitions/avatar-collection.js +1 -1
- package/lib/unit-definitions/avatar-input.d.ts +49 -4
- package/lib/unit-definitions/avatar.d.ts +54 -4
- package/lib/unit-definitions/avatar.js +1 -1
- package/lib/unit-definitions/back-references-list.d.ts +31 -4
- package/lib/unit-definitions/back-references-list.js +1 -1
- package/lib/unit-definitions/bool-checkbox.d.ts +23 -4
- package/lib/unit-definitions/bool-checkbox.js +1 -1
- package/lib/unit-definitions/bool.d.ts +23 -4
- package/lib/unit-definitions/bool.js +1 -1
- package/lib/unit-definitions/collection-count.d.ts +31 -4
- package/lib/unit-definitions/color-input.d.ts +22 -4
- package/lib/unit-definitions/color-input.js +1 -1
- package/lib/unit-definitions/comments-list.d.ts +63 -4
- package/lib/unit-definitions/comments-list.js +1 -1
- package/lib/unit-definitions/date-range-combobox.d.ts +23 -4
- package/lib/unit-definitions/date-range-combobox.js +1 -1
- package/lib/unit-definitions/date-range.d.ts +23 -4
- package/lib/unit-definitions/date-range.js +1 -1
- package/lib/unit-definitions/date-time-combobox.d.ts +23 -4
- package/lib/unit-definitions/date-time-combobox.js +1 -1
- package/lib/unit-definitions/date.d.ts +23 -4
- package/lib/unit-definitions/date.js +1 -1
- package/lib/unit-definitions/email-input.d.ts +23 -4
- package/lib/unit-definitions/email.d.ts +23 -4
- package/lib/unit-definitions/emoji.d.ts +23 -4
- package/lib/unit-definitions/file-collection-count.d.ts +23 -4
- package/lib/unit-definitions/file-collection-count.js +1 -1
- package/lib/unit-definitions/file-compact-collection.d.ts +23 -4
- package/lib/unit-definitions/file-compact-collection.js +1 -1
- package/lib/unit-definitions/file-compact-reference.d.ts +27 -4
- package/lib/unit-definitions/file-reference.d.ts +23 -4
- package/lib/unit-definitions/file-reference.js +1 -1
- package/lib/unit-definitions/files-gallery.d.ts +23 -4
- package/lib/unit-definitions/files-gallery.js +1 -1
- package/lib/unit-definitions/files-l-list-item.d.ts +23 -4
- package/lib/unit-definitions/files-l-list-item.js +1 -1
- package/lib/unit-definitions/files-l-list.d.ts +23 -4
- package/lib/unit-definitions/files-l-list.js +1 -1
- package/lib/unit-definitions/files-list-item.d.ts +23 -4
- package/lib/unit-definitions/files-list-item.js +1 -1
- package/lib/unit-definitions/files-list.d.ts +23 -4
- package/lib/unit-definitions/files-list.js +1 -1
- package/lib/unit-definitions/geometry-preview.d.ts +23 -4
- package/lib/unit-definitions/icon-button.d.ts +28 -4
- package/lib/unit-definitions/icon-button.js +1 -1
- package/lib/unit-definitions/icon-input.d.ts +23 -4
- package/lib/unit-definitions/id.d.ts +32 -4
- package/lib/unit-definitions/index.js +2 -2
- package/lib/unit-definitions/json-input.d.ts +22 -4
- package/lib/unit-definitions/json-input.js +1 -1
- package/lib/unit-definitions/location-input.d.ts +23 -4
- package/lib/unit-definitions/location.d.ts +23 -4
- package/lib/unit-definitions/not-found.d.ts +6 -4
- package/lib/unit-definitions/number-input.d.ts +23 -4
- package/lib/unit-definitions/number-input.js +1 -1
- package/lib/unit-definitions/number.d.ts +27 -4
- package/lib/unit-definitions/phone-input.d.ts +23 -4
- package/lib/unit-definitions/phone.d.ts +23 -4
- package/lib/unit-definitions/progress-bar.d.ts +26 -4
- package/lib/unit-definitions/reference-collection-combobox.d.ts +19 -4
- package/lib/unit-definitions/reference-collection-combobox.js +1 -1
- package/lib/unit-definitions/reference-collection-list.d.ts +19 -4
- package/lib/unit-definitions/reference-collection-list.js +1 -1
- package/lib/unit-definitions/reference-collection-view.d.ts +19 -4
- package/lib/unit-definitions/reference-collection-view.js +1 -1
- package/lib/unit-definitions/reference-collection.d.ts +23 -4
- package/lib/unit-definitions/reference-collection.js +1 -1
- package/lib/unit-definitions/reference-combobox.d.ts +19 -4
- package/lib/unit-definitions/reference-combobox.js +1 -1
- package/lib/unit-definitions/reference-icon.d.ts +27 -4
- package/lib/unit-definitions/reference.d.ts +27 -4
- package/lib/unit-definitions/rich-text-document.d.ts +23 -4
- package/lib/unit-definitions/rich-text-document.js +1 -1
- package/lib/unit-definitions/rich-text-snippet.d.ts +25 -5
- package/lib/unit-definitions/single-location-preview.d.ts +23 -4
- package/lib/unit-definitions/text-input.d.ts +23 -4
- package/lib/unit-definitions/text-input.js +1 -1
- package/lib/unit-definitions/text.d.ts +23 -4
- package/lib/unit-definitions/text.js +1 -1
- package/lib/unit-definitions/title-input.d.ts +24 -4
- package/lib/unit-definitions/title.d.ts +27 -4
- package/lib/unit-definitions/type-badge-abbr.d.ts +15 -4
- package/lib/unit-definitions/type-badge.d.ts +15 -4
- package/lib/unit-definitions/type-icon.d.ts +15 -4
- package/lib/unit-definitions/url-input.d.ts +23 -4
- package/lib/unit-definitions/url.d.ts +23 -4
- package/lib/unit-definitions/user-button.d.ts +13 -4
- package/lib/unit-definitions/user-role-input.d.ts +26 -4
- package/lib/unit-definitions/user-role.d.ts +27 -4
- package/lib/unit-definitions/user-role.js +1 -1
- package/lib/unit-utils/access.d.ts +4 -5
- package/lib/unit-utils/can-edit-field.d.ts +4 -5
- package/lib/unit-utils/common.d.ts +16 -11
- package/lib/unit-utils/decimal.js +4 -4
- package/lib/unit-utils/dynamic-keys.d.ts +8 -9
- package/lib/unit-utils/enums.d.ts +4 -5
- package/lib/unit-utils/formatters.d.ts +15 -16
- package/lib/unit-utils/get-export-value.d.ts +18 -19
- package/lib/unit-utils/get-field-label.d.ts +4 -5
- package/lib/unit-utils/get-unmatched-unit-label.d.ts +2 -3
- package/lib/unit-utils/wrap-normalized-in-expression.d.ts +2 -3
- package/lib/units/board.d.ts +22 -25
- package/lib/units/board.js +2 -1
- package/lib/units/canvas/all-units-data-definitions.js +1 -1
- package/lib/units/canvas/index.d.ts +19 -24
- package/lib/units/canvas/type-badge-abbr.d.ts +13 -35
- package/lib/units/canvas/type-badge.d.ts +13 -35
- package/lib/units/default.d.ts +21 -22
- package/lib/units/default.js +2 -1
- package/lib/units/gallery.d.ts +5 -3
- package/lib/units/gantt.d.ts +23 -24
- package/lib/units/gantt.js +3 -2
- package/lib/units/get-unit-definitions-for-view-type.d.ts +4 -4
- package/lib/units/grid.d.ts +14 -25
- package/lib/units/grid.js +5 -4
- package/lib/units/list.d.ts +17 -26
- package/lib/units/list.js +2 -1
- package/lib/units/make-factory.d.ts +25 -27
- package/lib/units/types.d.ts +19 -13
- package/package.json +10 -10
package/lib/private/calendar.js
CHANGED
|
@@ -1,91 +1,45 @@
|
|
|
1
|
-
import { REMOVE,
|
|
1
|
+
import { REMOVE, deleteNotFoundViewVisitor, identityViewVisitor, replaceIdsWithNamesViewVisitor, replaceNamesWithIdsViewVisitor, resetContextExpressionIfBroken, reuseIfUnchanged, visitColorCoding, visitContextExpression, visitUnits } from "./utils.js";
|
|
2
2
|
import { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit } from "./units.js";
|
|
3
3
|
import { truthy } from "@fibery/helpers/src/_";
|
|
4
|
-
import get from "lodash/get.js";
|
|
5
4
|
//#region src/private/calendar.ts
|
|
5
|
+
function visitItem(item, visitor) {
|
|
6
|
+
const { query, filter, startExpression, endExpression, contextExpression, units, colorCoding, ...rest } = item;
|
|
7
|
+
const fromType = query?.["q/from"];
|
|
8
|
+
if (!fromType) return query ? item : null;
|
|
9
|
+
const visitedQuery = visitor.visitQueryExpression(query);
|
|
10
|
+
if (!visitedQuery) return null;
|
|
11
|
+
return reuseIfUnchanged(item, {
|
|
12
|
+
...rest,
|
|
13
|
+
startExpression: startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression,
|
|
14
|
+
endExpression: endExpression ? visitor.visitExpression(fromType, endExpression) : endExpression,
|
|
15
|
+
contextExpression: visitContextExpression(fromType, contextExpression, visitor),
|
|
16
|
+
query: visitedQuery,
|
|
17
|
+
filter: filter ? visitor.visitFilter(fromType, filter) : null,
|
|
18
|
+
units: units ? visitUnits(fromType, units.filter(truthy), visitor) : void 0,
|
|
19
|
+
colorCoding: colorCoding ? visitColorCoding(fromType, colorCoding, visitor) : colorCoding
|
|
20
|
+
});
|
|
21
|
+
}
|
|
6
22
|
const visitView = (view, visitor) => {
|
|
7
|
-
const
|
|
23
|
+
const { "fibery/meta": meta, ...rest } = view;
|
|
24
|
+
const { items, ...metaRest } = meta;
|
|
8
25
|
return {
|
|
9
|
-
...
|
|
26
|
+
...rest,
|
|
10
27
|
"fibery/meta": {
|
|
11
|
-
...
|
|
12
|
-
items:
|
|
13
|
-
const fromType = get(item, ["query", "q/from"]);
|
|
14
|
-
if (!fromType) return item;
|
|
15
|
-
const nextItem = {
|
|
16
|
-
...item,
|
|
17
|
-
startExpression: item.startExpression ? visitor.visitExpression(fromType, item.startExpression) : item.startExpression,
|
|
18
|
-
endExpression: item.endExpression ? visitor.visitExpression(fromType, item.endExpression) : item.endExpression,
|
|
19
|
-
contextExpression: visitContextExpression(fromType, item.contextExpression, visitor),
|
|
20
|
-
query: item.query ? visitor.visitQueryExpression(item.query) : null,
|
|
21
|
-
filter: item.filter ? visitor.visitFilter(fromType, item.filter) : null,
|
|
22
|
-
units: item.units ? item.units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE) : void 0,
|
|
23
|
-
colorCoding: item.colorCoding && item.colorCoding.map((colorCoding) => ({
|
|
24
|
-
...colorCoding,
|
|
25
|
-
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
26
|
-
})).filter((colorCoding) => colorCoding.expression !== null)
|
|
27
|
-
};
|
|
28
|
-
return Object.entries(nextItem).every(([key, value]) => Object.hasOwn(item, key) && item[key] === value) ? item : nextItem;
|
|
29
|
-
}).filter((item) => {
|
|
30
|
-
const { query } = item;
|
|
31
|
-
return query ? item : null;
|
|
32
|
-
})
|
|
28
|
+
...metaRest,
|
|
29
|
+
items: items.map((item) => visitItem(item, visitor)).filter(truthy)
|
|
33
30
|
}
|
|
34
31
|
};
|
|
35
32
|
};
|
|
36
|
-
const replaceNamesWithIdsInCalendarView = (schema, view) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
visitQueryExpression: (query) => replaceIdsWithNamesInQueryExpression(schema, query)
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView(view, {
|
|
51
|
-
visitQueryExpression: (queryExpression) => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
52
|
-
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
53
|
-
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
54
|
-
});
|
|
55
|
-
const fixUserSelectedUnitsInCalendarView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
56
|
-
return visitView(view, {
|
|
57
|
-
visitExpression: (_fromType, expression) => expression,
|
|
58
|
-
visitFilter: (_fromType, filter) => filter,
|
|
59
|
-
visitQueryExpression: (query) => query,
|
|
60
|
-
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
61
|
-
unitDefinitions,
|
|
62
|
-
getDefaultUnitTypeForField
|
|
63
|
-
})
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, {
|
|
67
|
-
visitQueryExpression: (query) => query,
|
|
68
|
-
visitFilter: (_fromType, filter) => filter,
|
|
69
|
-
visitExpression: (fromType, expression) => expression,
|
|
70
|
-
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
71
|
-
});
|
|
72
|
-
const collectGarbage = (view) => {
|
|
73
|
-
return visitView(view, {
|
|
74
|
-
visitExpression: (fromType, expression) => expression,
|
|
75
|
-
visitFilter: (_fromType, filter) => filter,
|
|
76
|
-
visitQueryExpression: (query) => query,
|
|
77
|
-
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
const enableHideWhenEmptyForCheckedUnits = (view) => {
|
|
81
|
-
return visitView(view, {
|
|
82
|
-
visitQueryExpression: (queryExpression) => queryExpression,
|
|
83
|
-
visitFilter: (_fromType, filter) => filter,
|
|
84
|
-
visitGroupByExpression: (groupBy) => groupBy,
|
|
85
|
-
visitExpression: (fromType, expression) => expression,
|
|
86
|
-
visitEnums: (enums) => enums,
|
|
87
|
-
visitViewUnit: (fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
88
|
-
});
|
|
89
|
-
};
|
|
33
|
+
const replaceNamesWithIdsInCalendarView = (schema, view) => visitView(view, replaceNamesWithIdsViewVisitor(schema));
|
|
34
|
+
const replaceIdsWithNamesInCalendarView = (schema, view) => visitView(view, replaceIdsWithNamesViewVisitor(schema));
|
|
35
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) => visitView(view, deleteNotFoundViewVisitor(schema));
|
|
36
|
+
const fixUserSelectedUnitsInCalendarView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => visitView(view, identityViewVisitor({ visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
37
|
+
unitDefinitions,
|
|
38
|
+
getDefaultUnitTypeForField
|
|
39
|
+
}) }));
|
|
40
|
+
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, identityViewVisitor({ visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression) }));
|
|
41
|
+
const enableHideWhenEmptyForCheckedUnits = (view) => visitView(view, identityViewVisitor({ visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit) }));
|
|
42
|
+
/** @deprecated Drop unchecked units with `visitView(view, identityViewVisitor({visitViewUnit}))`. */
|
|
43
|
+
const collectGarbage = (view) => visitView(view, identityViewVisitor({ visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE }));
|
|
90
44
|
//#endregion
|
|
91
|
-
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInCalendarView, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInCalendarView, replaceIdsWithNamesInCalendarView, replaceNamesWithIdsInCalendarView };
|
|
45
|
+
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInCalendarView, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInCalendarView, replaceIdsWithNamesInCalendarView, replaceNamesWithIdsInCalendarView, visitView };
|
package/lib/private/feed.d.ts
CHANGED
|
@@ -1,17 +1,215 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { FilterGroup } from "../filter.js";
|
|
2
|
+
import { ColorCoding, UnitDefinitions, ViewVisitor } from "./utils.js";
|
|
3
|
+
import { FieldObject, Schema, TypeId, TypeName } from "@fibery/schema";
|
|
4
|
+
import { FieldExpression, Query } from "@fibery/expression-utils/src/types";
|
|
4
5
|
import { Unit } from "@fibery/views/src/units/types";
|
|
5
6
|
//#region src/private/feed.d.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type FeedItemShape<From extends string> = {
|
|
8
|
+
query?: Query<From> | null;
|
|
9
|
+
filter?: FilterGroup | null;
|
|
10
|
+
postExpression?: string[] | null;
|
|
11
|
+
contextExpression?: FieldExpression | null;
|
|
12
|
+
units?: Unit[] | null;
|
|
13
|
+
colorCoding?: ColorCoding[] | null;
|
|
14
|
+
};
|
|
15
|
+
type VisitedKeys = "query" | "filter" | "postExpression" | "contextExpression" | "units" | "colorCoding";
|
|
16
|
+
export type VisitedFeedItem<I extends FeedItemShape<string>, To extends string> = Omit<I, VisitedKeys> & {
|
|
17
|
+
query: Query<To>;
|
|
18
|
+
filter: FilterGroup | null;
|
|
19
|
+
postExpression: I["postExpression"] | null;
|
|
20
|
+
contextExpression: I["contextExpression"] | null;
|
|
21
|
+
units: Unit[] | undefined;
|
|
22
|
+
colorCoding: I["colorCoding"];
|
|
23
|
+
};
|
|
24
|
+
export declare const visitView: <From extends string, To extends string, I extends FeedItemShape<From>, M extends {
|
|
25
|
+
items: I[];
|
|
26
|
+
}, V extends {
|
|
27
|
+
"fibery/meta": M;
|
|
28
|
+
}>(view: V & {
|
|
29
|
+
"fibery/meta": M & {
|
|
30
|
+
items: I[];
|
|
31
|
+
};
|
|
32
|
+
}, visitor: ViewVisitor<From, To>) => Omit<V & {
|
|
33
|
+
"fibery/meta": M & {
|
|
34
|
+
items: I[];
|
|
35
|
+
};
|
|
36
|
+
}, "fibery/meta"> & {
|
|
37
|
+
"fibery/meta": Omit<M & {
|
|
38
|
+
items: I[];
|
|
39
|
+
}, "items"> & {
|
|
40
|
+
items: VisitedFeedItem<I, To>[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
type FeedViewShape<From extends string, I extends FeedItemShape<From>, M extends {
|
|
44
|
+
items: I[];
|
|
45
|
+
}, V> = V & {
|
|
46
|
+
"fibery/meta": M & {
|
|
47
|
+
items: I[];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export declare const replaceNamesWithIdsInFeedView: <I extends FeedItemShape<TypeName | TypeId>, M extends {
|
|
51
|
+
items: I[];
|
|
52
|
+
}, V extends {
|
|
53
|
+
"fibery/meta": M;
|
|
54
|
+
}>(schema: Schema, view: FeedViewShape<TypeName | TypeId, I, M, V>) => Omit<V & {
|
|
55
|
+
"fibery/meta": M & {
|
|
56
|
+
items: I[];
|
|
57
|
+
};
|
|
58
|
+
} & {
|
|
59
|
+
"fibery/meta": M & {
|
|
60
|
+
items: I[];
|
|
61
|
+
} & {
|
|
62
|
+
items: I[];
|
|
63
|
+
};
|
|
64
|
+
}, "fibery/meta"> & {
|
|
65
|
+
"fibery/meta": Omit<M & {
|
|
66
|
+
items: I[];
|
|
67
|
+
} & {
|
|
68
|
+
items: I[];
|
|
69
|
+
}, "items"> & {
|
|
70
|
+
items: VisitedFeedItem<I, TypeId | TypeName>[];
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export declare const replaceIdsWithNamesInFeedView: <I extends FeedItemShape<TypeName | TypeId>, M extends {
|
|
74
|
+
items: I[];
|
|
75
|
+
}, V extends {
|
|
76
|
+
"fibery/meta": M;
|
|
77
|
+
}>(schema: Schema, view: FeedViewShape<TypeName | TypeId, I, M, V>) => Omit<V & {
|
|
78
|
+
"fibery/meta": M & {
|
|
79
|
+
items: I[];
|
|
80
|
+
};
|
|
81
|
+
} & {
|
|
82
|
+
"fibery/meta": M & {
|
|
83
|
+
items: I[];
|
|
84
|
+
} & {
|
|
85
|
+
items: I[];
|
|
86
|
+
};
|
|
87
|
+
}, "fibery/meta"> & {
|
|
88
|
+
"fibery/meta": Omit<M & {
|
|
89
|
+
items: I[];
|
|
90
|
+
} & {
|
|
91
|
+
items: I[];
|
|
92
|
+
}, "items"> & {
|
|
93
|
+
items: VisitedFeedItem<I, TypeId | TypeName>[];
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
export declare const deleteExpressionWithNotFoundFieldsOrTypesInFeedView: <I extends FeedItemShape<string>, M extends {
|
|
97
|
+
items: I[];
|
|
98
|
+
}, V extends {
|
|
99
|
+
"fibery/meta": M;
|
|
100
|
+
}>(schema: Schema, view: FeedViewShape<string, I, M, V>) => Omit<V & {
|
|
101
|
+
"fibery/meta": M & {
|
|
102
|
+
items: I[];
|
|
103
|
+
};
|
|
104
|
+
} & {
|
|
105
|
+
"fibery/meta": M & {
|
|
106
|
+
items: I[];
|
|
107
|
+
} & {
|
|
108
|
+
items: I[];
|
|
109
|
+
};
|
|
110
|
+
}, "fibery/meta"> & {
|
|
111
|
+
"fibery/meta": Omit<M & {
|
|
112
|
+
items: I[];
|
|
113
|
+
} & {
|
|
114
|
+
items: I[];
|
|
115
|
+
}, "items"> & {
|
|
116
|
+
items: VisitedFeedItem<I, TypeName>[];
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export declare const fixUserSelectedUnitsInFeedView: <From extends string, I extends FeedItemShape<From>, M extends {
|
|
120
|
+
items: I[];
|
|
121
|
+
}, V extends {
|
|
122
|
+
"fibery/meta": M;
|
|
123
|
+
}>(schema: Schema, view: FeedViewShape<From, I, M, V>, { unitDefinitions, getDefaultUnitTypeForField }: {
|
|
10
124
|
unitDefinitions: UnitDefinitions;
|
|
11
125
|
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
12
|
-
}) => V
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
126
|
+
}) => Omit<V & {
|
|
127
|
+
"fibery/meta": M & {
|
|
128
|
+
items: I[];
|
|
129
|
+
};
|
|
130
|
+
} & {
|
|
131
|
+
"fibery/meta": M & {
|
|
132
|
+
items: I[];
|
|
133
|
+
} & {
|
|
134
|
+
items: I[];
|
|
135
|
+
};
|
|
136
|
+
}, "fibery/meta"> & {
|
|
137
|
+
"fibery/meta": Omit<M & {
|
|
138
|
+
items: I[];
|
|
139
|
+
} & {
|
|
140
|
+
items: I[];
|
|
141
|
+
}, "items"> & {
|
|
142
|
+
items: VisitedFeedItem<I, From>[];
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
export declare const fixContextExpressionWithBrokenPath: <From extends string, I extends FeedItemShape<From>, M extends {
|
|
146
|
+
items: I[];
|
|
147
|
+
}, V extends {
|
|
148
|
+
"fibery/meta": M;
|
|
149
|
+
}>(schema: Schema, view: FeedViewShape<From, I, M, V>, defaultContextExpression: FieldExpression) => Omit<V & {
|
|
150
|
+
"fibery/meta": M & {
|
|
151
|
+
items: I[];
|
|
152
|
+
};
|
|
153
|
+
} & {
|
|
154
|
+
"fibery/meta": M & {
|
|
155
|
+
items: I[];
|
|
156
|
+
} & {
|
|
157
|
+
items: I[];
|
|
158
|
+
};
|
|
159
|
+
}, "fibery/meta"> & {
|
|
160
|
+
"fibery/meta": Omit<M & {
|
|
161
|
+
items: I[];
|
|
162
|
+
} & {
|
|
163
|
+
items: I[];
|
|
164
|
+
}, "items"> & {
|
|
165
|
+
items: VisitedFeedItem<I, From>[];
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
export declare const enableHideWhenEmptyForCheckedUnits: <From extends string, I extends FeedItemShape<From>, M extends {
|
|
169
|
+
items: I[];
|
|
170
|
+
}, V extends {
|
|
171
|
+
"fibery/meta": M;
|
|
172
|
+
}>(view: FeedViewShape<From, I, M, V>) => Omit<V & {
|
|
173
|
+
"fibery/meta": M & {
|
|
174
|
+
items: I[];
|
|
175
|
+
};
|
|
176
|
+
} & {
|
|
177
|
+
"fibery/meta": M & {
|
|
178
|
+
items: I[];
|
|
179
|
+
} & {
|
|
180
|
+
items: I[];
|
|
181
|
+
};
|
|
182
|
+
}, "fibery/meta"> & {
|
|
183
|
+
"fibery/meta": Omit<M & {
|
|
184
|
+
items: I[];
|
|
185
|
+
} & {
|
|
186
|
+
items: I[];
|
|
187
|
+
}, "items"> & {
|
|
188
|
+
items: VisitedFeedItem<I, From>[];
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
/** @deprecated Drop unchecked units with `visitView(view, identityViewVisitor({visitViewUnit}))`. */
|
|
192
|
+
export declare const collectGarbage: <From extends string, I extends FeedItemShape<From>, M extends {
|
|
193
|
+
items: I[];
|
|
194
|
+
}, V extends {
|
|
195
|
+
"fibery/meta": M;
|
|
196
|
+
}>(view: FeedViewShape<From, I, M, V>) => Omit<V & {
|
|
197
|
+
"fibery/meta": M & {
|
|
198
|
+
items: I[];
|
|
199
|
+
};
|
|
200
|
+
} & {
|
|
201
|
+
"fibery/meta": M & {
|
|
202
|
+
items: I[];
|
|
203
|
+
} & {
|
|
204
|
+
items: I[];
|
|
205
|
+
};
|
|
206
|
+
}, "fibery/meta"> & {
|
|
207
|
+
"fibery/meta": Omit<M & {
|
|
208
|
+
items: I[];
|
|
209
|
+
} & {
|
|
210
|
+
items: I[];
|
|
211
|
+
}, "items"> & {
|
|
212
|
+
items: VisitedFeedItem<I, From>[];
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
//#endregion
|
package/lib/private/feed.js
CHANGED
|
@@ -1,90 +1,44 @@
|
|
|
1
|
-
import { REMOVE,
|
|
1
|
+
import { REMOVE, deleteNotFoundViewVisitor, identityViewVisitor, replaceIdsWithNamesViewVisitor, replaceNamesWithIdsViewVisitor, resetContextExpressionIfBroken, reuseIfUnchanged, visitColorCoding, visitContextExpression, visitUnits } from "./utils.js";
|
|
2
2
|
import { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit } from "./units.js";
|
|
3
3
|
import { truthy } from "@fibery/helpers/src/_";
|
|
4
|
-
import get from "lodash/get.js";
|
|
5
4
|
//#region src/private/feed.ts
|
|
5
|
+
function visitItem(item, visitor) {
|
|
6
|
+
const { query, filter, postExpression, contextExpression, units, colorCoding, ...rest } = item;
|
|
7
|
+
const fromType = query?.["q/from"];
|
|
8
|
+
if (!fromType) return query ? item : null;
|
|
9
|
+
const visitedQuery = visitor.visitQueryExpression(query);
|
|
10
|
+
if (!visitedQuery) return null;
|
|
11
|
+
return reuseIfUnchanged(item, {
|
|
12
|
+
...rest,
|
|
13
|
+
postExpression: postExpression ? visitor.visitExpression(fromType, postExpression) : postExpression,
|
|
14
|
+
contextExpression: visitContextExpression(fromType, contextExpression, visitor),
|
|
15
|
+
query: visitedQuery,
|
|
16
|
+
filter: filter ? visitor.visitFilter(fromType, filter) : null,
|
|
17
|
+
units: units ? visitUnits(fromType, units.filter(truthy), visitor) : void 0,
|
|
18
|
+
colorCoding: colorCoding ? visitColorCoding(fromType, colorCoding, visitor) : colorCoding
|
|
19
|
+
});
|
|
20
|
+
}
|
|
6
21
|
const visitView = (view, visitor) => {
|
|
7
|
-
const
|
|
22
|
+
const { "fibery/meta": meta, ...rest } = view;
|
|
23
|
+
const { items, ...metaRest } = meta;
|
|
8
24
|
return {
|
|
9
|
-
...
|
|
25
|
+
...rest,
|
|
10
26
|
"fibery/meta": {
|
|
11
|
-
...
|
|
12
|
-
items:
|
|
13
|
-
const fromType = get(item, ["query", "q/from"]);
|
|
14
|
-
if (!fromType) return item;
|
|
15
|
-
const nextItem = {
|
|
16
|
-
...item,
|
|
17
|
-
postExpression: item.postExpression ? visitor.visitExpression(fromType, item.postExpression) : item.postExpression,
|
|
18
|
-
contextExpression: visitContextExpression(fromType, item.contextExpression, visitor),
|
|
19
|
-
query: item.query ? visitor.visitQueryExpression(item.query) : null,
|
|
20
|
-
filter: item.filter ? visitor.visitFilter(fromType, item.filter) : null,
|
|
21
|
-
units: item.units ? item.units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE) : void 0,
|
|
22
|
-
colorCoding: item.colorCoding && item.colorCoding.map((colorCoding) => ({
|
|
23
|
-
...colorCoding,
|
|
24
|
-
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
25
|
-
})).filter((colorCoding) => colorCoding.expression !== null)
|
|
26
|
-
};
|
|
27
|
-
return Object.entries(nextItem).every(([key, value]) => Object.hasOwn(item, key) && item[key] === value) ? item : nextItem;
|
|
28
|
-
}).filter((item) => {
|
|
29
|
-
const { query } = item;
|
|
30
|
-
return query ? item : null;
|
|
31
|
-
})
|
|
27
|
+
...metaRest,
|
|
28
|
+
items: items.map((item) => visitItem(item, visitor)).filter(truthy)
|
|
32
29
|
}
|
|
33
30
|
};
|
|
34
31
|
};
|
|
35
|
-
const replaceNamesWithIdsInFeedView = (schema, view) =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
visitQueryExpression: (query) => replaceIdsWithNamesInQueryExpression(schema, query)
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView(view, {
|
|
50
|
-
visitQueryExpression: (queryExpression) => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
51
|
-
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
52
|
-
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
53
|
-
});
|
|
54
|
-
const fixUserSelectedUnitsInFeedView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
55
|
-
return visitView(view, {
|
|
56
|
-
visitExpression: (_fromType, expression) => expression,
|
|
57
|
-
visitFilter: (_fromType, filter) => filter,
|
|
58
|
-
visitQueryExpression: (query) => query,
|
|
59
|
-
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
60
|
-
unitDefinitions,
|
|
61
|
-
getDefaultUnitTypeForField
|
|
62
|
-
})
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, {
|
|
66
|
-
visitQueryExpression: (query) => query,
|
|
67
|
-
visitFilter: (_fromType, filter) => filter,
|
|
68
|
-
visitExpression: (_fromType, expression) => expression,
|
|
69
|
-
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
70
|
-
});
|
|
71
|
-
const collectGarbage = (view) => {
|
|
72
|
-
return visitView(view, {
|
|
73
|
-
visitExpression: (_fromType, expression) => expression,
|
|
74
|
-
visitFilter: (_fromType, filter) => filter,
|
|
75
|
-
visitQueryExpression: (query) => query,
|
|
76
|
-
visitViewUnit: (fromType, unit) => unit.checked ? unit : REMOVE
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
const enableHideWhenEmptyForCheckedUnits = (view) => {
|
|
80
|
-
return visitView(view, {
|
|
81
|
-
visitQueryExpression: (queryExpression) => queryExpression,
|
|
82
|
-
visitGroupByExpression: (groupBy) => groupBy,
|
|
83
|
-
visitFilter: (_fromType, filter) => filter,
|
|
84
|
-
visitExpression: (_fromType, expression) => expression,
|
|
85
|
-
visitEnums: (enums) => enums,
|
|
86
|
-
visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
87
|
-
});
|
|
88
|
-
};
|
|
32
|
+
const replaceNamesWithIdsInFeedView = (schema, view) => visitView(view, replaceNamesWithIdsViewVisitor(schema));
|
|
33
|
+
const replaceIdsWithNamesInFeedView = (schema, view) => visitView(view, replaceIdsWithNamesViewVisitor(schema));
|
|
34
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => visitView(view, deleteNotFoundViewVisitor(schema));
|
|
35
|
+
const fixUserSelectedUnitsInFeedView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => visitView(view, identityViewVisitor({ visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
36
|
+
unitDefinitions,
|
|
37
|
+
getDefaultUnitTypeForField
|
|
38
|
+
}) }));
|
|
39
|
+
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, identityViewVisitor({ visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression) }));
|
|
40
|
+
const enableHideWhenEmptyForCheckedUnits = (view) => visitView(view, identityViewVisitor({ visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit) }));
|
|
41
|
+
/** @deprecated Drop unchecked units with `visitView(view, identityViewVisitor({visitViewUnit}))`. */
|
|
42
|
+
const collectGarbage = (view) => visitView(view, identityViewVisitor({ visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE }));
|
|
89
43
|
//#endregion
|
|
90
|
-
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInFeedView, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInFeedView, replaceIdsWithNamesInFeedView, replaceNamesWithIdsInFeedView };
|
|
44
|
+
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInFeedView, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInFeedView, replaceIdsWithNamesInFeedView, replaceNamesWithIdsInFeedView, visitView };
|
package/lib/private/form.d.ts
CHANGED
|
@@ -1,8 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Schema } from "@fibery/schema";
|
|
1
|
+
import { FieldId, FieldName, Schema, TypeId, TypeName } from "@fibery/schema";
|
|
3
2
|
//#region src/private/form.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export type FormFieldShape<Field extends string> = {
|
|
4
|
+
id: Field;
|
|
5
|
+
};
|
|
6
|
+
export type FormMetaShape<Type extends string, Field extends string, F extends FormFieldShape<Field>> = {
|
|
7
|
+
typeId?: Type | null;
|
|
8
|
+
fields?: F[] | null;
|
|
9
|
+
};
|
|
10
|
+
type FormViewShape<Type extends string, Field extends string, F extends FormFieldShape<Field>, M, V> = V & {
|
|
11
|
+
"fibery/meta": (M & FormMetaShape<Type, Field, F>) | null;
|
|
12
|
+
};
|
|
13
|
+
type FormResult<V extends {
|
|
14
|
+
"fibery/meta": unknown;
|
|
15
|
+
}, M extends FormMetaShape<string, string, FormFieldShape<string>>> = Omit<NonNullable<V["fibery/meta"]>, "typeId" | "fields"> & Omit<M, "typeId" | "fields"> & {
|
|
16
|
+
typeId: V extends {
|
|
17
|
+
"fibery/meta": {
|
|
18
|
+
typeId: string;
|
|
19
|
+
};
|
|
20
|
+
} ? NonNullable<M["typeId"]> : M["typeId"];
|
|
21
|
+
fields: V extends {
|
|
22
|
+
"fibery/meta": {
|
|
23
|
+
fields: FormFieldShape<string>[];
|
|
24
|
+
};
|
|
25
|
+
} ? NonNullable<M["fields"]> : M["fields"];
|
|
26
|
+
};
|
|
27
|
+
export declare const replaceNamesWithIdsInFormView: <F extends FormFieldShape<FieldName | FieldId>, M extends FormMetaShape<TypeName | TypeId, FieldName | FieldId, F>, V extends {
|
|
28
|
+
"fibery/meta": M | null;
|
|
29
|
+
}>(schema: Schema, view: FormViewShape<TypeName | TypeId, FieldName | FieldId, F, M, V>) => Omit<FormViewShape<TypeId | TypeName, FieldId | FieldName, F, M, V>, "fibery/meta"> & {
|
|
30
|
+
"fibery/meta": FormResult<FormViewShape<TypeId | TypeName, FieldId | FieldName, F, M, V>, {
|
|
31
|
+
typeId: TypeId | TypeName | null | undefined;
|
|
32
|
+
fields: F[] | null | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
export declare const replaceIdsWithNamesInFormView: <F extends FormFieldShape<FieldName | FieldId>, M extends FormMetaShape<TypeName | TypeId, FieldName | FieldId, F>, V extends {
|
|
36
|
+
"fibery/meta": M | null;
|
|
37
|
+
}>(schema: Schema, view: FormViewShape<TypeName | TypeId, FieldName | FieldId, F, M, V>) => Omit<FormViewShape<TypeId | TypeName, FieldId | FieldName, F, M, V>, "fibery/meta"> & {
|
|
38
|
+
"fibery/meta": FormResult<FormViewShape<TypeId | TypeName, FieldId | FieldName, F, M, V>, {
|
|
39
|
+
typeId: TypeId | TypeName | null | undefined;
|
|
40
|
+
fields: F[] | null | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
export declare const deleteExpressionWithNotFoundFieldsOrTypesInFormView: <Type extends TypeName | TypeId, F extends FormFieldShape<string>, M extends FormMetaShape<Type, string, F>, V extends {
|
|
44
|
+
"fibery/meta": M | null;
|
|
45
|
+
}>(schema: Schema, view: FormViewShape<Type, string, F, M, V>) => Omit<FormViewShape<Type, string, F, M, V>, "fibery/meta"> & {
|
|
46
|
+
"fibery/meta": FormResult<FormViewShape<Type, string, F, M, V>, {
|
|
47
|
+
typeId: TypeName;
|
|
48
|
+
fields: (F & {
|
|
49
|
+
id: FieldName;
|
|
50
|
+
})[] | null | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
package/lib/private/form.js
CHANGED
|
@@ -1,59 +1,52 @@
|
|
|
1
|
+
import { typeObjectById, typeObjectByName } from "./utils.js";
|
|
1
2
|
//#region src/private/form.ts
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const typeObject = typeId ? schema.getTypeObjectByName(typeId) : null;
|
|
5
|
-
const fields = view["fibery/meta"]?.fields;
|
|
6
|
-
const fieldsInIdsTerms = fields && fields.map((field) => {
|
|
7
|
-
const fieldObject = typeObject?.getFieldObjectByName(field.id);
|
|
8
|
-
if (!fieldObject) return field;
|
|
9
|
-
return {
|
|
10
|
-
...field,
|
|
11
|
-
id: fieldObject.id
|
|
12
|
-
};
|
|
13
|
-
});
|
|
3
|
+
const withMeta = (view, meta) => {
|
|
4
|
+
const { "fibery/meta": _previous, ...rest } = view;
|
|
14
5
|
return {
|
|
15
|
-
...
|
|
16
|
-
"fibery/meta":
|
|
17
|
-
...view["fibery/meta"],
|
|
18
|
-
typeId: typeObject ? typeObject.id : typeId,
|
|
19
|
-
fields: fieldsInIdsTerms || fields
|
|
20
|
-
}
|
|
6
|
+
...rest,
|
|
7
|
+
"fibery/meta": meta
|
|
21
8
|
};
|
|
22
9
|
};
|
|
10
|
+
const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
11
|
+
const { typeId, fields, ...meta } = view["fibery/meta"] ?? {};
|
|
12
|
+
const typeObject = typeId ? typeObjectByName(schema, typeId) : null;
|
|
13
|
+
return withMeta(view, {
|
|
14
|
+
...meta,
|
|
15
|
+
typeId: typeObject ? typeObject.id : typeId,
|
|
16
|
+
fields: fields && fields.map((field) => {
|
|
17
|
+
const fieldName = field.id;
|
|
18
|
+
const fieldObject = typeObject?.getFieldObjectByName(fieldName);
|
|
19
|
+
return fieldObject ? {
|
|
20
|
+
...field,
|
|
21
|
+
id: fieldObject.id
|
|
22
|
+
} : field;
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
};
|
|
23
26
|
const replaceIdsWithNamesInFormView = (schema, view) => {
|
|
24
|
-
const typeId = view["fibery/meta"]
|
|
25
|
-
const typeObject = typeId ? schema
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
const { typeId, fields, ...meta } = view["fibery/meta"] ?? {};
|
|
28
|
+
const typeObject = typeId ? typeObjectById(schema, typeId) : null;
|
|
29
|
+
return withMeta(view, {
|
|
30
|
+
...meta,
|
|
31
|
+
typeId: typeObject ? typeObject.name : typeId,
|
|
32
|
+
fields: fields && fields.map((field) => {
|
|
33
|
+
const fieldId = field.id;
|
|
34
|
+
const fieldObject = typeObject?.getFieldObjectById(fieldId);
|
|
35
|
+
return fieldObject ? {
|
|
36
|
+
...field,
|
|
37
|
+
id: fieldObject.name
|
|
38
|
+
} : field;
|
|
39
|
+
})
|
|
34
40
|
});
|
|
35
|
-
return {
|
|
36
|
-
...view,
|
|
37
|
-
"fibery/meta": {
|
|
38
|
-
...view["fibery/meta"],
|
|
39
|
-
typeId: typeObject ? typeObject.name : typeId,
|
|
40
|
-
fields: fieldsInNameTerms || fields
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
41
|
};
|
|
44
42
|
const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
|
|
45
|
-
const
|
|
46
|
-
const typeObject =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
...view["fibery/meta"],
|
|
53
|
-
typeId: typeObject ? typeObject.name : typeName,
|
|
54
|
-
fields: existingFields || fields
|
|
55
|
-
}
|
|
56
|
-
};
|
|
43
|
+
const { typeId, fields, ...meta } = view["fibery/meta"] ?? {};
|
|
44
|
+
const typeObject = typeId ? typeObjectByName(schema, typeId) : null;
|
|
45
|
+
return withMeta(view, {
|
|
46
|
+
...meta,
|
|
47
|
+
typeId: typeObject ? typeObject.name : typeId,
|
|
48
|
+
fields: fields && fields.filter((field) => Boolean(typeObject?.getFieldObjectByName(field.id)))
|
|
49
|
+
});
|
|
57
50
|
};
|
|
58
51
|
//#endregion
|
|
59
52
|
export { deleteExpressionWithNotFoundFieldsOrTypesInFormView, replaceIdsWithNamesInFormView, replaceNamesWithIdsInFormView };
|