@fibery/expression-utils 1.1.17 → 1.1.19
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/expression-utils.js +4 -1
- package/lib/visitors.js +4 -1
- package/package.json +1 -1
- package/types.d.ts +27 -2
package/lib/expression-utils.js
CHANGED
|
@@ -639,12 +639,15 @@ const getExpressionTypeInternal = ({
|
|
|
639
639
|
typeObject,
|
|
640
640
|
functionsMeta,
|
|
641
641
|
onFieldNotFound,
|
|
642
|
-
returnRefTypeInsteadOfId: firstLastFunctions.has(fnName) ? returnRefTypeInsteadOfId : false
|
|
642
|
+
returnRefTypeInsteadOfId: firstLastFunctions.has(fnName) || fnName === "q/if" ? returnRefTypeInsteadOfId : false
|
|
643
643
|
}));
|
|
644
644
|
if (firstLastFunctions.has(fnName)) {
|
|
645
645
|
//assuming q/first has one argument and result type equals arg type.
|
|
646
646
|
//we need this trick to support 'returnRefTypeInsteadOfId' behavior for q/first and q/last.
|
|
647
647
|
result = argTypes[0];
|
|
648
|
+
} else if (fnName === "q/if") {
|
|
649
|
+
//we need this trick to support 'returnRefTypeInsteadOfId' behavior for q/if.
|
|
650
|
+
result = argTypes[1];
|
|
648
651
|
} else {
|
|
649
652
|
const overload = fnMeta.overloads.find(o => o["arg-types"].every((argType, index) => argTypes[index] === UNKNOWN_EXPRESSION_TYPE || argTypes[index] === argType));
|
|
650
653
|
if (!overload) {
|
package/lib/visitors.js
CHANGED
|
@@ -383,12 +383,15 @@ const getExpressionTypeInternal = ({
|
|
|
383
383
|
typeObject,
|
|
384
384
|
functionsMeta,
|
|
385
385
|
onFieldNotFound,
|
|
386
|
-
returnRefTypeInsteadOfId: firstLastFunctions.has(fnName) ? returnRefTypeInsteadOfId : false
|
|
386
|
+
returnRefTypeInsteadOfId: firstLastFunctions.has(fnName) || fnName === "q/if" ? returnRefTypeInsteadOfId : false
|
|
387
387
|
}));
|
|
388
388
|
if (firstLastFunctions.has(fnName)) {
|
|
389
389
|
//assuming q/first has one argument and result type equals arg type.
|
|
390
390
|
//we need this trick to support 'returnRefTypeInsteadOfId' behavior for q/first and q/last.
|
|
391
391
|
result = argTypes[0];
|
|
392
|
+
} else if (fnName === "q/if") {
|
|
393
|
+
//we need this trick to support 'returnRefTypeInsteadOfId' behavior for q/if.
|
|
394
|
+
result = argTypes[1];
|
|
392
395
|
} else {
|
|
393
396
|
const overload = fnMeta.overloads.find(o => o["arg-types"].every((argType, index) => argTypes[index] === UNKNOWN_EXPRESSION_TYPE || argTypes[index] === argType));
|
|
394
397
|
if (!overload) {
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
-
import {TypeObject} from "@fibery/schema";
|
|
2
|
+
import {Schema, TypeObject} from "@fibery/schema";
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
5
|
export type $TSFixMe = any;
|
|
@@ -26,9 +26,34 @@ declare module "@fibery/expression-utils" {
|
|
|
26
26
|
}) => $TSFixMe
|
|
27
27
|
): $TSFixMe;
|
|
28
28
|
|
|
29
|
-
deleteExpressionsWithNotFoundFieldsVisitor(typeObject): $TSFixMe;
|
|
29
|
+
deleteExpressionsWithNotFoundFieldsVisitor(typeObject: TypeObject): $TSFixMe;
|
|
30
|
+
getExpressionType({
|
|
31
|
+
expression,
|
|
32
|
+
typeObject,
|
|
33
|
+
functionsMeta,
|
|
34
|
+
onFieldNotFound,
|
|
35
|
+
returnRefTypeInsteadOfId,
|
|
36
|
+
}: {
|
|
37
|
+
expression: $TSFixMe;
|
|
38
|
+
typeObject: TypeObject;
|
|
39
|
+
functionsMeta: Record<string, $TSFixMe>;
|
|
40
|
+
onFieldNotFound?: (input: {currentTypeObject: TypeObject; fieldId: string}) => {currentTypeObject: TypeObject};
|
|
41
|
+
returnRefTypeInsteadOfId?: boolean;
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
export const utils: {
|
|
45
|
+
createExpressionVisitor: (visitor: $TSFixMe) => {visitExpression: (expression: $TSFixMe) => $TSFixMe};
|
|
46
|
+
firstLastFunctions: Set<string>;
|
|
47
|
+
isQueryExpression: (expression: $TSFixMe) => boolean;
|
|
48
|
+
isVariableExpression: (expression: $TSFixMe) => boolean;
|
|
49
|
+
};
|
|
50
|
+
export const contextVariables: {
|
|
51
|
+
getEntityQueryVariables: (
|
|
52
|
+
schema: Schema
|
|
53
|
+
) => Array<{typeObject: TypeObject; id: string; title: string; isCollection: boolean; description: string}>;
|
|
30
54
|
};
|
|
31
55
|
export const paramsPlaceholders: {
|
|
56
|
+
formulaTodayDateParamPlaceholder: string;
|
|
32
57
|
dynamicFilterParamPrefix: string;
|
|
33
58
|
|
|
34
59
|
isDynamicFilterParam(paramValue: string): boolean;
|