@fibery/views 20.0.1 → 20.0.3

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.
@@ -22,8 +22,10 @@ const parseStart = ({ value, type }) => {
22
22
  throw new NotImplementedError(type);
23
23
  };
24
24
  const parseEnd = ({ value, type, minimumDelta = null }) => {
25
- if (isDateType(type)) if (isRangeType(type)) return parseDate(value).subtract(...minimumDelta || defaultDateDelta).endOf("day");
26
- else return parseDate(value).endOf("day");
25
+ if (isDateType(type)) {
26
+ if (isRangeType(type)) return parseDate(value).subtract(...minimumDelta || defaultDateDelta).endOf("day");
27
+ else return parseDate(value).endOf("day");
28
+ }
27
29
  if (isDateTimeType(type)) return parseDateTime(value).subtract(...minimumDelta || defaultDateTimeDelta).startOf("second");
28
30
  throw new NotImplementedError(type);
29
31
  };
@@ -42,7 +42,8 @@ const getReferenceFieldNormalizedSelectClause = (fieldObject, contextPath) => {
42
42
  const { typeObject } = fieldObject;
43
43
  if (typeObject.isEntityRef) {
44
44
  const pairs = fieldObject.multiRelatedFieldObjects.map((f) => {
45
- const normalizedSelect = normalizeSelect(getReferenceTypeSelectClause({ typeObject: f.holderTypeObject }, [contextPath.concat(f.holderType)]));
45
+ const select = getReferenceTypeSelectClause({ typeObject: f.holderTypeObject }, [contextPath.concat(f.holderType)]);
46
+ const normalizedSelect = normalizeSelect(select);
46
47
  return [f.holderType, {
47
48
  ...normalizedSelect,
48
49
  [isSelectForMultiFieldKey]: true
@@ -16,7 +16,7 @@ function getRichTextQuerySelect({ typeObject, unit: { expression }, includeSnipp
16
16
  ...toSelectMapClause([terminalTypeObject.idField, "Collaboration~Documents/secret"]),
17
17
  ...includeSnippet ? toSelectMapClause([terminalTypeObject.idField, "Collaboration~Documents/Snippet"]) : {}
18
18
  });
19
- return denormalizeSelect([...expression].reverse().reduce((inner, field, reversedIndex) => {
19
+ const nested = [...expression].reverse().reduce((inner, field, reversedIndex) => {
20
20
  const originalIndex = expression.length - 1 - reversedIndex;
21
21
  if (!(originalIndex === expression.length - 1)) {
22
22
  const { idField } = fieldObjects[originalIndex].typeObject;
@@ -27,7 +27,8 @@ function getRichTextQuerySelect({ typeObject, unit: { expression }, includeSnipp
27
27
  return { [field]: innerWithId };
28
28
  }
29
29
  return { [field]: inner };
30
- }, innerNormalized));
30
+ }, innerNormalized);
31
+ return denormalizeSelect(nested);
31
32
  }
32
33
  //#endregion
33
34
  export { getHasAccessToSecret, getHasAccessToSecretExpr, getRichTextQuerySelect, hasAccessToSecretKey };
@@ -1,4 +1,3 @@
1
- import { $TSFixMe } from "../tsfixme.js";
2
1
  //#region src/field-utils/text.d.ts
3
2
  declare const TextUIMetaKey = "ui/type";
4
3
  declare const TextUIMeta: {
@@ -27,12 +26,8 @@ declare const TextTypeToUiMeta: {
27
26
  "ui/type": string;
28
27
  };
29
28
  };
30
- declare const TextUiMetaToTextType: {
31
- [TextUIMeta.Phone]: string;
32
- [TextUIMeta.Email]: string;
33
- [TextUIMeta.URL]: string;
34
- };
35
- declare const getTextType: (fieldMeta: $TSFixMe) => string;
29
+ declare const TextUiMetaToTextType: Record<string, string>;
30
+ declare const getTextType: (fieldMeta: Record<string, unknown>) => string;
36
31
  declare const getTextTypeLabel: (textType: string) => string;
37
32
  //#endregion
38
33
  export { TextTypeToFiberyType, TextTypeToUiMeta, TextTypes, TextUIMeta, TextUIMetaKey, TextUiMetaToTextType, getTextType, getTextTypeLabel };
@@ -25,7 +25,10 @@ const TextUiMetaToTextType = {
25
25
  [TextUIMeta.Email]: TextTypes.CustomEmail,
26
26
  [TextUIMeta.URL]: TextTypes.CustomURL
27
27
  };
28
- const getTextType = (fieldMeta) => TextUiMetaToTextType[fieldMeta["ui/type"]] || "fibery/text";
28
+ const getTextType = (fieldMeta) => {
29
+ const textUiMeta = fieldMeta[TextUIMetaKey];
30
+ return typeof textUiMeta === "string" ? TextUiMetaToTextType[textUiMeta] || "fibery/text" : "fibery/text";
31
+ };
29
32
  const getTextTypeLabel = (textType) => {
30
33
  return {
31
34
  [TextTypes.CustomPhone]: "Phone",
@@ -1,23 +1,23 @@
1
1
  import { isUserActiveDynamicKeyPrefix, makeDynamicKey } from "../unit-utils/dynamic-keys.js";
2
- import { memoize } from "@fibery/helpers/src/_";
2
+ import { memoizeLeak, memoizeWeak } from "@fibery/helpers/src/_";
3
3
  //#region src/field-utils/user-active.ts
4
- const getIsUserActiveQueryPredicate = memoize(({ typeObject, contextPath }) => {
5
- if (typeObject.name !== "fibery/user") return null;
6
- const expression = [
7
- "=",
8
- [...contextPath, "fibery/active?"],
9
- "$true"
10
- ];
11
- return {
12
- key: makeDynamicKey(isUserActiveDynamicKeyPrefix),
13
- expression
14
- };
15
- }, ({ typeObject, contextPath }) => `${typeObject.name}_${typeObject.version}_${contextPath.join(",")}`);
4
+ const noUserActiveQueryPredicate = () => null;
5
+ const getIsUserActiveQueryPredicate = memoizeWeak((typeObject) => {
6
+ if (typeObject.name !== "fibery/user") return noUserActiveQueryPredicate;
7
+ return memoizeLeak((contextPath) => {
8
+ const expression = [
9
+ "=",
10
+ [...contextPath, "fibery/active?"],
11
+ "$true"
12
+ ];
13
+ return {
14
+ key: makeDynamicKey(isUserActiveDynamicKeyPrefix),
15
+ expression
16
+ };
17
+ }, (contextPath) => contextPath.join(","));
18
+ });
16
19
  const getIsUserActiveSelect = ({ typeObject, contextPath = [] }) => {
17
- const isUserActiveQueryPredicate = getIsUserActiveQueryPredicate({
18
- typeObject,
19
- contextPath
20
- });
20
+ const isUserActiveQueryPredicate = getIsUserActiveQueryPredicate(typeObject)(contextPath);
21
21
  return isUserActiveQueryPredicate ? { [isUserActiveQueryPredicate.key]: isUserActiveQueryPredicate.expression } : null;
22
22
  };
23
23
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { isFinalStateDynamicKeyPrefix, makeDynamicKey } from "../unit-utils/dynamic-keys.js";
2
- import { memoize } from "@fibery/helpers/src/_";
2
+ import { memoizeLeak, memoizeWeak } from "@fibery/helpers/src/_";
3
3
  //#region src/field-utils/workflow.ts
4
4
  function isWorkflowType(typeObject) {
5
5
  return typeObject.isEnum && typeObject.nameParts.namespace === "workflow";
@@ -13,9 +13,11 @@ const getWorkflowFieldObject = (typeObject) => {
13
13
  });
14
14
  return workflowFieldObject;
15
15
  };
16
- const getIsFinalStateQueryPredicate = memoize(({ typeObject, contextPath }) => {
16
+ const noFinalStateQueryPredicate = () => null;
17
+ const getIsFinalStateQueryPredicate = memoizeWeak((typeObject) => {
17
18
  const workflowFieldObject = getWorkflowFieldObject(typeObject);
18
- if (workflowFieldObject) {
19
+ if (!workflowFieldObject) return noFinalStateQueryPredicate;
20
+ return memoizeLeak((contextPath) => {
19
21
  const expression = [
20
22
  "=",
21
23
  [
@@ -29,15 +31,10 @@ const getIsFinalStateQueryPredicate = memoize(({ typeObject, contextPath }) => {
29
31
  key: makeDynamicKey(isFinalStateDynamicKeyPrefix),
30
32
  expression
31
33
  };
32
- } else return null;
33
- }, ({ typeObject, contextPath }) => {
34
- return `${typeObject.name}_${typeObject.version}_${contextPath.join(",")}`;
34
+ }, (contextPath) => contextPath.join(","));
35
35
  });
36
36
  const getIsFinalStateSelect = ({ typeObject, contextPath = [] }) => {
37
- const isFinalStateQueryPredicate = getIsFinalStateQueryPredicate({
38
- typeObject,
39
- contextPath
40
- });
37
+ const isFinalStateQueryPredicate = getIsFinalStateQueryPredicate(typeObject)(contextPath);
41
38
  return isFinalStateQueryPredicate ? { [isFinalStateQueryPredicate.key]: isFinalStateQueryPredicate.expression } : null;
42
39
  };
43
40
  function getWorkflowTypeSelect(typeObject) {
@@ -18,6 +18,7 @@ type TimelineMetaItem = {
18
18
  secondaryEndExpression?: Expression | null;
19
19
  contextExpression?: Expression | null;
20
20
  units?: Unit[] | null;
21
+ laneUnits?: Unit[] | null;
21
22
  colorCoding?: {
22
23
  expression: Expression;
23
24
  [k: string]: unknown;
@@ -10,6 +10,7 @@ import set from "lodash/set.js";
10
10
  import some from "lodash/some.js";
11
11
  import has from "lodash/has.js";
12
12
  //#region src/private/timeline.ts
13
+ const visitMetaItemUnits = (fromType, units, visitor) => units ? units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, nextUnits) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, nextUnits) : unit).filter((unit) => unit !== REMOVE) : void 0;
13
14
  const visitAxisSingle = (axis, visitor) => {
14
15
  const fromType = get(axis, ["query", "q/from"]);
15
16
  const firstOrNull = (x) => Array.isArray(x) ? x[0] : null;
@@ -50,7 +51,8 @@ const visitView = (view, visitor) => immutableUpdate(view, { "fibery/meta": {
50
51
  contextExpression: { $apply: (contextExpression) => visitContextExpression(fromType, contextExpression, visitor) },
51
52
  filter: { $apply: (filter) => filter ? visitor.visitFilter(fromType, filter) : null },
52
53
  query: { $apply: (query) => query ? visitor.visitQueryExpression(query) : null },
53
- units: { $apply: (units) => units ? 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 },
54
+ units: { $apply: (units) => visitMetaItemUnits(fromType, units, visitor) },
55
+ laneUnits: { $apply: (laneUnits) => visitMetaItemUnits(fromType, laneUnits, visitor) },
54
56
  colorCoding: { $apply: (colorCodings) => {
55
57
  return colorCodings && colorCodings.map((colorCoding) => ({
56
58
  ...colorCoding,
@@ -1,3 +1,4 @@
1
+ import { AVATAR_EXTENSION_FIELD } from "../field-utils/avatar.js";
1
2
  import { REMOVE } from "./utils.js";
2
3
  import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
3
4
  //#region src/private/units.ts
@@ -33,22 +34,22 @@ const getUnitKind = (unit) => {
33
34
  };
34
35
  const migrateUnitOptsDefault = { migrateFileCollectionUnit: true };
35
36
  const migrateUnit = (schema, fromType, unit, units, opts = migrateUnitOptsDefault) => {
36
- const kind = unit.kind || getUnitKind(unit);
37
+ const legacyUnit = unit;
37
38
  if (unit.type === "date-time") return {
38
39
  ...unit,
39
- kind,
40
+ kind: unit.kind || "field",
40
41
  type: "date"
41
42
  };
42
43
  if (unit.type === "date-time-range") return {
43
44
  ...unit,
44
- kind,
45
+ kind: unit.kind || "field",
45
46
  type: "date-range"
46
47
  };
47
48
  if (unit.type === "text") {
48
49
  const [field] = unit.expression;
49
50
  if (getFieldType(schema, fromType, field) === "fibery/email") return {
50
51
  ...unit,
51
- kind,
52
+ kind: unit.kind || "field",
52
53
  type: "email"
53
54
  };
54
55
  }
@@ -56,7 +57,7 @@ const migrateUnit = (schema, fromType, unit, units, opts = migrateUnitOptsDefaul
56
57
  const [field] = unit.expression;
57
58
  if (getFieldType(schema, fromType, field) === "fibery/text") return {
58
59
  ...unit,
59
- kind,
60
+ kind: unit.kind || "field",
60
61
  type: getUnitTypeForTextField(getFieldMeta(schema, fromType, field))
61
62
  };
62
63
  }
@@ -64,31 +65,33 @@ const migrateUnit = (schema, fromType, unit, units, opts = migrateUnitOptsDefaul
64
65
  const [field] = unit.expression;
65
66
  if (getFieldType(schema, fromType, field) === "fibery/file") return {
66
67
  ...unit,
67
- kind,
68
+ kind: unit.kind || "field",
68
69
  type: opts.migrateFileCollectionUnit ? "file-collection-count" : "collection-count"
69
70
  };
70
71
  }
71
- if (unit.type === "avatar" && !unit.expression) {
72
- const isAvatarExntensionEnabled = schema.typeObjectsByName[fromType]?.installedMixins.has("avatar/avatar-mixin");
73
- const hasAvatarExntensionField = getFieldType(schema, fromType, "avatar/avatars") === "fibery/file";
74
- if (isAvatarExntensionEnabled && hasAvatarExntensionField) return {
75
- ...unit,
76
- expression: ["avatar/avatars"],
77
- kind
78
- };
72
+ if (unit.type === "avatar") {
73
+ if (unit.kind === "db" || !unit.expression) {
74
+ const isAvatarExntensionEnabled = schema.typeObjectsByName[fromType]?.installedMixins.has("avatar/avatar-mixin");
75
+ const hasAvatarExntensionField = getFieldType(schema, fromType, AVATAR_EXTENSION_FIELD) === "fibery/file";
76
+ if (isAvatarExntensionEnabled && hasAvatarExntensionField) return {
77
+ ...unit,
78
+ expression: unit.expression ?? ["avatar/avatars"],
79
+ kind: "field"
80
+ };
81
+ }
79
82
  }
80
83
  if (opts.migrateFileCollectionUnit && unit.type === "collection-count") {
81
84
  const [field] = unit.expression;
82
85
  const fieldObject = getField(schema, fromType, field);
83
86
  if (fieldObject?.type === "fibery/file" && fieldObject?.isCollection) return {
84
87
  ...unit,
85
- kind,
88
+ kind: unit.kind || "field",
86
89
  type: "file-collection-count"
87
90
  };
88
91
  }
89
- return {
90
- ...unit,
91
- kind
92
+ return legacyUnit.kind ? unit : {
93
+ ...legacyUnit,
94
+ kind: getUnitKind(unit)
92
95
  };
93
96
  };
94
97
  const expressionFrom = (unit) => unit.expression;
@@ -1,4 +1,4 @@
1
- import { getAvatarSelectQuery, isAvatarExtensionEnabledType, isAvatarExtensionField } from "../field-utils/avatar.js";
1
+ import { AVATAR_EXTENSION_FIELD, getAvatarSelectQuery, isAvatarExtensionEnabledType, isAvatarExtensionField } from "../field-utils/avatar.js";
2
2
  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";
@@ -19,10 +19,11 @@ const Avatar = {
19
19
  getLabel({ typeObject, unit }) {
20
20
  const { expression } = unit;
21
21
  if (expression) {
22
- if (isAvatarExtensionEnabledType(getFieldObjectByFieldExpression({
22
+ const fieldObject = getFieldObjectByFieldExpression({
23
23
  typeObject,
24
24
  expression
25
- }).typeObject)) return `Avatar of ${getFieldLabel({
25
+ });
26
+ if (isAvatarExtensionEnabledType(fieldObject.typeObject)) return `Avatar of ${getFieldLabel({
26
27
  typeObject,
27
28
  unit
28
29
  })}`;
@@ -32,7 +33,8 @@ const Avatar = {
32
33
  makeUnit(args) {
33
34
  if (!args) return {
34
35
  type,
35
- kind: "db"
36
+ kind: "field",
37
+ expression: [AVATAR_EXTENSION_FIELD]
36
38
  };
37
39
  assertIsValidExpression(args.expression);
38
40
  return {
@@ -57,7 +59,7 @@ const Avatar = {
57
59
  }),
58
60
  getAvatarSelectQuery({ typeObject: terminalFieldObject.typeObject })
59
61
  ].filter(truthy)));
60
- return denormalizeSelect([...expression].reverse().reduce((inner, field, reversedIndex) => {
62
+ const nested = [...expression].reverse().reduce((inner, field, reversedIndex) => {
61
63
  const originalIndex = expression.length - 1 - reversedIndex;
62
64
  if (!(originalIndex === expression.length - 1)) {
63
65
  const { idField } = fieldObjects[originalIndex].typeObject;
@@ -68,7 +70,8 @@ const Avatar = {
68
70
  return { [field]: innerWithId };
69
71
  }
70
72
  return { [field]: inner };
71
- }, innerSelect));
73
+ }, innerSelect);
74
+ return denormalizeSelect(nested);
72
75
  },
73
76
  calculateErrors: calculateUnitExpressionErrors,
74
77
  getExportValue: ({ typeObject, unit, object }) => {
@@ -14,10 +14,11 @@ const CommentsList = {
14
14
  getLabel: getFieldLabel,
15
15
  getQuerySelect: ({ typeObject, unit }) => {
16
16
  const { expression } = unit;
17
- return getQuerySelect(getFieldObjectByFieldExpression({
17
+ const fieldObject = getFieldObjectByFieldExpression({
18
18
  typeObject,
19
19
  expression
20
- }));
20
+ });
21
+ return getQuerySelect(fieldObject);
21
22
  },
22
23
  calculateErrors: calculateUnitExpressionErrors,
23
24
  getExportValue,
@@ -21,11 +21,12 @@ const FileCollectionCount = {
21
21
  expression
22
22
  });
23
23
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
24
- return denormalizeSelect(wrapNormalizedInExpression({
24
+ const collectionNormalized = {
25
25
  "q/from": null,
26
26
  "q/limit": "q/no-limit",
27
27
  "q/select": normalizeSelect(getFilesSelect(terminalFieldObject))
28
- }, fieldObjects, expression));
28
+ };
29
+ return denormalizeSelect(wrapNormalizedInExpression(collectionNormalized, fieldObjects, expression));
29
30
  },
30
31
  getExportValue,
31
32
  canExport: () => true
@@ -21,11 +21,12 @@ const FileCompactCollection = {
21
21
  expression
22
22
  });
23
23
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
24
- return denormalizeSelect(wrapNormalizedInExpression({
24
+ const collectionNormalized = {
25
25
  "q/from": null,
26
26
  "q/limit": "q/no-limit",
27
27
  "q/select": normalizeSelect(getFilesSelect(terminalFieldObject))
28
- }, fieldObjects, expression));
28
+ };
29
+ return denormalizeSelect(wrapNormalizedInExpression(collectionNormalized, fieldObjects, expression));
29
30
  },
30
31
  getExportValue,
31
32
  canExport: () => true
@@ -29,7 +29,8 @@ const FileCompactReference = {
29
29
  expression
30
30
  });
31
31
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
32
- return denormalizeSelect(wrapNormalizedInExpression(getReferenceFieldNormalizedSelectClause(terminalFieldObject, expression), fieldObjects, expression));
32
+ const innerNormalized = getReferenceFieldNormalizedSelectClause(terminalFieldObject, expression);
33
+ return denormalizeSelect(wrapNormalizedInExpression(innerNormalized, fieldObjects, expression));
33
34
  },
34
35
  calculateErrors({ typeObject, unit }) {
35
36
  return calculateUnitExpressionErrors({
@@ -21,7 +21,8 @@ const FileReference = {
21
21
  expression
22
22
  });
23
23
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
24
- return denormalizeSelect(wrapNormalizedInExpression(normalizeSelect(getFilesSelect(terminalFieldObject)), fieldObjects, expression));
24
+ const innerNormalized = normalizeSelect(getFilesSelect(terminalFieldObject));
25
+ return denormalizeSelect(wrapNormalizedInExpression(innerNormalized, fieldObjects, expression));
25
26
  },
26
27
  getExportValue,
27
28
  canExport: () => true
@@ -21,11 +21,12 @@ const FilesGallery = {
21
21
  expression
22
22
  });
23
23
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
24
- return denormalizeSelect(wrapNormalizedInExpression({
24
+ const collectionNormalized = {
25
25
  "q/from": null,
26
26
  "q/limit": "q/no-limit",
27
27
  "q/select": normalizeSelect(getFilesSelect(terminalFieldObject))
28
- }, fieldObjects, expression));
28
+ };
29
+ return denormalizeSelect(wrapNormalizedInExpression(collectionNormalized, fieldObjects, expression));
29
30
  },
30
31
  getExportValue,
31
32
  canExport: () => true
@@ -21,7 +21,8 @@ const FileLListItem = {
21
21
  expression
22
22
  });
23
23
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
24
- return denormalizeSelect(wrapNormalizedInExpression(normalizeSelect(getFilesSelect(terminalFieldObject)), fieldObjects, expression));
24
+ const innerNormalized = normalizeSelect(getFilesSelect(terminalFieldObject));
25
+ return denormalizeSelect(wrapNormalizedInExpression(innerNormalized, fieldObjects, expression));
25
26
  },
26
27
  getExportValue,
27
28
  canExport: () => true
@@ -21,11 +21,12 @@ const FileLList = {
21
21
  expression
22
22
  });
23
23
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
24
- return denormalizeSelect(wrapNormalizedInExpression({
24
+ const collectionNormalized = {
25
25
  "q/from": null,
26
26
  "q/limit": "q/no-limit",
27
27
  "q/select": normalizeSelect(getFilesSelect(terminalFieldObject))
28
- }, fieldObjects, expression));
28
+ };
29
+ return denormalizeSelect(wrapNormalizedInExpression(collectionNormalized, fieldObjects, expression));
29
30
  },
30
31
  getExportValue,
31
32
  canExport: () => true
@@ -21,7 +21,8 @@ const FileListItem = {
21
21
  expression
22
22
  });
23
23
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
24
- return denormalizeSelect(wrapNormalizedInExpression(normalizeSelect(getFilesSelect(terminalFieldObject)), fieldObjects, expression));
24
+ const innerNormalized = normalizeSelect(getFilesSelect(terminalFieldObject));
25
+ return denormalizeSelect(wrapNormalizedInExpression(innerNormalized, fieldObjects, expression));
25
26
  },
26
27
  getExportValue,
27
28
  canExport: () => true
@@ -21,11 +21,12 @@ const FileList = {
21
21
  expression
22
22
  });
23
23
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
24
- return denormalizeSelect(wrapNormalizedInExpression({
24
+ const collectionNormalized = {
25
25
  "q/from": null,
26
26
  "q/limit": "q/no-limit",
27
27
  "q/select": normalizeSelect(getFilesSelect(terminalFieldObject))
28
- }, fieldObjects, expression));
28
+ };
29
+ return denormalizeSelect(wrapNormalizedInExpression(collectionNormalized, fieldObjects, expression));
29
30
  },
30
31
  getExportValue,
31
32
  canExport: () => true
@@ -12,11 +12,12 @@ const ReferenceCollection = {
12
12
  getLabel: getFieldLabel,
13
13
  makeUnit: makeUnitMethod(type),
14
14
  getQuerySelect({ typeObject, unit: { expression } }) {
15
+ const fieldObjects = getFieldObjectsByFieldExpression({
16
+ typeObject,
17
+ expression
18
+ });
15
19
  return calculateReferenceCollectionQuery({
16
- fieldObjects: getFieldObjectsByFieldExpression({
17
- typeObject,
18
- expression
19
- }),
20
+ fieldObjects,
20
21
  expression,
21
22
  limit: REFERENCE_COLLECTION_LIMIT
22
23
  });
@@ -29,7 +29,7 @@ const Reference = {
29
29
  });
30
30
  const terminalFieldObject = fieldObjects[fieldObjects.length - 1];
31
31
  const innerNormalized = getReferenceFieldNormalizedSelectClause(terminalFieldObject, expression);
32
- return denormalizeSelect([...expression].reverse().reduce((inner, field, reversedIndex) => {
32
+ const nested = [...expression].reverse().reduce((inner, field, reversedIndex) => {
33
33
  const originalIndex = expression.length - 1 - reversedIndex;
34
34
  if (!(originalIndex === expression.length - 1)) {
35
35
  const { idField } = fieldObjects[originalIndex].typeObject;
@@ -40,7 +40,8 @@ const Reference = {
40
40
  return { [field]: innerWithId };
41
41
  }
42
42
  return { [field]: inner };
43
- }, innerNormalized));
43
+ }, innerNormalized);
44
+ return denormalizeSelect(nested);
44
45
  },
45
46
  calculateErrors({ typeObject, unit }) {
46
47
  const errors = calculateUnitExpressionErrors({
@@ -1,5 +1,4 @@
1
- import { $TSFixMe } from "../tsfixme.js";
2
- import { FieldUnit, PureUnit, Unit, UnitExpression } from "../units/types.js";
1
+ import { FieldUnit, Unit, UnitExpression } from "../units/types.js";
3
2
  import { TypeObject } from "@fibery/schema";
4
3
  //#region src/unit-utils/common.d.ts
5
4
  declare const makeUnitMethod: (type: FieldUnit["type"]) => ({ expression }?: {
@@ -10,8 +9,29 @@ declare const calculateUnitExpressionErrors: ({ typeObject, unit }: {
10
9
  unit: Unit;
11
10
  }) => string[];
12
11
  declare const isUnitEnabled: (unit: Unit) => boolean;
13
- declare const toPureUnit: (unit: Unit) => PureUnit;
14
- declare const asString: (something: $TSFixMe) => string;
12
+ declare const toPureUnit: (unit: Unit) => {
13
+ kind: "user-button";
14
+ type: "user-button" | "icon-button";
15
+ data: {
16
+ id: string;
17
+ typeId: string;
18
+ };
19
+ label: string;
20
+ hideWhenEmpty?: boolean;
21
+ icon?: string;
22
+ } | {
23
+ kind: "db";
24
+ type: "type-icon" | "type-badge" | "type-badge-abbr";
25
+ expression?: UnitExpression;
26
+ hideWhenEmpty?: boolean;
27
+ } | {
28
+ kind: "field";
29
+ type: "avatar" | "avatar-collection" | "avatar-input" | "back-references-list" | "bool" | "bool-checkbox" | "collection-count" | "color-input" | "comments-list" | "date" | "date-time" | "date-time-range" | "date-time-combobox" | "date-range" | "date-range-combobox" | "email" | "email-input" | "emoji" | "field" | "files-collection" | "files-gallery" | "files-list" | "files-list-item" | "files-l-list" | "files-l-list-item" | "file-reference" | "file-compact-collection" | "file-compact-reference" | "file-collection-count" | "geometry-preview" | "icon-button" | "icon-input" | "id" | "json-input" | "location" | "location-input" | "number" | "number-input" | "phone" | "phone-input" | "progress-bar" | "reference" | "reference-icon" | "reference-combobox" | "reference-collection" | "reference-collection-list" | "reference-collection-view" | "reference-collection-combobox" | "rich-text-snippet" | "rich-text-document" | "single-location-preview" | "text" | "text-input" | "title" | "title-input" | "url" | "url-input" | "user-role" | "user-role-input";
30
+ expression: UnitExpression;
31
+ settings?: Record<string, unknown>;
32
+ hideWhenEmpty?: boolean;
33
+ };
34
+ declare const asString: (something: unknown) => string;
15
35
  declare const canEditFieldExpression: (typeObject: TypeObject, expression: UnitExpression) => boolean;
16
36
  //#endregion
17
37
  export { asString, calculateUnitExpressionErrors, canEditFieldExpression, isUnitEnabled, makeUnitMethod, toPureUnit };
@@ -1,5 +1,4 @@
1
1
  import { getUnmatchedUnitLabel } from "./get-unmatched-unit-label.js";
2
- import omit from "lodash/omit.js";
3
2
  import { assertIsValidExpression, getFieldObjectByFieldExpression, isFieldExpressionValid } from "@fibery/expression-utils/src/utils";
4
3
  //#region src/unit-utils/common.ts
5
4
  const makeUnitMethod = (type) => ({ expression } = {}) => {
@@ -21,7 +20,10 @@ const isUnitEnabled = (unit) => {
21
20
  const { checked } = unit;
22
21
  return checked === void 0 || checked === true;
23
22
  };
24
- const toPureUnit = (unit) => omit(unit, ["checked"]);
23
+ const toPureUnit = (unit) => {
24
+ const { checked: _checked, ...pureUnit } = unit;
25
+ return pureUnit;
26
+ };
25
27
  const asString = (something) => typeof something === "string" ? something : JSON.stringify(something);
26
28
  const canEditFieldExpression = (typeObject, expression) => {
27
29
  if (isFieldExpressionValid({
@@ -1,5 +1,4 @@
1
1
  import { NumberDisplaySettings } from "../../field-utils/number.js";
2
- import { $TSFixMe } from "../../tsfixme.js";
3
2
  import { DbUnit, PureUnit, UnitExpression } from "../types.js";
4
3
  import { TypeObject } from "@fibery/schema";
5
4
  //#region src/units/canvas/type-badge-abbr.d.ts
@@ -20,7 +19,7 @@ declare const TypeBadgeAbbr: {
20
19
  calculateErrors: (params: {
21
20
  typeObject: TypeObject;
22
21
  unit: DbUnit;
23
- }) => $TSFixMe[];
22
+ }) => string[];
24
23
  getExportValue: (params: {
25
24
  typeObject: TypeObject;
26
25
  unit: DbUnit;
@@ -1,5 +1,4 @@
1
1
  import { NumberDisplaySettings } from "../../field-utils/number.js";
2
- import { $TSFixMe } from "../../tsfixme.js";
3
2
  import { DbUnit, PureUnit, UnitExpression } from "../types.js";
4
3
  import { TypeObject } from "@fibery/schema";
5
4
  //#region src/units/canvas/type-badge.d.ts
@@ -20,7 +19,7 @@ declare const TypeBadge: {
20
19
  calculateErrors: (params: {
21
20
  typeObject: TypeObject;
22
21
  unit: DbUnit;
23
- }) => $TSFixMe[];
22
+ }) => string[];
24
23
  getExportValue: (params: {
25
24
  typeObject: TypeObject;
26
25
  unit: DbUnit;
@@ -180,13 +180,14 @@ const makeUnitDefinitionsFactory = (allUnitDefinitions) => {
180
180
  * @returns flat list of all units for given type
181
181
  */
182
182
  function getUnitsForType(typeObject, options = {}) {
183
- return sortBy(flatMap(typeObject.fieldObjects.filter((x) => !x.isHidden), (fieldObject) => getUnitsForField(fieldObject, options).map((unit) => ({
183
+ const collection = flatMap(typeObject.fieldObjects.filter((x) => !x.isHidden), (fieldObject) => getUnitsForField(fieldObject, options).map((unit) => ({
184
184
  unit,
185
185
  fieldObject
186
186
  }))).concat(getTypeUnits().map((unit) => ({
187
187
  unit,
188
188
  fieldObject: typeObject.titleFieldObject
189
- }))), ({ unit }) => {
189
+ })));
190
+ return sortBy(collection, ({ unit }) => {
190
191
  const index = staticUnitsTypeOrder.indexOf(unit.type);
191
192
  return index === -1 ? staticUnitsTypeOrder.length : index;
192
193
  });
@@ -240,7 +241,7 @@ const makeUnitDefinitionsFactory = (allUnitDefinitions) => {
240
241
  return NotFound;
241
242
  };
242
243
  const getCardUnitsSelect = ({ schema, typeObject, units }) => {
243
- return mergeDenormalizedSelects(units.filter((unit) => {
244
+ const selects = units.filter((unit) => {
244
245
  return isUnitEnabled(unit) && unit.kind !== "user-button" && !unit.expression?.includes("documents/documents") && !unit.expression?.includes("whiteboards/whiteboards");
245
246
  }).map((unit) => {
246
247
  if (calculateUnitExpressionErrors({
@@ -254,7 +255,8 @@ const makeUnitDefinitionsFactory = (allUnitDefinitions) => {
254
255
  });
255
256
  assert(isPlainObject(select), "getQuerySelect must return object-shaped select");
256
257
  return select;
257
- }));
258
+ });
259
+ return mergeDenormalizedSelects(selects);
258
260
  };
259
261
  return {
260
262
  getTypeUnits,
@@ -1,5 +1,4 @@
1
1
  import { NumberDisplaySettings } from "../field-utils/number.js";
2
- import { $TSFixMe } from "../tsfixme.js";
3
2
  import { Schema, TypeObject } from "@fibery/schema";
4
3
  import { FiberyObject } from "@fibery/expression-utils/src/types";
5
4
  //#region src/units/types.d.ts
@@ -52,11 +51,11 @@ type UnitDataDefinition<T extends Unit> = {
52
51
  typeObject: TypeObject;
53
52
  unit: T;
54
53
  schema: Schema;
55
- }) => $TSFixMe;
54
+ }) => Record<string, unknown>;
56
55
  calculateErrors: (params: {
57
56
  typeObject: TypeObject;
58
57
  unit: T;
59
- }) => $TSFixMe[];
58
+ }) => string[];
60
59
  getExportValue: (params: {
61
60
  typeObject: TypeObject;
62
61
  unit: T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/views",
3
- "version": "20.0.1",
3
+ "version": "20.0.3",
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": "10.0.1",
37
- "@fibery/helpers": "3.2.1",
38
- "@fibery/query-utils": "2.0.1",
39
- "@fibery/schema": "10.3.1"
36
+ "@fibery/expression-utils": "10.0.3",
37
+ "@fibery/query-utils": "2.0.3",
38
+ "@fibery/helpers": "3.3.0",
39
+ "@fibery/schema": "10.3.2"
40
40
  },
41
41
  "peerDependencies": {
42
- "@fibery/expression-utils": "^10.0.1",
43
- "@fibery/schema": "^10.3.1",
42
+ "@fibery/expression-utils": "^10.0.3",
43
+ "@fibery/schema": "^10.3.2",
44
44
  "immutability-helper": "^2.4.0",
45
45
  "lodash": "4.17.21"
46
46
  }
package/lib/tsfixme.d.ts DELETED
@@ -1,4 +0,0 @@
1
- //#region src/tsfixme.d.ts
2
- type $TSFixMe = any;
3
- //#endregion
4
- export { $TSFixMe };
package/lib/tsfixme.js DELETED
File without changes