@fibery/views 21.0.0 → 22.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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TypeObject } from "@fibery/schema";
|
|
2
2
|
import { FieldExpression } from "@fibery/expression-utils";
|
|
3
|
+
import { FiberyObject } from "@fibery/expression-utils/src/types";
|
|
3
4
|
//#region src/field-utils/workflow.d.ts
|
|
4
5
|
declare function isWorkflowType(typeObject: TypeObject): boolean;
|
|
5
6
|
declare const getWorkflowFieldObject: (typeObject: TypeObject) => import("@fibery/schema").FieldObject | undefined;
|
|
@@ -9,10 +10,16 @@ declare const getIsFinalStateSelect: ({ typeObject, contextPath }: {
|
|
|
9
10
|
}) => {
|
|
10
11
|
[x: string]: (string | (string | import("@fibery/expression-utils").MultiFieldAccess)[])[];
|
|
11
12
|
} | null;
|
|
13
|
+
/** Reads the final-state flag off an already-fetched object, keyed the same way the select writes it. */
|
|
14
|
+
declare const getIsInFinalState: ({ typeObject, object, contextPath }: {
|
|
15
|
+
typeObject: TypeObject;
|
|
16
|
+
object: FiberyObject;
|
|
17
|
+
contextPath?: FieldExpression;
|
|
18
|
+
}) => boolean | null | undefined;
|
|
12
19
|
declare function getWorkflowTypeSelect(typeObject: TypeObject): {
|
|
13
20
|
"workflow/Type": string[];
|
|
14
21
|
} | {
|
|
15
22
|
"workflow/Type"?: undefined;
|
|
16
23
|
};
|
|
17
24
|
//#endregion
|
|
18
|
-
export { getIsFinalStateSelect, getWorkflowFieldObject, getWorkflowTypeSelect, isWorkflowType };
|
|
25
|
+
export { getIsFinalStateSelect, getIsInFinalState, getWorkflowFieldObject, getWorkflowTypeSelect, isWorkflowType };
|
|
@@ -37,9 +37,15 @@ const getIsFinalStateSelect = ({ typeObject, contextPath = [] }) => {
|
|
|
37
37
|
const isFinalStateQueryPredicate = getIsFinalStateQueryPredicate(typeObject)(contextPath);
|
|
38
38
|
return isFinalStateQueryPredicate ? { [isFinalStateQueryPredicate.key]: isFinalStateQueryPredicate.expression } : null;
|
|
39
39
|
};
|
|
40
|
+
/** Reads the final-state flag off an already-fetched object, keyed the same way the select writes it. */
|
|
41
|
+
const getIsInFinalState = ({ typeObject, object, contextPath = [] }) => {
|
|
42
|
+
const isFinalStateQueryPredicate = getIsFinalStateQueryPredicate(typeObject)(contextPath);
|
|
43
|
+
if (!isFinalStateQueryPredicate) return null;
|
|
44
|
+
return object[isFinalStateQueryPredicate.key];
|
|
45
|
+
};
|
|
40
46
|
function getWorkflowTypeSelect(typeObject) {
|
|
41
47
|
if (isWorkflowType(typeObject)) return { "workflow/Type": ["workflow/Type"] };
|
|
42
48
|
return {};
|
|
43
49
|
}
|
|
44
50
|
//#endregion
|
|
45
|
-
export { getIsFinalStateSelect, getWorkflowFieldObject, getWorkflowTypeSelect, isWorkflowType };
|
|
51
|
+
export { getIsFinalStateSelect, getIsInFinalState, getWorkflowFieldObject, getWorkflowTypeSelect, isWorkflowType };
|
package/lib/private/units.js
CHANGED
|
@@ -2,12 +2,12 @@ import { AVATAR_EXTENSION_FIELD } from "../field-utils/avatar.js";
|
|
|
2
2
|
import { REMOVE } from "./utils.js";
|
|
3
3
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
4
4
|
//#region src/private/units.ts
|
|
5
|
-
const getField = (schema, fromType, field) => schema.getTypeObjectByName(fromType)?.getFieldObjectByName(field);
|
|
5
|
+
const getField = (schema, fromType, field) => schema.getTypeObjectByName(fromType)?.getFieldObjectByName(field) ?? null;
|
|
6
6
|
const getFieldType = (schema, fromType, field) => getField(schema, fromType, field)?.type;
|
|
7
7
|
const getFieldMeta = (schema, fromType, field) => getField(schema, fromType, field)?.rawMeta;
|
|
8
8
|
const getFieldByExpression = (schema, fromType, expression) => {
|
|
9
9
|
let currentType = fromType;
|
|
10
|
-
let fieldObject;
|
|
10
|
+
let fieldObject = null;
|
|
11
11
|
for (const part of expression) {
|
|
12
12
|
fieldObject = getField(schema, currentType, part);
|
|
13
13
|
if (!fieldObject) return null;
|
|
@@ -211,14 +211,20 @@ const makeUnitDefinitionsFactory = (allUnitDefinitions) => {
|
|
|
211
211
|
}).sort((a, b) => a - b)[0];
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
|
+
const hardcodedFieldNames = [
|
|
215
|
+
"fibery/creation-date",
|
|
216
|
+
"fibery/container-app",
|
|
217
|
+
"fibery/container-entity-id",
|
|
218
|
+
"fibery/container-entity-type"
|
|
219
|
+
];
|
|
214
220
|
const getHardcodedUnitsForView = (typeObject) => {
|
|
215
221
|
return [
|
|
216
222
|
TypeIcon && TypeIcon.makeUnit(),
|
|
217
223
|
Title && Title.makeUnit(),
|
|
218
|
-
...
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
...hardcodedFieldNames.flatMap((name) => {
|
|
225
|
+
const fieldObject = typeObject.getFieldObjectByName(name);
|
|
226
|
+
return fieldObject ? getUnitsForField(fieldObject) : [];
|
|
227
|
+
})
|
|
222
228
|
].filter(Boolean);
|
|
223
229
|
};
|
|
224
230
|
const unitDefinitionsByTypeLookup = mapValues(groupBy(allUnitDefinitions, (x) => x.type), (value) => single(value));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"date-fns": "2.29.2",
|
|
34
34
|
"lodash": "4.17.21",
|
|
35
35
|
"moment": "2.29.4",
|
|
36
|
-
"@fibery/expression-utils": "
|
|
37
|
-
"@fibery/query-utils": "3.0.0",
|
|
36
|
+
"@fibery/expression-utils": "12.0.0",
|
|
38
37
|
"@fibery/helpers": "3.3.1",
|
|
39
|
-
"@fibery/
|
|
38
|
+
"@fibery/query-utils": "4.0.0",
|
|
39
|
+
"@fibery/schema": "11.1.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@fibery/expression-utils": "^
|
|
43
|
-
"@fibery/schema": "^11.
|
|
42
|
+
"@fibery/expression-utils": "^12.0.0",
|
|
43
|
+
"@fibery/schema": "^11.1.0",
|
|
44
44
|
"immutability-helper": "^2.4.0",
|
|
45
45
|
"lodash": "4.17.21"
|
|
46
46
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Schema } from "@fibery/schema";
|
|
2
|
-
//#region src/unit-utils/schema.d.ts
|
|
3
|
-
declare const extractTypePart: (type: string) => string;
|
|
4
|
-
declare const extractTypeNamespacePart: (type: string) => string;
|
|
5
|
-
declare const getTypeById: (schema: Schema, id: string) => import("@fibery/schema").TypeObject | null;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { extractTypeNamespacePart, extractTypePart, getTypeById };
|
package/lib/unit-utils/schema.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { parseType } from "@fibery/schema";
|
|
2
|
-
//#region src/unit-utils/schema.ts
|
|
3
|
-
const extractTypePart = (type) => parseType(type).name;
|
|
4
|
-
const extractTypeNamespacePart = (type) => parseType(type).namespace;
|
|
5
|
-
const getTypeById = (schema, id) => {
|
|
6
|
-
return schema.getTypeObjectById(id);
|
|
7
|
-
};
|
|
8
|
-
//#endregion
|
|
9
|
-
export { extractTypeNamespacePart, extractTypePart, getTypeById };
|