@fibery/views 26.0.7 → 26.0.8
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/field-utils/reference-collection.js +2 -13
- package/lib/field-utils/rich-text.js +3 -13
- package/lib/private/board.js +2 -2
- package/lib/private/smart-folder.js +3 -3
- package/lib/private/timeline.js +3 -3
- package/lib/private/units.js +1 -1
- package/lib/unit-definitions/avatar-collection.js +2 -13
- package/lib/unit-definitions/avatar.js +2 -12
- package/lib/unit-definitions/reference.js +2 -12
- package/lib/unit-utils/formatters.js +1 -1
- package/lib/unit-utils/wrap-normalized-in-expression.d.ts +2 -1
- package/lib/unit-utils/wrap-normalized-in-expression.js +14 -12
- package/package.json +7 -7
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { generateAccessCheckQueryExpression } from "../unit-utils/access.js";
|
|
2
2
|
import { collectionCountKeyPrefix, makeDynamicKey } from "../unit-utils/dynamic-keys.js";
|
|
3
3
|
import { getEnumIconColorQuery } from "../unit-utils/enums.js";
|
|
4
|
+
import { wrapCollectionSelectInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
4
5
|
import { getAvatarSelectQuery } from "./avatar.js";
|
|
5
6
|
import { getFilesSelect } from "./file.js";
|
|
6
7
|
import { getEntityIconSelect } from "./icon.js";
|
|
@@ -30,18 +31,6 @@ const calculateReferenceCollectionQuery = ({ fieldObjects, expression, limit })
|
|
|
30
31
|
].filter(truthy)),
|
|
31
32
|
"q/limit": limit
|
|
32
33
|
};
|
|
33
|
-
return
|
|
34
|
-
const originalIndex = expression.length - 1 - reversedIndex;
|
|
35
|
-
if (!(originalIndex === expression.length - 1)) {
|
|
36
|
-
const pathToField = expression.slice(0, originalIndex + 1);
|
|
37
|
-
const { idField } = fieldObjects[originalIndex].typeObject;
|
|
38
|
-
const innerForField = idField ? {
|
|
39
|
-
[idField]: [...pathToField, idField],
|
|
40
|
-
...inner
|
|
41
|
-
} : { ...inner };
|
|
42
|
-
return { [field]: innerForField };
|
|
43
|
-
}
|
|
44
|
-
return { [field]: inner };
|
|
45
|
-
}, collectionSubQuery);
|
|
34
|
+
return wrapCollectionSelectInExpression(collectionSubQuery, fieldObjects, expression);
|
|
46
35
|
};
|
|
47
36
|
export { REFERENCE_COLLECTION_LIMIT, calculateReferenceCollectionQuery, getCollectionCountSelect, getCountKey, makeCollectionCountExpression };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { hasAccessToSecretKeyPrefix, makeDynamicKey } from "../unit-utils/dynamic-keys.js";
|
|
2
|
+
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
2
3
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
3
4
|
import { denormalizeSelect, normalizeSelect, toSelectMapClause } from "@fibery/query-utils/src/select";
|
|
4
5
|
// src/field-utils/rich-text.ts
|
|
@@ -14,20 +15,9 @@ function getRichTextQuerySelect({ typeObject, unit: { expression }, includeSnipp
|
|
|
14
15
|
const innerNormalized = normalizeSelect({
|
|
15
16
|
...getHasAccessToSecret(expression),
|
|
16
17
|
...toSelectMapClause([terminalTypeObject.idField, "Collaboration~Documents/secret"]),
|
|
17
|
-
...includeSnippet
|
|
18
|
+
...includeSnippet && toSelectMapClause([terminalTypeObject.idField, "Collaboration~Documents/Snippet"])
|
|
18
19
|
});
|
|
19
|
-
const nested =
|
|
20
|
-
const originalIndex = expression.length - 1 - reversedIndex;
|
|
21
|
-
if (!(originalIndex === expression.length - 1)) {
|
|
22
|
-
const { idField } = fieldObjects[originalIndex].typeObject;
|
|
23
|
-
const innerWithId = idField ? {
|
|
24
|
-
[idField]: idField,
|
|
25
|
-
...inner
|
|
26
|
-
} : inner;
|
|
27
|
-
return { [field]: innerWithId };
|
|
28
|
-
}
|
|
29
|
-
return { [field]: inner };
|
|
30
|
-
}, innerNormalized);
|
|
20
|
+
const nested = wrapNormalizedInExpression(innerNormalized, fieldObjects, expression);
|
|
31
21
|
return denormalizeSelect(nested);
|
|
32
22
|
}
|
|
33
23
|
export { getHasAccessToSecret, getHasAccessToSecretExpr, getRichTextQuerySelect, hasAccessToSecretKey };
|
package/lib/private/board.js
CHANGED
|
@@ -18,8 +18,8 @@ function visitQueryHolder(holder, visitor, visitHolderUnits = true) {
|
|
|
18
18
|
contextExpression: visitContextExpression(fromType, contextExpression, visitor),
|
|
19
19
|
units: units ? visitUnits(fromType, units.filter(truthy), visitor) : void 0
|
|
20
20
|
} : {
|
|
21
|
-
...Object.hasOwn(holder, "contextExpression")
|
|
22
|
-
...Object.hasOwn(holder, "units")
|
|
21
|
+
...Object.hasOwn(holder, "contextExpression") && { contextExpression },
|
|
22
|
+
...Object.hasOwn(holder, "units") && { units }
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -6,7 +6,7 @@ import { deepEqual } from "@fibery/helpers/src/equal";
|
|
|
6
6
|
// src/private/smart-folder.ts
|
|
7
7
|
function visitItems(items, visitor) {
|
|
8
8
|
const removedItemsIndexes = items.flatMap((item, index) => item.query && visitor.visitQueryExpression(item.query) ? [] : [index]);
|
|
9
|
-
const removedBefore = (groupBy) => Object.keys(groupBy).map((key) => removedItemsIndexes.filter((n) => n < parseInt(key)).length);
|
|
9
|
+
const removedBefore = (groupBy) => Object.keys(groupBy).map((key) => removedItemsIndexes.filter((n) => n < Number.parseInt(key)).length);
|
|
10
10
|
const visitGroupBy = (groupBy, fromType) => groupBy && visitor.visitGroupByExpression ? visitor.visitGroupByExpression(groupBy, fromType, removedBefore(groupBy)) : null;
|
|
11
11
|
return items.map((item) => {
|
|
12
12
|
const { query, filter, contextExpression, units, groupBy, groupingExpression, colorCoding, ...rest } = item;
|
|
@@ -18,7 +18,7 @@ function visitItems(items, visitor) {
|
|
|
18
18
|
const keepsGroupingExpression = Array.isArray(groupingExpression) || !hasGroupBy && !groupingExpression;
|
|
19
19
|
return reuseIfUnchanged(item, {
|
|
20
20
|
...rest,
|
|
21
|
-
...hasGroupBy
|
|
21
|
+
...hasGroupBy && { groupBy: visitGroupBy(groupBy, fromType) },
|
|
22
22
|
...keepsGroupingExpression ? Object.hasOwn(item, "groupingExpression") ? { groupingExpression } : {} : { groupingExpression: visitGroupBy(groupingExpression, fromType) },
|
|
23
23
|
filter: filter ? visitor.visitFilter(fromType, filter) : null,
|
|
24
24
|
query: visitedQuery,
|
|
@@ -47,7 +47,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, gr
|
|
|
47
47
|
if (!groupByExpression) return null;
|
|
48
48
|
const entries = Object.entries(groupByExpression).flatMap(([index, { expression }], groupByIndex) => {
|
|
49
49
|
const visitedExpression = deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression);
|
|
50
|
-
return visitedExpression ? [[`${parseInt(index) - removedItems[groupByIndex]}`, { expression: visitedExpression }]] : [];
|
|
50
|
+
return visitedExpression ? [[`${Number.parseInt(index) - removedItems[groupByIndex]}`, { expression: visitedExpression }]] : [];
|
|
51
51
|
});
|
|
52
52
|
return entries.length > 0 ? Object.fromEntries(entries) : null;
|
|
53
53
|
};
|
package/lib/private/timeline.js
CHANGED
|
@@ -14,7 +14,7 @@ const visitAxisSingle = (axis, visitor) => {
|
|
|
14
14
|
filter: filter ? visitor.visitFilter(fromType, filter) : null,
|
|
15
15
|
query: visitedQuery,
|
|
16
16
|
contextExpression: visitContextExpression(fromType, contextExpression, visitor),
|
|
17
|
-
...units
|
|
17
|
+
...units && { units: visitUnits(fromType, units, visitor) },
|
|
18
18
|
groupByExpression: groupByExpression && firstOrNull(visitor.visitExpression(fromType, [groupByExpression]))
|
|
19
19
|
};
|
|
20
20
|
};
|
|
@@ -70,7 +70,7 @@ function visitMilestone(milestone, visitor) {
|
|
|
70
70
|
}
|
|
71
71
|
function visitItems(items, visitor) {
|
|
72
72
|
const removedItemsIndexes = items.flatMap((item, index) => item.query && visitor.visitQueryExpression(item.query) ? [] : [index]);
|
|
73
|
-
const removedBefore = (groupBy) => Object.keys(groupBy).map((key) => removedItemsIndexes.filter((n) => n < parseInt(key)).length);
|
|
73
|
+
const removedBefore = (groupBy) => Object.keys(groupBy).map((key) => removedItemsIndexes.filter((n) => n < Number.parseInt(key)).length);
|
|
74
74
|
return items.map((item) => {
|
|
75
75
|
const { query, filter, yExpression, startExpression, endExpression, secondaryStartExpression, secondaryEndExpression, contextExpression, units, laneUnits, colorCoding, dependencyExpression, groupBy, groupingExpression, ...rest } = item;
|
|
76
76
|
const fromType = query?.["q/from"];
|
|
@@ -93,7 +93,7 @@ function visitItems(items, visitor) {
|
|
|
93
93
|
colorCoding: colorCoding ? visitColorCoding(fromType, colorCoding, visitor) : colorCoding,
|
|
94
94
|
dependencyExpression: dependencyExpression && visitor.visitExpression(fromType, dependencyExpression),
|
|
95
95
|
groupBy: groupBy ? visitor.visitGroupByExpression(groupBy, fromType, removedBefore(groupBy)) : groupBy,
|
|
96
|
-
...Object.hasOwn(item, "groupingExpression")
|
|
96
|
+
...Object.hasOwn(item, "groupingExpression") && { groupingExpression: groupingExpression ? visitor.visitGroupByExpression(groupingExpression, fromType, removedBefore(groupingExpression)) : null }
|
|
97
97
|
});
|
|
98
98
|
}).filter(truthy);
|
|
99
99
|
}
|
package/lib/private/units.js
CHANGED
|
@@ -143,7 +143,7 @@ const fixViewUnit = (schema, fromType, unit, units, { unitDefinitions, getDefaul
|
|
|
143
143
|
if (replacement) return {
|
|
144
144
|
...replacement,
|
|
145
145
|
checked: true,
|
|
146
|
-
|
|
146
|
+
...!(unit.hideWhenEmpty === void 0) && { hideWhenEmpty: unit.hideWhenEmpty }
|
|
147
147
|
};
|
|
148
148
|
} else return REMOVE;
|
|
149
149
|
}
|
|
@@ -3,6 +3,7 @@ import { generateAccessCheckQueryExpression } from "../unit-utils/access.js";
|
|
|
3
3
|
import { calculateUnitExpressionErrors, canEditFieldExpression, makeUnitMethod } from "../unit-utils/common.js";
|
|
4
4
|
import { getReferenceCollectionExportValue } from "../unit-utils/get-export-value.js";
|
|
5
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
6
|
+
import { wrapCollectionSelectInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
6
7
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
7
8
|
import { truthy } from "@fibery/helpers/src/_";
|
|
8
9
|
import { mergeDenormalizedSelects, toSelectMapClause } from "@fibery/query-utils/src/select";
|
|
@@ -36,19 +37,7 @@ const AvatarCollection = {
|
|
|
36
37
|
].filter(truthy)),
|
|
37
38
|
"q/limit": "q/no-limit"
|
|
38
39
|
};
|
|
39
|
-
return
|
|
40
|
-
const originalIndex = expression.length - 1 - reversedIndex;
|
|
41
|
-
if (!(originalIndex === expression.length - 1)) {
|
|
42
|
-
const pathToField = expression.slice(0, originalIndex + 1);
|
|
43
|
-
const { idField } = fieldObjects[originalIndex].typeObject;
|
|
44
|
-
const innerForField = idField ? {
|
|
45
|
-
[idField]: [...pathToField, idField],
|
|
46
|
-
...inner
|
|
47
|
-
} : { ...inner };
|
|
48
|
-
return { [field]: innerForField };
|
|
49
|
-
}
|
|
50
|
-
return { [field]: inner };
|
|
51
|
-
}, collectionSubQuery);
|
|
40
|
+
return wrapCollectionSelectInExpression(collectionSubQuery, fieldObjects, expression);
|
|
52
41
|
},
|
|
53
42
|
calculateErrors: calculateUnitExpressionErrors,
|
|
54
43
|
getExportValue: getReferenceCollectionExportValue,
|
|
@@ -3,6 +3,7 @@ import { generateAccessCheckQueryExpression } from "../unit-utils/access.js";
|
|
|
3
3
|
import { calculateUnitExpressionErrors, canEditFieldExpression } from "../unit-utils/common.js";
|
|
4
4
|
import { getReferenceExportValue } from "../unit-utils/get-export-value.js";
|
|
5
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
6
|
+
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
6
7
|
import { assertIsValidExpression, getFieldObjectByFieldExpression, getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
7
8
|
import { truthy } from "@fibery/helpers/src/_";
|
|
8
9
|
import { denormalizeSelect, mergeDenormalizedSelects, normalizeSelect, toSelectMapClause } from "@fibery/query-utils/src/select";
|
|
@@ -59,18 +60,7 @@ const Avatar = {
|
|
|
59
60
|
}),
|
|
60
61
|
getAvatarSelectQuery({ typeObject: terminalFieldObject.typeObject })
|
|
61
62
|
].filter(truthy)));
|
|
62
|
-
const nested =
|
|
63
|
-
const originalIndex = expression.length - 1 - reversedIndex;
|
|
64
|
-
if (!(originalIndex === expression.length - 1)) {
|
|
65
|
-
const { idField } = fieldObjects[originalIndex].typeObject;
|
|
66
|
-
const innerWithId = idField ? {
|
|
67
|
-
[idField]: idField,
|
|
68
|
-
...inner
|
|
69
|
-
} : inner;
|
|
70
|
-
return { [field]: innerWithId };
|
|
71
|
-
}
|
|
72
|
-
return { [field]: inner };
|
|
73
|
-
}, innerSelect);
|
|
63
|
+
const nested = wrapNormalizedInExpression(innerSelect, fieldObjects, expression);
|
|
74
64
|
return denormalizeSelect(nested);
|
|
75
65
|
},
|
|
76
66
|
calculateErrors: calculateUnitExpressionErrors,
|
|
@@ -2,6 +2,7 @@ import { getReferenceFieldNormalizedSelectClause } from "../field-utils/referenc
|
|
|
2
2
|
import { calculateUnitExpressionErrors, canEditFieldExpression } from "../unit-utils/common.js";
|
|
3
3
|
import { getReferenceExportValue } from "../unit-utils/get-export-value.js";
|
|
4
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
+
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
5
6
|
import { assertIsValidExpression, getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
6
7
|
import { denormalizeSelect } from "@fibery/query-utils/src/select";
|
|
7
8
|
// src/unit-definitions/reference.ts
|
|
@@ -29,18 +30,7 @@ const Reference = {
|
|
|
29
30
|
});
|
|
30
31
|
const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
|
|
31
32
|
const innerNormalized = getReferenceFieldNormalizedSelectClause(terminalFieldObject, expression);
|
|
32
|
-
const nested =
|
|
33
|
-
const originalIndex = expression.length - 1 - reversedIndex;
|
|
34
|
-
if (!(originalIndex === expression.length - 1)) {
|
|
35
|
-
const { idField } = fieldObjects[originalIndex].typeObject;
|
|
36
|
-
const innerWithId = idField ? {
|
|
37
|
-
[idField]: idField,
|
|
38
|
-
...inner
|
|
39
|
-
} : inner;
|
|
40
|
-
return { [field]: innerWithId };
|
|
41
|
-
}
|
|
42
|
-
return { [field]: inner };
|
|
43
|
-
}, innerNormalized);
|
|
33
|
+
const nested = wrapNormalizedInExpression(innerNormalized, fieldObjects, expression);
|
|
44
34
|
return denormalizeSelect(nested);
|
|
45
35
|
},
|
|
46
36
|
calculateErrors({ typeObject, unit }) {
|
|
@@ -63,7 +63,7 @@ const formatNumberWithoutUnit = ({ value, format = "Number", displaySettings, cu
|
|
|
63
63
|
case "Percent": return formatPercent(useThousandSeparator, precision, value, displaySettings);
|
|
64
64
|
default: return value;
|
|
65
65
|
}
|
|
66
|
-
} catch
|
|
66
|
+
} catch {
|
|
67
67
|
return value;
|
|
68
68
|
}
|
|
69
69
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { FieldObject } from "@fibery/schema";
|
|
2
2
|
import { FieldExpression } from "@fibery/expression-utils/src/types";
|
|
3
|
-
export declare const wrapNormalizedInExpression: (
|
|
3
|
+
export declare const wrapNormalizedInExpression: (select: Record<string, unknown>, fieldObjects: FieldObject[], expression: FieldExpression) => Record<string, unknown>;
|
|
4
|
+
export declare const wrapCollectionSelectInExpression: (select: Record<string, unknown>, fieldObjects: FieldObject[], expression: readonly string[]) => Record<string, unknown>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// src/unit-utils/wrap-normalized-in-expression.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
[idField]: idField,
|
|
8
|
-
...
|
|
9
|
-
} :
|
|
10
|
-
|
|
2
|
+
function wrapSelectInExpression(select, fieldObjects, expression, getIdSelect) {
|
|
3
|
+
let nested = select;
|
|
4
|
+
for (let index = expression.length - 1; index >= 0; index--) {
|
|
5
|
+
const idField = index < expression.length - 1 ? fieldObjects[index].typeObject.idField : void 0;
|
|
6
|
+
const inner = idField ? {
|
|
7
|
+
[idField]: getIdSelect(idField, index),
|
|
8
|
+
...nested
|
|
9
|
+
} : nested;
|
|
10
|
+
nested = { [String(expression[index])]: inner };
|
|
11
11
|
}
|
|
12
|
-
return
|
|
13
|
-
}
|
|
14
|
-
|
|
12
|
+
return nested;
|
|
13
|
+
}
|
|
14
|
+
const wrapNormalizedInExpression = (select, fieldObjects, expression) => wrapSelectInExpression(select, fieldObjects, expression, (id) => id);
|
|
15
|
+
const wrapCollectionSelectInExpression = (select, fieldObjects, expression) => wrapSelectInExpression(select, fieldObjects, expression, (id, index) => [...expression.slice(0, index + 1), id]);
|
|
16
|
+
export { wrapCollectionSelectInExpression, wrapNormalizedInExpression };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "26.0.
|
|
3
|
+
"version": "26.0.8",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@fibery/expression-utils": "17.0.
|
|
34
|
-
"@fibery/helpers": "7.
|
|
35
|
-
"@fibery/query-utils": "7.2.
|
|
36
|
-
"@fibery/schema": "13.1.
|
|
33
|
+
"@fibery/expression-utils": "17.0.6",
|
|
34
|
+
"@fibery/helpers": "7.1.0",
|
|
35
|
+
"@fibery/query-utils": "7.2.10",
|
|
36
|
+
"@fibery/schema": "13.1.6",
|
|
37
37
|
"date-fns": "3.6.0",
|
|
38
38
|
"moment": "2.31.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@fibery/expression-utils": "^17.0.
|
|
42
|
-
"@fibery/schema": "^13.1.
|
|
41
|
+
"@fibery/expression-utils": "^17.0.6",
|
|
42
|
+
"@fibery/schema": "^13.1.6"
|
|
43
43
|
}
|
|
44
44
|
}
|