@fibery/expression-utils 17.0.2 → 17.0.4
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-expression-visitor-type-aware.js +1 -1
- package/lib/filter-expression/operator-utils.js +3 -3
- package/lib/filter-expression/operators.js +3 -3
- package/lib/filter-expression/pattern-match.js +2 -2
- package/lib/params-placeholders.js +1 -1
- package/lib/utils.js +2 -2
- package/lib/visitors.js +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createExpressionVisitor, isMultiFieldAccess } from "./utils.js";
|
|
2
|
-
import { mapValues } from "@fibery/helpers/src/
|
|
2
|
+
import { mapValues } from "@fibery/helpers/src/object";
|
|
3
3
|
import isPlainObject from "lodash/isPlainObject.js";
|
|
4
4
|
//#region src/field-expression-visitor-type-aware.ts
|
|
5
5
|
const visitFieldExpression = ({ expression: fieldExpression, typeObject: initialTypeObject, onField, onFieldNotFound }) => fieldExpression.reduce(({ typeObject, expression }, fieldAccess) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { doPatternMatch, isExpressionPatternMatch, isParamPatternMatch } from "./pattern-match.js";
|
|
2
2
|
import { dateToDateTimeIntervalLookup, monthAgoDateParamPlaceholder, monthAgoStartDateTimeParamPlaceholder, monthFromNowDateParamPlaceholder, monthFromNowEndDateTimeParamPlaceholder, paramsPlaceholdersLookup, parseRelativeDatePlaceholder, toRelativeDatePlaceholder, todayDateParamPlaceholder, todayEndDateTimeParamPlaceholder, weekAgoDateParamPlaceholder, weekAgoStartDateTimeParamPlaceholder, weekFromNowDateParamPlaceholder, weekFromNowEndDateTimeParamPlaceholder, yearAgoDateParamPlaceholder, yearAgoStartDateTimeParamPlaceholder, yearFromNowDateParamPlaceholder, yearFromNowEndDateTimeParamPlaceholder } from "../params-placeholders.js";
|
|
3
3
|
import { dateTimeOrDateTimeRangeExpressionPlaceholder, getParamPlaceholder } from "./pattern-match-placeholders.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isObjectLike } from "@fibery/helpers/src/object";
|
|
5
5
|
import isString from "lodash/isString.js";
|
|
6
6
|
import { deepEqual } from "@fibery/helpers/src/equal";
|
|
7
7
|
import findKey from "lodash/findKey.js";
|
|
@@ -9,7 +9,7 @@ import findKey from "lodash/findKey.js";
|
|
|
9
9
|
const isDateTime = (dateString) => dateString.length === 24 || dateString.length === 10;
|
|
10
10
|
const NO_VALUE = void 0;
|
|
11
11
|
const isNoValue = (value) => {
|
|
12
|
-
if (
|
|
12
|
+
if (isObjectLike(value) && "withinRangeStart" in value && "withinRangeEnd" in value) return value.withinRangeStart === void 0 && value.withinRangeEnd === void 0;
|
|
13
13
|
return value === void 0;
|
|
14
14
|
};
|
|
15
15
|
const getCompareOperatorForDateTime = (id, title, operator, compareByStartInterval, isNegative) => ({
|
|
@@ -105,7 +105,7 @@ const getWithinRangeParam = ({ withinRangeValue, getNextParamName }) => {
|
|
|
105
105
|
value: withinRangeValue
|
|
106
106
|
};
|
|
107
107
|
};
|
|
108
|
-
const isWithinRangeValue = (value) =>
|
|
108
|
+
const isWithinRangeValue = (value) => isObjectLike(value) && "withinRangeStart" in value && "withinRangeEnd" in value;
|
|
109
109
|
const getWithinOperatorCustomConvertFn = (leftPartExcluded) => {
|
|
110
110
|
return (expression, value, getNextParamName) => {
|
|
111
111
|
const withinRangeValue = isWithinRangeValue(value) ? value : null;
|
|
@@ -5,11 +5,11 @@ import { anyDateExpressionPlaceholder, boolFieldPlaceholder, collectionCountExpr
|
|
|
5
5
|
import { getCompareOperatorForDateTime, getWithinOperatorCustomConvertFn, getWithinOperatorCustomMatchFn, isDateTime, isNoValue } from "./operator-utils.js";
|
|
6
6
|
import { convertToExpression } from "./pattern-to-expression.js";
|
|
7
7
|
import flatten from "lodash/flatten.js";
|
|
8
|
-
import { mapValues } from "@fibery/helpers/src/
|
|
8
|
+
import { mapValues } from "@fibery/helpers/src/object";
|
|
9
9
|
import isString from "lodash/isString.js";
|
|
10
10
|
import last from "lodash/last.js";
|
|
11
|
-
import { validate } from "uuid";
|
|
12
11
|
import { deepEqual } from "@fibery/helpers/src/equal";
|
|
12
|
+
import { isUuid } from "@fibery/helpers/src/id";
|
|
13
13
|
import findKey from "lodash/findKey.js";
|
|
14
14
|
import uniq from "lodash/uniq.js";
|
|
15
15
|
//#region src/filter-expression/operators.ts
|
|
@@ -127,7 +127,7 @@ const operatorReferenceIsNotMe = getReferenceMeOperator({
|
|
|
127
127
|
isNegative: true
|
|
128
128
|
});
|
|
129
129
|
function isValidReferenceUUID(val) {
|
|
130
|
-
return isString(val) && (
|
|
130
|
+
return isString(val) && (isUuid(val) || isDynamicFilterParam(val));
|
|
131
131
|
}
|
|
132
132
|
const operatorReferenceIs = {
|
|
133
133
|
id: ":operator/reference-is",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getFieldObjectByFieldExpression, isFieldExpressionValid, isVariableExpression } from "../utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isObjectLike } from "@fibery/helpers/src/object";
|
|
3
3
|
import isPlainObject from "lodash/isPlainObject.js";
|
|
4
4
|
import isString from "lodash/isString.js";
|
|
5
5
|
//#region src/filter-expression/pattern-match.ts
|
|
@@ -9,7 +9,7 @@ const isPlaceholderNode = (node) => {
|
|
|
9
9
|
return typeof matchFn === "function" && (id === ":expression-pattern/expression-placeholder" || id === ":expression-pattern/param-placeholder" || id === ":expression-pattern/constant-placeholder");
|
|
10
10
|
};
|
|
11
11
|
const isQueryPatternNode = (node) => typeof node === "object" && node !== null && !Array.isArray(node) && "q/from" in node;
|
|
12
|
-
const isQueryExpression = (expression) =>
|
|
12
|
+
const isQueryExpression = (expression) => isObjectLike(expression) && "q/from" in expression && Array.isArray(expression["q/from"]);
|
|
13
13
|
const isSelectPatternRecord = (pattern) => pattern !== void 0 && isPlainObject(pattern) && !isPlaceholderNode(pattern);
|
|
14
14
|
const isParamPatternMatch = (match) => match?.matchType === ":expression-match-type/param";
|
|
15
15
|
const isExpressionPatternMatch = (match) => match?.matchType === ":expression-match-type/expression";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { mapValues } from "@fibery/helpers/src/
|
|
2
|
+
import { mapValues } from "@fibery/helpers/src/object";
|
|
3
3
|
import isString from "lodash/isString.js";
|
|
4
4
|
import moment from "moment";
|
|
5
5
|
//#region src/params-placeholders.ts
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { NotImplementedError } from "./errors.js";
|
|
3
3
|
import uniqBy from "lodash/uniqBy.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isObjectLike, mapValues } from "@fibery/helpers/src/object";
|
|
5
5
|
import isPlainObject from "lodash/isPlainObject.js";
|
|
6
6
|
import { assert } from "@fibery/helpers/utils/trace";
|
|
7
7
|
import isString from "lodash/isString.js";
|
|
@@ -159,7 +159,7 @@ const isMultiFieldAccess = (expression) => Array.isArray(expression) && expressi
|
|
|
159
159
|
const isMultiFieldExpression = (expression) => Array.isArray(expression) && !isFunctionCallExpression(expression) && expression.some((x) => isMultiFieldAccess(x)) && expression.every((x) => !isVariableExpression(x) && !(isString(x) && binaryOperations.has(x)) && (isString(x) || isMultiFieldAccess(x)));
|
|
160
160
|
const isFieldExpression = (expression) => Array.isArray(expression) && !isFunctionCallExpression(expression) && expression.every((x) => !isVariableExpression(x) && isString(x));
|
|
161
161
|
const isQueryExpression = (expression) => {
|
|
162
|
-
if (
|
|
162
|
+
if (isObjectLike(expression) && "q/from" in expression) {
|
|
163
163
|
const fromExpression = expression["q/from"];
|
|
164
164
|
return fromExpression === null || isFieldExpression(fromExpression) || isFromRootFieldExpression(fromExpression) || isMultiFieldExpression(fromExpression);
|
|
165
165
|
}
|
package/lib/visitors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { createExpressionVisitor, firstLastFunctions, isCollectionFunctionExpression, isMultiFieldAccess, logicalOperators } from "./utils.js";
|
|
3
3
|
import { fieldAccessVisitorTypeAware } from "./field-expression-visitor-type-aware.js";
|
|
4
|
-
import { mapValues } from "@fibery/helpers/src/
|
|
4
|
+
import { mapValues } from "@fibery/helpers/src/object";
|
|
5
5
|
import isPlainObject from "lodash/isPlainObject.js";
|
|
6
6
|
import pickBy from "lodash/pickBy.js";
|
|
7
7
|
//#region src/visitors.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/expression-utils",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.4",
|
|
4
4
|
"description": "utils for working with fibery api expressions",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"files": [
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@fibery/helpers": "
|
|
28
|
+
"@fibery/helpers": "6.0.0",
|
|
29
29
|
"lodash": "4.18.1",
|
|
30
30
|
"moment": "2.31.0",
|
|
31
31
|
"uuid": "11.1.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@fibery/schema": "13.1.
|
|
34
|
+
"@fibery/schema": "13.1.4"
|
|
35
35
|
}
|
|
36
36
|
}
|