@fibery/expression-utils 9.0.6 → 9.1.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.
@@ -832,7 +832,7 @@ const getExpressionTypeInternal = ({
832
832
  typeObject,
833
833
  functionsMeta,
834
834
  onFieldNotFound,
835
- returnRefTypeInsteadOfId: firstLastFunctions.has(fnName) || fnName === "q/if" ? returnRefTypeInsteadOfId : false
835
+ returnRefTypeInsteadOfId: firstLastFunctions.has(fnName) || fnName === "q/if" || fnName === "q/if-null" ? returnRefTypeInsteadOfId : false
836
836
  }));
837
837
  if (firstLastFunctions.has(fnName)) {
838
838
  //assuming q/first has one argument and result type equals arg type.
@@ -841,6 +841,9 @@ const getExpressionTypeInternal = ({
841
841
  } else if (fnName === "q/if") {
842
842
  //we need this trick to support 'returnRefTypeInsteadOfId' behavior for q/if.
843
843
  result = argTypes[1];
844
+ } else if (fnName === "q/if-null" && argTypes.some(x => !x.isPrimitive)) {
845
+ //we need this trick to support 'returnRefTypeInsteadOfId' behavior for q/if.
846
+ result = argTypes[0];
844
847
  } else {
845
848
  const overload = fnMeta.overloads.find(o => o["arg-types"].every((argType, index) => argTypes[index] === UNKNOWN_EXPRESSION_TYPE || argTypes[index] === argType || ["fibery/email", "fibery/url", "fibery/emoji", "fibery/color"].includes(argTypes[index]) && argType === "fibery/text"));
846
849
  if (!overload) {
package/lib/visitors.js CHANGED
@@ -567,7 +567,7 @@ const getExpressionTypeInternal = ({
567
567
  typeObject,
568
568
  functionsMeta,
569
569
  onFieldNotFound,
570
- returnRefTypeInsteadOfId: firstLastFunctions.has(fnName) || fnName === "q/if" ? returnRefTypeInsteadOfId : false
570
+ returnRefTypeInsteadOfId: firstLastFunctions.has(fnName) || fnName === "q/if" || fnName === "q/if-null" ? returnRefTypeInsteadOfId : false
571
571
  }));
572
572
  if (firstLastFunctions.has(fnName)) {
573
573
  //assuming q/first has one argument and result type equals arg type.
@@ -576,6 +576,9 @@ const getExpressionTypeInternal = ({
576
576
  } else if (fnName === "q/if") {
577
577
  //we need this trick to support 'returnRefTypeInsteadOfId' behavior for q/if.
578
578
  result = argTypes[1];
579
+ } else if (fnName === "q/if-null" && argTypes.some(x => !x.isPrimitive)) {
580
+ //we need this trick to support 'returnRefTypeInsteadOfId' behavior for q/if.
581
+ result = argTypes[0];
579
582
  } else {
580
583
  const overload = fnMeta.overloads.find(o => o["arg-types"].every((argType, index) => argTypes[index] === UNKNOWN_EXPRESSION_TYPE || argTypes[index] === argType || ["fibery/email", "fibery/url", "fibery/emoji", "fibery/color"].includes(argTypes[index]) && argType === "fibery/text"));
581
584
  if (!overload) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/expression-utils",
3
- "version": "9.0.6",
3
+ "version": "9.1.0",
4
4
  "description": "utils for working with fibery api expressions",
5
5
  "exports": {
6
6
  ".": "./lib/expression-utils.js",
@@ -34,8 +34,8 @@
34
34
  "jest": "27.5.1",
35
35
  "jest-junit": "13.0.0",
36
36
  "microbundle": "0.15.1",
37
- "@fibery/eslint-config": "8.6.0",
38
- "@fibery/babel-preset": "7.4.0"
37
+ "@fibery/babel-preset": "7.4.0",
38
+ "@fibery/eslint-config": "8.6.0"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@fibery/schema": "10.2.2"