@fibery/views 17.0.4 → 18.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +17 -0
- package/lib/jest.config.d.ts +2 -0
- package/lib/jest.config.js +33 -0
- package/lib/src/field-utils/avatar.d.ts +20 -0
- package/lib/src/field-utils/avatar.js +42 -0
- package/lib/src/field-utils/back-references.d.ts +15 -0
- package/lib/src/field-utils/back-references.js +21 -0
- package/lib/src/field-utils/comments.d.ts +60 -0
- package/lib/src/field-utils/comments.js +46 -0
- package/lib/src/field-utils/date-time.d.ts +14 -0
- package/lib/src/field-utils/date-time.js +56 -0
- package/lib/src/field-utils/enum-value.d.ts +13 -0
- package/lib/src/field-utils/enum-value.js +29 -0
- package/lib/src/field-utils/file.d.ts +4 -0
- package/lib/src/field-utils/file.js +18 -0
- package/lib/src/field-utils/icon.d.ts +10 -0
- package/lib/src/field-utils/icon.js +26 -0
- package/lib/src/field-utils/number.d.ts +31 -0
- package/lib/src/field-utils/number.js +91 -0
- package/lib/src/field-utils/reference-collection.d.ts +18 -0
- package/lib/src/field-utils/reference-collection.js +45 -0
- package/lib/src/field-utils/reference.d.ts +7 -0
- package/lib/src/field-utils/reference.js +57 -0
- package/lib/src/field-utils/relation-view.d.ts +2 -0
- package/lib/src/field-utils/relation-view.js +12 -0
- package/lib/src/field-utils/rich-text.d.ts +12 -0
- package/lib/src/field-utils/rich-text.js +27 -0
- package/lib/src/field-utils/text.d.ts +35 -0
- package/lib/src/field-utils/text.js +40 -0
- package/lib/src/field-utils/user-active.d.ts +8 -0
- package/lib/src/field-utils/user-active.js +28 -0
- package/lib/src/field-utils/user-role.d.ts +6 -0
- package/lib/src/field-utils/user-role.js +25 -0
- package/lib/src/field-utils/workflow.d.ts +15 -0
- package/lib/src/field-utils/workflow.js +56 -0
- package/lib/src/index.d.ts +16 -0
- package/lib/src/index.js +258 -0
- package/lib/src/private/board.d.ts +11 -0
- package/lib/src/private/board.js +326 -0
- package/lib/src/private/calendar.d.ts +10 -0
- package/lib/src/private/calendar.js +122 -0
- package/lib/src/private/feed.d.ts +10 -0
- package/lib/src/private/feed.js +119 -0
- package/lib/src/private/form.d.ts +3 -0
- package/lib/src/private/form.js +61 -0
- package/lib/src/private/map.d.ts +10 -0
- package/lib/src/private/map.js +119 -0
- package/lib/src/private/smart-folder.d.ts +23 -0
- package/lib/src/private/smart-folder.js +274 -0
- package/lib/src/private/test-data/garbage-test.d.ts +649 -0
- package/lib/src/private/test-data/garbage-test.js +520 -0
- package/lib/src/private/test-data/kanban.d.ts +1123 -0
- package/lib/src/private/test-data/kanban.js +1203 -0
- package/lib/src/private/test-data/tasks.d.ts +3216 -0
- package/lib/src/private/test-data/tasks.js +2731 -0
- package/lib/src/private/timeline.d.ts +10 -0
- package/lib/src/private/timeline.js +323 -0
- package/lib/src/private/units.d.ts +6 -0
- package/lib/src/private/units.js +144 -0
- package/lib/src/private/utils.d.ts +17 -0
- package/lib/src/private/utils.js +267 -0
- package/lib/src/tsfixme.d.ts +1 -0
- package/lib/src/tsfixme.js +2 -0
- package/lib/src/unit-definitions/avatar-collection.d.ts +2 -0
- package/lib/src/unit-definitions/avatar-collection.js +53 -0
- package/lib/src/unit-definitions/avatar-input.d.ts +2 -0
- package/lib/src/unit-definitions/avatar-input.js +12 -0
- package/lib/src/unit-definitions/avatar.d.ts +2 -0
- package/lib/src/unit-definitions/avatar.js +80 -0
- package/lib/src/unit-definitions/back-references-list.d.ts +2 -0
- package/lib/src/unit-definitions/back-references-list.js +38 -0
- package/lib/src/unit-definitions/bool-checkbox.d.ts +2 -0
- package/lib/src/unit-definitions/bool-checkbox.js +25 -0
- package/lib/src/unit-definitions/bool.d.ts +2 -0
- package/lib/src/unit-definitions/bool.js +22 -0
- package/lib/src/unit-definitions/collection-count.d.ts +2 -0
- package/lib/src/unit-definitions/collection-count.js +32 -0
- package/lib/src/unit-definitions/color-input.d.ts +2 -0
- package/lib/src/unit-definitions/color-input.js +21 -0
- package/lib/src/unit-definitions/comments-list.d.ts +2 -0
- package/lib/src/unit-definitions/comments-list.js +25 -0
- package/lib/src/unit-definitions/date-range-combobox.d.ts +2 -0
- package/lib/src/unit-definitions/date-range-combobox.js +22 -0
- package/lib/src/unit-definitions/date-range.d.ts +2 -0
- package/lib/src/unit-definitions/date-range.js +22 -0
- package/lib/src/unit-definitions/date-time-combobox.d.ts +2 -0
- package/lib/src/unit-definitions/date-time-combobox.js +22 -0
- package/lib/src/unit-definitions/date.d.ts +2 -0
- package/lib/src/unit-definitions/date.js +22 -0
- package/lib/src/unit-definitions/email-input.d.ts +2 -0
- package/lib/src/unit-definitions/email-input.js +12 -0
- package/lib/src/unit-definitions/email.d.ts +2 -0
- package/lib/src/unit-definitions/email.js +17 -0
- package/lib/src/unit-definitions/emoji.d.ts +2 -0
- package/lib/src/unit-definitions/emoji.js +17 -0
- package/lib/src/unit-definitions/file-collection-count.d.ts +2 -0
- package/lib/src/unit-definitions/file-collection-count.js +30 -0
- package/lib/src/unit-definitions/file-compact-collection.d.ts +2 -0
- package/lib/src/unit-definitions/file-compact-collection.js +30 -0
- package/lib/src/unit-definitions/file-compact-reference.d.ts +2 -0
- package/lib/src/unit-definitions/file-compact-reference.js +36 -0
- package/lib/src/unit-definitions/file-reference.d.ts +2 -0
- package/lib/src/unit-definitions/file-reference.js +26 -0
- package/lib/src/unit-definitions/files-gallery.d.ts +2 -0
- package/lib/src/unit-definitions/files-gallery.js +30 -0
- package/lib/src/unit-definitions/files-l-list-item.d.ts +2 -0
- package/lib/src/unit-definitions/files-l-list-item.js +26 -0
- package/lib/src/unit-definitions/files-l-list.d.ts +2 -0
- package/lib/src/unit-definitions/files-l-list.js +30 -0
- package/lib/src/unit-definitions/files-list-item.d.ts +2 -0
- package/lib/src/unit-definitions/files-list-item.js +26 -0
- package/lib/src/unit-definitions/files-list.d.ts +2 -0
- package/lib/src/unit-definitions/files-list.js +30 -0
- package/lib/src/unit-definitions/geometry-preview.d.ts +2 -0
- package/lib/src/unit-definitions/geometry-preview.js +17 -0
- package/lib/src/unit-definitions/icon-button.d.ts +2 -0
- package/lib/src/unit-definitions/icon-button.js +29 -0
- package/lib/src/unit-definitions/icon-input.d.ts +2 -0
- package/lib/src/unit-definitions/icon-input.js +12 -0
- package/lib/src/unit-definitions/id.d.ts +2 -0
- package/lib/src/unit-definitions/id.js +29 -0
- package/lib/src/unit-definitions/index.d.ts +27 -0
- package/lib/src/unit-definitions/index.js +57 -0
- package/lib/src/unit-definitions/json-input.d.ts +2 -0
- package/lib/src/unit-definitions/json-input.js +21 -0
- package/lib/src/unit-definitions/location-input.d.ts +2 -0
- package/lib/src/unit-definitions/location-input.js +18 -0
- package/lib/src/unit-definitions/location.d.ts +2 -0
- package/lib/src/unit-definitions/location.js +17 -0
- package/lib/src/unit-definitions/not-found.d.ts +2 -0
- package/lib/src/unit-definitions/not-found.js +24 -0
- package/lib/src/unit-definitions/number-input.d.ts +2 -0
- package/lib/src/unit-definitions/number-input.js +22 -0
- package/lib/src/unit-definitions/number.d.ts +2 -0
- package/lib/src/unit-definitions/number.js +27 -0
- package/lib/src/unit-definitions/phone-input.d.ts +2 -0
- package/lib/src/unit-definitions/phone-input.js +12 -0
- package/lib/src/unit-definitions/phone.d.ts +2 -0
- package/lib/src/unit-definitions/phone.js +12 -0
- package/lib/src/unit-definitions/progress-bar.d.ts +2 -0
- package/lib/src/unit-definitions/progress-bar.js +32 -0
- package/lib/src/unit-definitions/reference-collection-combobox.d.ts +2 -0
- package/lib/src/unit-definitions/reference-collection-combobox.js +21 -0
- package/lib/src/unit-definitions/reference-collection-list.d.ts +2 -0
- package/lib/src/unit-definitions/reference-collection-list.js +22 -0
- package/lib/src/unit-definitions/reference-collection-view.d.ts +2 -0
- package/lib/src/unit-definitions/reference-collection-view.js +19 -0
- package/lib/src/unit-definitions/reference-collection.d.ts +2 -0
- package/lib/src/unit-definitions/reference-collection.js +27 -0
- package/lib/src/unit-definitions/reference-combobox.d.ts +2 -0
- package/lib/src/unit-definitions/reference-combobox.js +21 -0
- package/lib/src/unit-definitions/reference-icon.d.ts +2 -0
- package/lib/src/unit-definitions/reference-icon.js +12 -0
- package/lib/src/unit-definitions/reference.d.ts +2 -0
- package/lib/src/unit-definitions/reference.js +49 -0
- package/lib/src/unit-definitions/rich-text-document.d.ts +2 -0
- package/lib/src/unit-definitions/rich-text-document.js +22 -0
- package/lib/src/unit-definitions/rich-text-snippet.d.ts +2 -0
- package/lib/src/unit-definitions/rich-text-snippet.js +39 -0
- package/lib/src/unit-definitions/single-location-preview.d.ts +2 -0
- package/lib/src/unit-definitions/single-location-preview.js +17 -0
- package/lib/src/unit-definitions/text-input.d.ts +2 -0
- package/lib/src/unit-definitions/text-input.js +22 -0
- package/lib/src/unit-definitions/text.d.ts +2 -0
- package/lib/src/unit-definitions/text.js +22 -0
- package/lib/src/unit-definitions/title-input.d.ts +2 -0
- package/lib/src/unit-definitions/title-input.js +16 -0
- package/lib/src/unit-definitions/title.d.ts +2 -0
- package/lib/src/unit-definitions/title.js +34 -0
- package/lib/src/unit-definitions/type-badge-abbr.d.ts +2 -0
- package/lib/src/unit-definitions/type-badge-abbr.js +25 -0
- package/lib/src/unit-definitions/type-badge.d.ts +2 -0
- package/lib/src/unit-definitions/type-badge.js +25 -0
- package/lib/src/unit-definitions/type-icon.d.ts +2 -0
- package/lib/src/unit-definitions/type-icon.js +25 -0
- package/lib/src/unit-definitions/url-input.d.ts +2 -0
- package/lib/src/unit-definitions/url-input.js +12 -0
- package/lib/src/unit-definitions/url.d.ts +2 -0
- package/lib/src/unit-definitions/url.js +17 -0
- package/lib/src/unit-definitions/user-button.d.ts +2 -0
- package/lib/src/unit-definitions/user-button.js +23 -0
- package/lib/src/unit-definitions/user-role-input.d.ts +2 -0
- package/lib/src/unit-definitions/user-role-input.js +12 -0
- package/lib/src/unit-definitions/user-role.d.ts +2 -0
- package/lib/src/unit-definitions/user-role.js +29 -0
- package/lib/src/unit-utils/access.d.ts +9 -0
- package/lib/src/unit-utils/access.js +14 -0
- package/lib/src/unit-utils/can-edit-field.d.ts +6 -0
- package/lib/src/unit-utils/can-edit-field.js +8 -0
- package/lib/src/unit-utils/common.d.ts +14 -0
- package/lib/src/unit-utils/common.js +43 -0
- package/lib/src/unit-utils/decimal.d.ts +42 -0
- package/lib/src/unit-utils/decimal.js +414 -0
- package/lib/src/unit-utils/dynamic-keys.d.ts +7 -0
- package/lib/src/unit-utils/dynamic-keys.js +13 -0
- package/lib/src/unit-utils/enums.d.ts +27 -0
- package/lib/src/unit-utils/enums.js +69 -0
- package/lib/src/unit-utils/formatters.d.ts +50 -0
- package/lib/src/unit-utils/formatters.js +163 -0
- package/lib/src/unit-utils/get-export-value.d.ts +45 -0
- package/lib/src/unit-utils/get-export-value.js +83 -0
- package/lib/src/unit-utils/get-field-label.d.ts +6 -0
- package/lib/src/unit-utils/get-field-label.js +10 -0
- package/lib/src/unit-utils/get-unmatched-unit-label.d.ts +2 -0
- package/lib/src/unit-utils/get-unmatched-unit-label.js +9 -0
- package/lib/src/unit-utils/schema.d.ts +4 -0
- package/lib/src/unit-utils/schema.js +12 -0
- package/lib/src/units/board.d.ts +43 -0
- package/lib/src/units/board.js +51 -0
- package/lib/src/units/canvas/all-units-data-definitions.d.ts +18 -0
- package/lib/src/units/canvas/all-units-data-definitions.js +40 -0
- package/lib/src/units/canvas/index.d.ts +42 -0
- package/lib/src/units/canvas/index.js +48 -0
- package/lib/src/units/canvas/type-badge-abbr.d.ts +36 -0
- package/lib/src/units/canvas/type-badge-abbr.js +11 -0
- package/lib/src/units/canvas/type-badge.d.ts +36 -0
- package/lib/src/units/canvas/type-badge.js +11 -0
- package/lib/src/units/default.d.ts +43 -0
- package/lib/src/units/default.js +51 -0
- package/lib/src/units/gallery.d.ts +3 -0
- package/lib/src/units/gallery.js +18 -0
- package/lib/src/units/gantt.d.ts +44 -0
- package/lib/src/units/gantt.js +59 -0
- package/lib/src/units/get-unit-definitions-for-view-type.d.ts +2 -0
- package/lib/src/units/get-unit-definitions-for-view-type.js +64 -0
- package/lib/src/units/grid.d.ts +42 -0
- package/lib/src/units/grid.js +67 -0
- package/lib/src/units/list.d.ts +43 -0
- package/lib/src/units/list.js +49 -0
- package/lib/src/units/make-factory.d.ts +50 -0
- package/lib/src/units/make-factory.js +245 -0
- package/lib/src/units/types.d.ts +73 -0
- package/lib/src/units/types.js +2 -0
- package/package.json +42 -52
- package/lib/views.js +0 -1813
- /package/{index.js → lib/index.d.ts} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInMapView = exports.deleteExpressionWithNotFoundFieldsOrTypesInMapView = exports.replaceIdsWithNamesInMapView = exports.replaceNamesWithIdsInMapView = void 0;
|
|
7
|
+
const immutability_helper_1 = __importDefault(require("immutability-helper"));
|
|
8
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
+
const units_1 = require("./units");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
|
|
12
|
+
"fibery/meta": {
|
|
13
|
+
items: {
|
|
14
|
+
$apply: (items) => items
|
|
15
|
+
.map((item) => {
|
|
16
|
+
const fromType = (0, get_1.default)(item, ["query", "q/from"]);
|
|
17
|
+
return fromType
|
|
18
|
+
? (0, immutability_helper_1.default)(item, {
|
|
19
|
+
locationExpression: {
|
|
20
|
+
$apply: (startExpression) => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression,
|
|
21
|
+
},
|
|
22
|
+
contextExpression: {
|
|
23
|
+
$apply: (contextExpression) => (0, utils_1.visitContextExpression)(fromType, contextExpression, visitor),
|
|
24
|
+
},
|
|
25
|
+
query: {
|
|
26
|
+
$apply: (query) => (query ? visitor.visitQueryExpression(query) : null),
|
|
27
|
+
},
|
|
28
|
+
filter: {
|
|
29
|
+
$apply: (filter) => (filter ? visitor.visitFilter(fromType, filter) : null),
|
|
30
|
+
},
|
|
31
|
+
units: {
|
|
32
|
+
$apply: (units) => units
|
|
33
|
+
? units
|
|
34
|
+
.filter((unit) => Boolean(unit))
|
|
35
|
+
.map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
|
|
36
|
+
.filter((unit) => (0, utils_1.isUnitExpressionValid)(unit))
|
|
37
|
+
.map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
|
|
38
|
+
.filter((unit) => unit !== utils_1.REMOVE)
|
|
39
|
+
: undefined,
|
|
40
|
+
},
|
|
41
|
+
colorCoding: {
|
|
42
|
+
$apply: (colorCodings) => {
|
|
43
|
+
return (colorCodings &&
|
|
44
|
+
colorCodings
|
|
45
|
+
.map((colorCoding) => ({
|
|
46
|
+
...colorCoding,
|
|
47
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression),
|
|
48
|
+
}))
|
|
49
|
+
.filter((colorCoding) => colorCoding.expression !== null));
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
: item;
|
|
54
|
+
})
|
|
55
|
+
.filter((item) => {
|
|
56
|
+
const { query } = item;
|
|
57
|
+
return query ? item : null;
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
const replaceNamesWithIdsInMapView = (schema, view) => {
|
|
63
|
+
return visitView(view, {
|
|
64
|
+
visitQueryExpression: (query) => (0, utils_1.replaceNamesWithIdsInQueryExpression)(schema, query),
|
|
65
|
+
visitFilter: (fromType, expression) => (0, utils_1.replaceNamesWithIdsInFilter)(schema, fromType, expression),
|
|
66
|
+
visitExpression: (fromType, expression) => (0, utils_1.replaceNamesWithIdsInExpression)(schema, fromType, expression),
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
exports.replaceNamesWithIdsInMapView = replaceNamesWithIdsInMapView;
|
|
70
|
+
const replaceIdsWithNamesInMapView = (schema, view) => {
|
|
71
|
+
return visitView(view, {
|
|
72
|
+
visitQueryExpression: (query) => (0, utils_1.replaceIdsWithNamesInQueryExpression)(schema, query),
|
|
73
|
+
visitFilter: (fromType, expression) => (0, utils_1.replaceIdsWithNamesInFilter)(schema, fromType, expression),
|
|
74
|
+
visitExpression: (fromType, expression) => (0, utils_1.replaceIdsWithNamesInExpression)(schema, fromType, expression),
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
exports.replaceIdsWithNamesInMapView = replaceIdsWithNamesInMapView;
|
|
78
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInMapView = (schema, view) => visitView(view, {
|
|
79
|
+
visitQueryExpression: (queryExpression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression)(schema, queryExpression),
|
|
80
|
+
visitFilter: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInFilter)(schema, fromType, expression),
|
|
81
|
+
visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
|
|
82
|
+
});
|
|
83
|
+
exports.deleteExpressionWithNotFoundFieldsOrTypesInMapView = deleteExpressionWithNotFoundFieldsOrTypesInMapView;
|
|
84
|
+
const fixUserSelectedUnitsInMapView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
85
|
+
return visitView(view, {
|
|
86
|
+
visitQueryExpression: (query) => query,
|
|
87
|
+
visitFilter: (_fromType, filter) => filter,
|
|
88
|
+
visitExpression: (_fromType, expression) => expression,
|
|
89
|
+
visitViewUnit: (fromType, unit, units) => (0, units_1.fixViewUnit)(schema, fromType, unit, units, { unitDefinitions, getDefaultUnitTypeForField }),
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
exports.fixUserSelectedUnitsInMapView = fixUserSelectedUnitsInMapView;
|
|
93
|
+
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, {
|
|
94
|
+
visitExpression: (_fromType, expression) => expression,
|
|
95
|
+
visitQueryExpression: (query) => query,
|
|
96
|
+
visitFilter: (_fromType, filter) => filter,
|
|
97
|
+
visitContextExpression: (fromType, expression) => (0, utils_1.resetContextExpressionIfBroken)(schema, fromType, expression, defaultContextExpression),
|
|
98
|
+
});
|
|
99
|
+
exports.fixContextExpressionWithBrokenPath = fixContextExpressionWithBrokenPath;
|
|
100
|
+
const collectGarbage = (view) => {
|
|
101
|
+
return visitView(view, {
|
|
102
|
+
visitQueryExpression: (query) => query,
|
|
103
|
+
visitFilter: (_fromType, filter) => filter,
|
|
104
|
+
visitExpression: (_fromType, expression) => expression,
|
|
105
|
+
visitViewUnit: (_fromType, unit) => (unit.checked ? unit : utils_1.REMOVE),
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
exports.collectGarbage = collectGarbage;
|
|
109
|
+
const enableHideWhenEmptyForCheckedUnits = (view) => {
|
|
110
|
+
return visitView(view, {
|
|
111
|
+
visitQueryExpression: (queryExpression) => queryExpression,
|
|
112
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
113
|
+
visitFilter: (_fromType, filter) => filter,
|
|
114
|
+
visitExpression: (_fromType, expression) => expression,
|
|
115
|
+
visitEnums: (enums) => enums,
|
|
116
|
+
visitViewUnit: (_fromType, unit) => (0, units_1.enableHideWhenEmptyForCheckedEditableUnit)(unit),
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
exports.enableHideWhenEmptyForCheckedUnits = enableHideWhenEmptyForCheckedUnits;
|
|
@@ -0,0 +1,23 @@
|
|
|
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): {
|
|
5
|
+
[k: string]: {
|
|
6
|
+
expression: any;
|
|
7
|
+
};
|
|
8
|
+
} | null;
|
|
9
|
+
export function replaceNamesWithIdsInGroupByExpression(schema: any, groupByExpression: any, fromType: any): {
|
|
10
|
+
[k: string]: {
|
|
11
|
+
expression: any;
|
|
12
|
+
};
|
|
13
|
+
} | 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;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fixUserSelectedUnitsInSmartFolder = exports.fixContextExpressionWithBrokenPath = exports.deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = exports.replaceIdsWithNamesInSmartFolder = exports.replaceNamesWithIdsInSmartFolder = exports.replaceNamesWithIdsInGroupByExpression = exports.replaceIdsWithNamesInGroupByExpression = exports.deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = void 0;
|
|
7
|
+
const visitors_1 = require("@fibery/expression-utils/src/visitors");
|
|
8
|
+
const immutability_helper_1 = __importDefault(require("immutability-helper"));
|
|
9
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
+
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
11
|
+
const units_1 = require("./units");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
const visitSmartFolder = (smartFolder, visitor) => (0, immutability_helper_1.default)(smartFolder, {
|
|
14
|
+
"fibery/meta": {
|
|
15
|
+
items: {
|
|
16
|
+
$apply: (items = []) => {
|
|
17
|
+
const isOldSmartFolder = !items.every((item) => Object.hasOwn(item, "groupBy"));
|
|
18
|
+
const removedItemsIndexes = items
|
|
19
|
+
.map((item, index) => (visitor.visitQueryExpression(item.query) ? null : index))
|
|
20
|
+
.filter((value) => value !== null);
|
|
21
|
+
return items
|
|
22
|
+
.map((item) => {
|
|
23
|
+
if (isOldSmartFolder) {
|
|
24
|
+
return item;
|
|
25
|
+
}
|
|
26
|
+
const fromType = (0, get_1.default)(item, ["query", "q/from"]);
|
|
27
|
+
return fromType
|
|
28
|
+
? (0, immutability_helper_1.default)(item, {
|
|
29
|
+
groupBy: {
|
|
30
|
+
$apply: (groupBy) => {
|
|
31
|
+
if (!groupBy) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const groupByIndexes = Object.keys(groupBy).map((key) => parseInt(key));
|
|
35
|
+
const removedItemsBeforeTargetLengths = groupByIndexes.map((groupByIndex) => removedItemsIndexes.filter((n) => n < groupByIndex).length);
|
|
36
|
+
return visitor.visitGroupByExpression(groupBy, fromType, removedItemsBeforeTargetLengths);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
: item;
|
|
41
|
+
})
|
|
42
|
+
.map((item) => {
|
|
43
|
+
if (isOldSmartFolder) {
|
|
44
|
+
return item;
|
|
45
|
+
}
|
|
46
|
+
const fromType = (0, get_1.default)(item, ["query", "q/from"]);
|
|
47
|
+
return fromType
|
|
48
|
+
? (0, immutability_helper_1.default)(item, {
|
|
49
|
+
groupingExpression: {
|
|
50
|
+
$apply: (groupingExpression) => {
|
|
51
|
+
if (!groupingExpression) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const groupingExpressionIndexes = Object.keys(groupingExpression).map((key) => parseInt(key));
|
|
55
|
+
const removedItemsBeforeTargetLengths = groupingExpressionIndexes.map((groupByIndex) => removedItemsIndexes.filter((n) => n < groupByIndex).length);
|
|
56
|
+
return visitor.visitGroupByExpression(groupingExpression, fromType, removedItemsBeforeTargetLengths);
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
: item;
|
|
61
|
+
})
|
|
62
|
+
.map((item) => {
|
|
63
|
+
const fromType = (0, get_1.default)(item, ["query", "q/from"]);
|
|
64
|
+
return fromType
|
|
65
|
+
? (0, immutability_helper_1.default)(item, {
|
|
66
|
+
filter: {
|
|
67
|
+
$apply: (filter) => (filter ? visitor.visitFilter(fromType, filter) : null),
|
|
68
|
+
},
|
|
69
|
+
query: {
|
|
70
|
+
$apply: (query) => {
|
|
71
|
+
const visitedQuery = visitor.visitQueryExpression(query);
|
|
72
|
+
return query ? visitedQuery : null;
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
units: {
|
|
76
|
+
$apply: (units) => {
|
|
77
|
+
return units
|
|
78
|
+
? units
|
|
79
|
+
.filter((unit) => Boolean(unit))
|
|
80
|
+
.map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
|
|
81
|
+
.filter((unit) => (0, utils_1.isUnitExpressionValid)(unit))
|
|
82
|
+
.map((unit, index, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
|
|
83
|
+
.filter((unit) => unit !== utils_1.REMOVE)
|
|
84
|
+
: undefined;
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
contextExpression: {
|
|
88
|
+
$apply: (contextExpression) => (0, utils_1.visitContextExpression)(fromType, contextExpression, visitor),
|
|
89
|
+
},
|
|
90
|
+
colorCoding: {
|
|
91
|
+
$apply: (colorCodings) => {
|
|
92
|
+
return colorCodings
|
|
93
|
+
? colorCodings
|
|
94
|
+
.map((colorCoding) => ({
|
|
95
|
+
...colorCoding,
|
|
96
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression),
|
|
97
|
+
}))
|
|
98
|
+
.filter((colorCoding) => colorCoding.expression !== null)
|
|
99
|
+
: undefined;
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
})
|
|
103
|
+
: item;
|
|
104
|
+
})
|
|
105
|
+
.filter((item) => {
|
|
106
|
+
const { query } = item;
|
|
107
|
+
return query ? item : null;
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
columnOrderWithIds: {
|
|
112
|
+
$apply: (columnOrderWithIds) => {
|
|
113
|
+
if (!visitor.visitUnitGroupKey || !columnOrderWithIds) {
|
|
114
|
+
return columnOrderWithIds;
|
|
115
|
+
}
|
|
116
|
+
return columnOrderWithIds.map((key) => visitor.visitUnitGroupKey(key));
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
pinnedColumnsWithIds: {
|
|
120
|
+
$apply: (pinnedColumnsWithIds) => {
|
|
121
|
+
if (!visitor.visitUnitGroupKey || !pinnedColumnsWithIds) {
|
|
122
|
+
return pinnedColumnsWithIds;
|
|
123
|
+
}
|
|
124
|
+
return pinnedColumnsWithIds.map((key) => visitor.visitUnitGroupKey(key));
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
columnAggFunc: {
|
|
128
|
+
$apply: (columnAggFunc) => {
|
|
129
|
+
if (!visitor.visitUnitGroupKey || !columnAggFunc) {
|
|
130
|
+
return columnAggFunc;
|
|
131
|
+
}
|
|
132
|
+
return Object.fromEntries(Object.entries(columnAggFunc).map(([key, value]) => {
|
|
133
|
+
return [visitor.visitUnitGroupKey(key), value];
|
|
134
|
+
}));
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, groupByExpression, fromType, removedItems) => {
|
|
140
|
+
if (!groupByExpression) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const entries = Object.entries(groupByExpression)
|
|
144
|
+
.map(([index, { expression }], groupByIndex) => {
|
|
145
|
+
const visitedExpression = (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression);
|
|
146
|
+
if (visitedExpression) {
|
|
147
|
+
return [
|
|
148
|
+
`${parseInt(index) - removedItems[groupByIndex]}`,
|
|
149
|
+
{
|
|
150
|
+
expression: visitedExpression,
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
})
|
|
156
|
+
.filter(Boolean);
|
|
157
|
+
return entries.length > 0 ? Object.fromEntries(entries) : null;
|
|
158
|
+
};
|
|
159
|
+
exports.deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression;
|
|
160
|
+
const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
161
|
+
if (!groupByExpression) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
return Object.fromEntries(Object.entries(groupByExpression).map(([index, { expression }]) => {
|
|
165
|
+
if (Object.hasOwn(schema.typeObjectsById, fromType)) {
|
|
166
|
+
const typeObject = schema.typeObjectsById[fromType];
|
|
167
|
+
return [
|
|
168
|
+
index,
|
|
169
|
+
{
|
|
170
|
+
expression: (0, visitors_1.replaceIdsWithNamesVisitor)(typeObject).visitExpression(expression),
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
return [index, { expression }];
|
|
176
|
+
}
|
|
177
|
+
}));
|
|
178
|
+
};
|
|
179
|
+
exports.replaceIdsWithNamesInGroupByExpression = replaceIdsWithNamesInGroupByExpression;
|
|
180
|
+
const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
181
|
+
if (!groupByExpression) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
return Object.fromEntries(Object.entries(groupByExpression).map(([index, { expression }]) => {
|
|
185
|
+
if (Object.hasOwn(schema.typeObjectsByName, fromType)) {
|
|
186
|
+
const typeObject = schema.typeObjectsByName[fromType];
|
|
187
|
+
return [
|
|
188
|
+
index,
|
|
189
|
+
{
|
|
190
|
+
expression: (0, visitors_1.replaceNamesWithIdsVisitor)(typeObject).visitExpression(expression),
|
|
191
|
+
},
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
return [index, { expression }];
|
|
196
|
+
}
|
|
197
|
+
}));
|
|
198
|
+
};
|
|
199
|
+
exports.replaceNamesWithIdsInGroupByExpression = replaceNamesWithIdsInGroupByExpression;
|
|
200
|
+
const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
201
|
+
visitQueryExpression: (query) => (0, utils_1.replaceNamesWithIdsInQueryExpression)(schema, query),
|
|
202
|
+
visitFilter: (fromType, expression) => (0, utils_1.replaceNamesWithIdsInFilter)(schema, fromType, expression),
|
|
203
|
+
visitGroupByExpression: (groupBy, fromType) => (0, exports.replaceNamesWithIdsInGroupByExpression)(schema, groupBy, fromType),
|
|
204
|
+
visitExpression: (fromType, expression) => (0, utils_1.replaceNamesWithIdsInExpression)(schema, fromType, expression),
|
|
205
|
+
visitUnitGroupKey: (unitGroupKey) => (0, utils_1.replaceNamesWithIdsInUnitGroupKey)(unitGroupKey, schema),
|
|
206
|
+
});
|
|
207
|
+
exports.replaceNamesWithIdsInSmartFolder = replaceNamesWithIdsInSmartFolder;
|
|
208
|
+
const replaceIdsWithNamesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
209
|
+
visitQueryExpression: (query) => (0, utils_1.replaceIdsWithNamesInQueryExpression)(schema, query),
|
|
210
|
+
visitFilter: (fromType, expression) => (0, utils_1.replaceIdsWithNamesInFilter)(schema, fromType, expression),
|
|
211
|
+
visitGroupByExpression: (groupBy, fromType) => (0, exports.replaceIdsWithNamesInGroupByExpression)(schema, groupBy, fromType),
|
|
212
|
+
visitExpression: (fromType, expression) => (0, utils_1.replaceIdsWithNamesInExpression)(schema, fromType, expression),
|
|
213
|
+
visitUnitGroupKey: (unitGroupKey) => (0, utils_1.replaceIdsWithNamesInUnitGroupKey)(unitGroupKey, (0, utils_1.getFieldObjectsById)(smartFolder, schema)),
|
|
214
|
+
});
|
|
215
|
+
exports.replaceIdsWithNamesInSmartFolder = replaceIdsWithNamesInSmartFolder;
|
|
216
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
217
|
+
visitQueryExpression: (query) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression)(schema, query),
|
|
218
|
+
visitGroupByExpression: (groupBy, fromType, removedItems) => (0, exports.deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression)(schema, groupBy, fromType, removedItems),
|
|
219
|
+
visitFilter: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInFilter)(schema, fromType, expression),
|
|
220
|
+
visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
|
|
221
|
+
});
|
|
222
|
+
exports.deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder;
|
|
223
|
+
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitSmartFolder(view, {
|
|
224
|
+
visitQueryExpression: (query) => query,
|
|
225
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
226
|
+
visitExpression: (_fromType, expression) => expression,
|
|
227
|
+
visitFilter: (_fromType, filter) => filter,
|
|
228
|
+
visitContextExpression: (fromType, expression) => (0, utils_1.resetContextExpressionIfBroken)(schema, fromType, expression, defaultContextExpression),
|
|
229
|
+
});
|
|
230
|
+
exports.fixContextExpressionWithBrokenPath = fixContextExpressionWithBrokenPath;
|
|
231
|
+
const fixUserSelectedUnitsInSmartFolder = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
232
|
+
return visitSmartFolder(view, {
|
|
233
|
+
visitQueryExpression: (query) => query,
|
|
234
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
235
|
+
visitFilter: (_fromType, filter) => filter,
|
|
236
|
+
visitExpression: (_fromType, expression) => expression,
|
|
237
|
+
visitViewUnit: (fromType, unit, units) => {
|
|
238
|
+
const { type, expression } = unit;
|
|
239
|
+
if (type === "rich-text" && view?.["fibery/type"] === "grid") {
|
|
240
|
+
if (unit.checked) {
|
|
241
|
+
const snippetsUnits = units?.filter((x) => x.type === "rich-text-snippet");
|
|
242
|
+
const snippetUnitForField = snippetsUnits?.find((x) => (0, isEqual_1.default)(x.expression, expression));
|
|
243
|
+
if (snippetUnitForField && !snippetUnitForField.checked) {
|
|
244
|
+
snippetUnitForField.checked = true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return utils_1.REMOVE;
|
|
248
|
+
}
|
|
249
|
+
return (0, units_1.fixViewUnit)(schema, fromType, unit, units, { unitDefinitions, getDefaultUnitTypeForField });
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
exports.fixUserSelectedUnitsInSmartFolder = fixUserSelectedUnitsInSmartFolder;
|
|
254
|
+
const collectGarbage = (view) => {
|
|
255
|
+
return visitSmartFolder(view, {
|
|
256
|
+
visitQueryExpression: (query) => query,
|
|
257
|
+
visitFilter: (_fromType, filter) => filter,
|
|
258
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
259
|
+
visitExpression: (_fromType, expression) => expression,
|
|
260
|
+
visitViewUnit: (_fromType, unit) => (unit.checked ? unit : utils_1.REMOVE),
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
exports.collectGarbage = collectGarbage;
|
|
264
|
+
const enableHideWhenEmptyForCheckedUnits = (view) => {
|
|
265
|
+
return visitSmartFolder(view, {
|
|
266
|
+
visitQueryExpression: (queryExpression) => queryExpression,
|
|
267
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
268
|
+
visitExpression: (_fromType, expression) => expression,
|
|
269
|
+
visitFilter: (_fromType, filter) => filter,
|
|
270
|
+
visitEnums: (enums) => enums,
|
|
271
|
+
visitViewUnit: (_fromType, unit) => (0, units_1.enableHideWhenEmptyForCheckedEditableUnit)(unit),
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
exports.enableHideWhenEmptyForCheckedUnits = enableHideWhenEmptyForCheckedUnits;
|