@fibery/expression-utils 10.0.1 → 10.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.
- package/lib/context-variables.js +2 -1
- package/lib/filter-expression/index.d.ts +1 -1
- package/lib/filter-expression/index.js +5 -4
- package/lib/filter-expression/operator-utils.d.ts +3 -7
- package/lib/filter-expression/operator-utils.js +12 -9
- package/lib/filter-expression/operators.d.ts +261 -20
- package/lib/filter-expression/operators.js +28 -24
- package/lib/filter-expression/pattern-match.d.ts +10 -8
- package/lib/filter-expression/pattern-match.js +79 -89
- package/lib/filter-expression/pattern-to-expression.d.ts +2 -13
- package/lib/filter-expression/pattern-to-expression.js +31 -33
- package/lib/filter-expression/types.d.ts +29 -6
- package/lib/index.d.ts +4 -180
- package/package.json +3 -3
- package/lib/tsfixme.d.ts +0 -4
- package/lib/tsfixme.js +0 -0
package/lib/context-variables.js
CHANGED
|
@@ -98,7 +98,8 @@ const getAutomationTriggersContextVariables = (triggers, typeId, fiberySchema) =
|
|
|
98
98
|
const triggerContextVars = triggers.flatMap((trigger) => {
|
|
99
99
|
return getTriggerContextVariables(trigger, typeId, fiberySchema);
|
|
100
100
|
});
|
|
101
|
-
|
|
101
|
+
const filteredContextVars = triggers.length > 1 ? triggerContextVars.filter((variable) => variable.id !== previousTriggeredEntityContextVariableId) : triggerContextVars;
|
|
102
|
+
return uniqBy(filteredContextVars, (variable) => `${variable.id}_${variable.typeObject.id}`);
|
|
102
103
|
};
|
|
103
104
|
const getEntityQueryVariables = (schema) => {
|
|
104
105
|
const grouped = groupBy(schema.typeObjects.filter((x) => x.isDomain), (typeObject) => typeObject.pluralTitle);
|
|
@@ -4,7 +4,7 @@ import { Schema } from "@fibery/schema";
|
|
|
4
4
|
//#region src/filter-expression/index.d.ts
|
|
5
5
|
declare const findMatchedFilter: (filterExpression: Expression, params: Record<string, unknown>, operators: Array<Operator>, schema: Schema | null, type: string) => {
|
|
6
6
|
operator: Operator;
|
|
7
|
-
value:
|
|
7
|
+
value: unknown;
|
|
8
8
|
expression: Expression;
|
|
9
9
|
type: string;
|
|
10
10
|
id: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NotImplementedError } from "../errors.js";
|
|
2
|
-
import { doPatternMatch } from "./pattern-match.js";
|
|
2
|
+
import { doPatternMatch, isExpressionPatternMatch, isParamPatternMatch } from "./pattern-match.js";
|
|
3
3
|
import { v4 } from "uuid";
|
|
4
4
|
//#region src/filter-expression/index.ts
|
|
5
5
|
const findMatchedFilter = (filterExpression, params, operators, schema, type) => {
|
|
@@ -14,13 +14,14 @@ const findMatchedFilter = (filterExpression, params, operators, schema, type) =>
|
|
|
14
14
|
type,
|
|
15
15
|
id: v4()
|
|
16
16
|
};
|
|
17
|
-
} else {
|
|
17
|
+
} else if (operator.pattern) {
|
|
18
18
|
const { matchSuccess, matches } = doPatternMatch(filterExpression, params, operator.pattern, typeObject);
|
|
19
19
|
if (matchSuccess) {
|
|
20
|
-
const paramMatches = matches.filter(
|
|
21
|
-
const expressionMatches = matches.filter(
|
|
20
|
+
const paramMatches = matches.filter(isParamPatternMatch);
|
|
21
|
+
const expressionMatches = matches.filter(isExpressionPatternMatch);
|
|
22
22
|
if (paramMatches.length > 1) throw new NotImplementedError(`Operator pattern with several param placeholders`);
|
|
23
23
|
if (expressionMatches.length > 1) throw new NotImplementedError(`Operator pattern with several expression placeholders`);
|
|
24
|
+
if (expressionMatches.length === 0) throw new NotImplementedError(`Operator pattern without an expression placeholder`);
|
|
24
25
|
return {
|
|
25
26
|
operator,
|
|
26
27
|
value: paramMatches[0] && paramMatches[0].value,
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { Expression } from "../types.js";
|
|
2
|
-
import {
|
|
3
|
-
import { CustomMatchFn, Operator } from "./types.js";
|
|
2
|
+
import { ConvertResult, CustomMatchFn, ExpressionPlaceholder, Operator } from "./types.js";
|
|
4
3
|
//#region src/filter-expression/operator-utils.d.ts
|
|
5
4
|
declare const isDateTime: (dateString: string) => boolean;
|
|
6
5
|
declare const NO_VALUE: undefined;
|
|
7
6
|
declare const isNoValue: (value: unknown) => boolean;
|
|
8
7
|
declare const getCompareOperatorForDateTime: (id: string, title: string, operator: string, compareByStartInterval: boolean, isNegative: boolean) => Operator;
|
|
9
|
-
declare const getWithinOperatorCustomConvertFn: (leftPartExcluded: boolean) => (expression: Expression, value:
|
|
10
|
-
|
|
11
|
-
withinRangeEnd: unknown;
|
|
12
|
-
} | null, getNextParamName: () => string) => $TSFixMe;
|
|
13
|
-
declare const getWithinOperatorCustomMatchFn: (fieldPlaceholder: $TSFixMe, leftPartExcluded: boolean) => CustomMatchFn;
|
|
8
|
+
declare const getWithinOperatorCustomConvertFn: (leftPartExcluded: boolean) => (expression: Expression, value: unknown, getNextParamName: () => string) => ConvertResult;
|
|
9
|
+
declare const getWithinOperatorCustomMatchFn: (fieldPlaceholder: ExpressionPlaceholder, leftPartExcluded: boolean) => CustomMatchFn;
|
|
14
10
|
//#endregion
|
|
15
11
|
export { NO_VALUE, getCompareOperatorForDateTime, getWithinOperatorCustomConvertFn, getWithinOperatorCustomMatchFn, isDateTime, isNoValue };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { doPatternMatch } from "./pattern-match.js";
|
|
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
4
|
import { isRecord } from "@fibery/helpers/src/_";
|
|
@@ -23,7 +23,7 @@ const getCompareOperatorForDateTime = (id, title, operator, compareByStartInterv
|
|
|
23
23
|
return isString(x) && Boolean(paramsPlaceholdersLookup[x]) || isString(x) && isDateTime(x) || Boolean(parseRelativeDatePlaceholder(x)) || isNoValue(x);
|
|
24
24
|
})
|
|
25
25
|
], typeObject);
|
|
26
|
-
if (matchSuccess) {
|
|
26
|
+
if (matchSuccess && isExpressionPatternMatch(fieldMatch) && isParamPatternMatch(paramMatch)) {
|
|
27
27
|
const paramValue = paramMatch.value;
|
|
28
28
|
const relativeDateInfo = parseRelativeDatePlaceholder(paramValue);
|
|
29
29
|
if (relativeDateInfo && relativeDateInfo.isStartOfInterval === compareByStartInterval) {
|
|
@@ -36,7 +36,7 @@ const getCompareOperatorForDateTime = (id, title, operator, compareByStartInterv
|
|
|
36
36
|
expression: fieldMatch.value,
|
|
37
37
|
value
|
|
38
38
|
};
|
|
39
|
-
} else if (paramsPlaceholdersLookup[paramValue]) {
|
|
39
|
+
} else if (typeof paramValue === "string" && paramsPlaceholdersLookup[paramValue]) {
|
|
40
40
|
const value = findKey(dateToDateTimeIntervalLookup, (val) => compareByStartInterval ? val.start === paramValue : val.end === paramValue);
|
|
41
41
|
return {
|
|
42
42
|
matchSuccess,
|
|
@@ -52,7 +52,7 @@ const getCompareOperatorForDateTime = (id, title, operator, compareByStartInterv
|
|
|
52
52
|
return { matchSuccess: false };
|
|
53
53
|
},
|
|
54
54
|
customConvertToWhereExpression: (expression, value, getNextParamName) => {
|
|
55
|
-
const dateTimePlaceholders = dateToDateTimeIntervalLookup[value];
|
|
55
|
+
const dateTimePlaceholders = typeof value === "string" ? dateToDateTimeIntervalLookup[value] : void 0;
|
|
56
56
|
let relativeDateInfo = null;
|
|
57
57
|
if (dateTimePlaceholders) {
|
|
58
58
|
const { start, end } = dateTimePlaceholders;
|
|
@@ -95,7 +95,8 @@ const getCompareOperatorForDateTime = (id, title, operator, compareByStartInterv
|
|
|
95
95
|
isNegative
|
|
96
96
|
});
|
|
97
97
|
const getWithinRangeParam = ({ withinRangeValue, getNextParamName }) => {
|
|
98
|
-
|
|
98
|
+
const withinRangeDateInfo = parseRelativeDatePlaceholder(withinRangeValue);
|
|
99
|
+
if (typeof withinRangeValue === "string" && withinRangeDateInfo) return {
|
|
99
100
|
key: withinRangeValue,
|
|
100
101
|
value: withinRangeValue
|
|
101
102
|
};
|
|
@@ -104,14 +105,16 @@ const getWithinRangeParam = ({ withinRangeValue, getNextParamName }) => {
|
|
|
104
105
|
value: withinRangeValue
|
|
105
106
|
};
|
|
106
107
|
};
|
|
108
|
+
const isWithinRangeValue = (value) => isRecord(value) && "withinRangeStart" in value && "withinRangeEnd" in value;
|
|
107
109
|
const getWithinOperatorCustomConvertFn = (leftPartExcluded) => {
|
|
108
110
|
return (expression, value, getNextParamName) => {
|
|
111
|
+
const withinRangeValue = isWithinRangeValue(value) ? value : null;
|
|
109
112
|
const { key: startParamKey, value: startParamValue } = getWithinRangeParam({
|
|
110
|
-
withinRangeValue:
|
|
113
|
+
withinRangeValue: withinRangeValue?.withinRangeStart,
|
|
111
114
|
getNextParamName
|
|
112
115
|
});
|
|
113
116
|
const { key: endParamKey, value: endParamValue } = getWithinRangeParam({
|
|
114
|
-
withinRangeValue:
|
|
117
|
+
withinRangeValue: withinRangeValue?.withinRangeEnd,
|
|
115
118
|
getNextParamName
|
|
116
119
|
});
|
|
117
120
|
return {
|
|
@@ -152,12 +155,12 @@ const oldWithinPlaceholderToRelativeDateLookup = {
|
|
|
152
155
|
[todayEndDateTimeParamPlaceholder]: "$end-of-day-0-day-before-now-date-time"
|
|
153
156
|
};
|
|
154
157
|
const getWithinRangeValue = (paramMatchValue) => {
|
|
155
|
-
if (Object.hasOwn(oldWithinPlaceholderToRelativeDateLookup, paramMatchValue)) return oldWithinPlaceholderToRelativeDateLookup[paramMatchValue];
|
|
158
|
+
if (typeof paramMatchValue === "string" && Object.hasOwn(oldWithinPlaceholderToRelativeDateLookup, paramMatchValue)) return oldWithinPlaceholderToRelativeDateLookup[paramMatchValue];
|
|
156
159
|
else return paramMatchValue;
|
|
157
160
|
};
|
|
158
161
|
const matchWithinOperator = (pattern, where, params, typeObject) => {
|
|
159
162
|
const { matchSuccess, matches: [firstFieldMatch, firstParamMatch, secondFieldMatch, secondParamMatch] } = doPatternMatch(where, params, pattern, typeObject);
|
|
160
|
-
if (matchSuccess) {
|
|
163
|
+
if (matchSuccess && isExpressionPatternMatch(firstFieldMatch) && isParamPatternMatch(firstParamMatch) && isExpressionPatternMatch(secondFieldMatch) && isParamPatternMatch(secondParamMatch)) {
|
|
161
164
|
const firstFieldValue = firstFieldMatch.value;
|
|
162
165
|
const secondFieldValue = secondFieldMatch.value;
|
|
163
166
|
if (isEqual(firstFieldValue, secondFieldValue)) return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Expression } from "../types.js";
|
|
2
2
|
import { Operator } from "./types.js";
|
|
3
|
+
import { TypeObject } from "@fibery/schema";
|
|
3
4
|
declare namespace operators_d_exports {
|
|
4
5
|
export { hiddenValidOperators, operatorBoolIs, operatorCollectionContains, operatorCollectionContainsAnyOf, operatorCollectionContainsMe, operatorCollectionCountDoesNotEqual, operatorCollectionCountEquals, operatorCollectionCountGreaterThan, operatorCollectionCountGreaterThanOrEqual, operatorCollectionCountLessThan, operatorCollectionCountLessThanOrEqual, operatorCollectionDoesNotContain, operatorCollectionDoesNotContainAnyOf, operatorCollectionDoesNotContainMe, operatorCollectionIsEmpty, operatorCollectionIsNotEmpty, operatorDateIs, operatorDateIsAfter, operatorDateIsBefore, operatorDateIsEmptyV1, operatorDateIsEmptyV2, operatorDateIsNotEmptyV1, operatorDateIsNotEmptyV2, operatorDateIsOnOrAfter, operatorDateIsOnOrBefore, operatorDateIsWithin, operatorDateTimeIs, operatorDateTimeIsAfter, operatorDateTimeIsBefore, operatorDateTimeIsOnOrAfter, operatorDateTimeIsOnOrBefore, operatorDateTimeIsWithin, operatorGreaterThan, operatorGreaterThanOrEqual, operatorLessThan, operatorLessThanOrEqual, operatorLocationContains, operatorLocationDoesNotContain, operatorLocationIsEmpty, operatorLocationIsNotEmpty, operatorNumberDoesNotEqual, operatorNumberEquals, operatorNumberIsEmptyV1, operatorNumberIsEmptyV2, operatorNumberIsNotEmptyV1, operatorNumberIsNotEmptyV2, operatorReferenceIs, operatorReferenceIsAnyOf, operatorReferenceIsEmpty, operatorReferenceIsMe, operatorReferenceIsNoneOf, operatorReferenceIsNot, operatorReferenceIsNotEmpty, operatorReferenceIsNotMe, operatorTextContains, operatorTextDoesNotContain, operatorTextEndsWith, operatorTextExactlyIs, operatorTextIs, operatorTextIsEmptyV1, operatorTextIsEmptyV2, operatorTextIsNot, operatorTextIsNotEmptyV1, operatorTextIsNotEmptyV2, operatorTextStartsWith, operatorUserRoleIsAnyOf, operators, operatorsGroups, operatorsGroupsWithoutMe, withoutLastIdAccess };
|
|
5
6
|
}
|
|
@@ -12,7 +13,19 @@ declare const operatorReferenceIsNoneOf: Operator;
|
|
|
12
13
|
declare const operatorReferenceIsEmpty: Operator;
|
|
13
14
|
declare const operatorReferenceIsNotEmpty: Operator;
|
|
14
15
|
declare const operatorUserRoleIsAnyOf: Operator;
|
|
15
|
-
declare const operatorTextIs:
|
|
16
|
+
declare const operatorTextIs: {
|
|
17
|
+
id: string;
|
|
18
|
+
title: string;
|
|
19
|
+
pattern: (string | {
|
|
20
|
+
id: ":expression-pattern/expression-placeholder";
|
|
21
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
22
|
+
} | {
|
|
23
|
+
id: ":expression-pattern/param-placeholder";
|
|
24
|
+
matchFn: (_x: unknown) => boolean;
|
|
25
|
+
})[];
|
|
26
|
+
type: string;
|
|
27
|
+
isNegative: false;
|
|
28
|
+
};
|
|
16
29
|
declare const operatorTextExactlyIs: Operator;
|
|
17
30
|
declare const operatorTextIsNot: Operator;
|
|
18
31
|
declare const operatorTextContains: Operator;
|
|
@@ -79,7 +92,19 @@ declare const operatorsGroupsWithoutMe: {
|
|
|
79
92
|
":filter-type/multi-select": Operator[];
|
|
80
93
|
":filter-type/reference-collection": Operator[];
|
|
81
94
|
":filter-type/user-reference-collection": Operator[];
|
|
82
|
-
":filter-type/text": Operator
|
|
95
|
+
":filter-type/text": (Operator | {
|
|
96
|
+
id: string;
|
|
97
|
+
title: string;
|
|
98
|
+
pattern: (string | {
|
|
99
|
+
id: ":expression-pattern/expression-placeholder";
|
|
100
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
101
|
+
} | {
|
|
102
|
+
id: ":expression-pattern/param-placeholder";
|
|
103
|
+
matchFn: (_x: unknown) => boolean;
|
|
104
|
+
})[];
|
|
105
|
+
type: string;
|
|
106
|
+
isNegative: false;
|
|
107
|
+
})[];
|
|
83
108
|
":filter-type/number": Operator[];
|
|
84
109
|
":filter-type/bool": Operator[];
|
|
85
110
|
":filter-type/date": Operator[];
|
|
@@ -89,25 +114,241 @@ declare const operatorsGroupsWithoutMe: {
|
|
|
89
114
|
":filter-type/collection-count": Operator[];
|
|
90
115
|
};
|
|
91
116
|
declare const operatorsGroups: {
|
|
92
|
-
":filter-type/comment-reference-collection": Operator
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
":filter-type/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
117
|
+
":filter-type/comment-reference-collection": (Operator | {
|
|
118
|
+
id: string;
|
|
119
|
+
title: string;
|
|
120
|
+
pattern: (string | {
|
|
121
|
+
id: ":expression-pattern/expression-placeholder";
|
|
122
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
123
|
+
} | {
|
|
124
|
+
id: ":expression-pattern/param-placeholder";
|
|
125
|
+
matchFn: (_x: unknown) => boolean;
|
|
126
|
+
})[];
|
|
127
|
+
type: string;
|
|
128
|
+
isNegative: false;
|
|
129
|
+
})[];
|
|
130
|
+
":filter-type/file-reference": (Operator | {
|
|
131
|
+
id: string;
|
|
132
|
+
title: string;
|
|
133
|
+
pattern: (string | {
|
|
134
|
+
id: ":expression-pattern/expression-placeholder";
|
|
135
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
136
|
+
} | {
|
|
137
|
+
id: ":expression-pattern/param-placeholder";
|
|
138
|
+
matchFn: (_x: unknown) => boolean;
|
|
139
|
+
})[];
|
|
140
|
+
type: string;
|
|
141
|
+
isNegative: false;
|
|
142
|
+
})[];
|
|
143
|
+
":filter-type/file-reference-collection": (Operator | {
|
|
144
|
+
id: string;
|
|
145
|
+
title: string;
|
|
146
|
+
pattern: (string | {
|
|
147
|
+
id: ":expression-pattern/expression-placeholder";
|
|
148
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
149
|
+
} | {
|
|
150
|
+
id: ":expression-pattern/param-placeholder";
|
|
151
|
+
matchFn: (_x: unknown) => boolean;
|
|
152
|
+
})[];
|
|
153
|
+
type: string;
|
|
154
|
+
isNegative: false;
|
|
155
|
+
})[];
|
|
156
|
+
":filter-type/reference": (Operator | {
|
|
157
|
+
id: string;
|
|
158
|
+
title: string;
|
|
159
|
+
pattern: (string | {
|
|
160
|
+
id: ":expression-pattern/expression-placeholder";
|
|
161
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
162
|
+
} | {
|
|
163
|
+
id: ":expression-pattern/param-placeholder";
|
|
164
|
+
matchFn: (_x: unknown) => boolean;
|
|
165
|
+
})[];
|
|
166
|
+
type: string;
|
|
167
|
+
isNegative: false;
|
|
168
|
+
})[];
|
|
169
|
+
":filter-type/user-reference": (Operator | {
|
|
170
|
+
id: string;
|
|
171
|
+
title: string;
|
|
172
|
+
pattern: (string | {
|
|
173
|
+
id: ":expression-pattern/expression-placeholder";
|
|
174
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
175
|
+
} | {
|
|
176
|
+
id: ":expression-pattern/param-placeholder";
|
|
177
|
+
matchFn: (_x: unknown) => boolean;
|
|
178
|
+
})[];
|
|
179
|
+
type: string;
|
|
180
|
+
isNegative: false;
|
|
181
|
+
})[];
|
|
182
|
+
":filter-type/single-select": (Operator | {
|
|
183
|
+
id: string;
|
|
184
|
+
title: string;
|
|
185
|
+
pattern: (string | {
|
|
186
|
+
id: ":expression-pattern/expression-placeholder";
|
|
187
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
188
|
+
} | {
|
|
189
|
+
id: ":expression-pattern/param-placeholder";
|
|
190
|
+
matchFn: (_x: unknown) => boolean;
|
|
191
|
+
})[];
|
|
192
|
+
type: string;
|
|
193
|
+
isNegative: false;
|
|
194
|
+
})[];
|
|
195
|
+
":filter-type/multi-select": (Operator | {
|
|
196
|
+
id: string;
|
|
197
|
+
title: string;
|
|
198
|
+
pattern: (string | {
|
|
199
|
+
id: ":expression-pattern/expression-placeholder";
|
|
200
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
201
|
+
} | {
|
|
202
|
+
id: ":expression-pattern/param-placeholder";
|
|
203
|
+
matchFn: (_x: unknown) => boolean;
|
|
204
|
+
})[];
|
|
205
|
+
type: string;
|
|
206
|
+
isNegative: false;
|
|
207
|
+
})[];
|
|
208
|
+
":filter-type/reference-collection": (Operator | {
|
|
209
|
+
id: string;
|
|
210
|
+
title: string;
|
|
211
|
+
pattern: (string | {
|
|
212
|
+
id: ":expression-pattern/expression-placeholder";
|
|
213
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
214
|
+
} | {
|
|
215
|
+
id: ":expression-pattern/param-placeholder";
|
|
216
|
+
matchFn: (_x: unknown) => boolean;
|
|
217
|
+
})[];
|
|
218
|
+
type: string;
|
|
219
|
+
isNegative: false;
|
|
220
|
+
})[];
|
|
221
|
+
":filter-type/user-reference-collection": (Operator | {
|
|
222
|
+
id: string;
|
|
223
|
+
title: string;
|
|
224
|
+
pattern: (string | {
|
|
225
|
+
id: ":expression-pattern/expression-placeholder";
|
|
226
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
227
|
+
} | {
|
|
228
|
+
id: ":expression-pattern/param-placeholder";
|
|
229
|
+
matchFn: (_x: unknown) => boolean;
|
|
230
|
+
})[];
|
|
231
|
+
type: string;
|
|
232
|
+
isNegative: false;
|
|
233
|
+
})[];
|
|
234
|
+
":filter-type/text": (Operator | {
|
|
235
|
+
id: string;
|
|
236
|
+
title: string;
|
|
237
|
+
pattern: (string | {
|
|
238
|
+
id: ":expression-pattern/expression-placeholder";
|
|
239
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
240
|
+
} | {
|
|
241
|
+
id: ":expression-pattern/param-placeholder";
|
|
242
|
+
matchFn: (_x: unknown) => boolean;
|
|
243
|
+
})[];
|
|
244
|
+
type: string;
|
|
245
|
+
isNegative: false;
|
|
246
|
+
})[];
|
|
247
|
+
":filter-type/number": (Operator | {
|
|
248
|
+
id: string;
|
|
249
|
+
title: string;
|
|
250
|
+
pattern: (string | {
|
|
251
|
+
id: ":expression-pattern/expression-placeholder";
|
|
252
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
253
|
+
} | {
|
|
254
|
+
id: ":expression-pattern/param-placeholder";
|
|
255
|
+
matchFn: (_x: unknown) => boolean;
|
|
256
|
+
})[];
|
|
257
|
+
type: string;
|
|
258
|
+
isNegative: false;
|
|
259
|
+
})[];
|
|
260
|
+
":filter-type/bool": (Operator | {
|
|
261
|
+
id: string;
|
|
262
|
+
title: string;
|
|
263
|
+
pattern: (string | {
|
|
264
|
+
id: ":expression-pattern/expression-placeholder";
|
|
265
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
266
|
+
} | {
|
|
267
|
+
id: ":expression-pattern/param-placeholder";
|
|
268
|
+
matchFn: (_x: unknown) => boolean;
|
|
269
|
+
})[];
|
|
270
|
+
type: string;
|
|
271
|
+
isNegative: false;
|
|
272
|
+
})[];
|
|
273
|
+
":filter-type/date": (Operator | {
|
|
274
|
+
id: string;
|
|
275
|
+
title: string;
|
|
276
|
+
pattern: (string | {
|
|
277
|
+
id: ":expression-pattern/expression-placeholder";
|
|
278
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
279
|
+
} | {
|
|
280
|
+
id: ":expression-pattern/param-placeholder";
|
|
281
|
+
matchFn: (_x: unknown) => boolean;
|
|
282
|
+
})[];
|
|
283
|
+
type: string;
|
|
284
|
+
isNegative: false;
|
|
285
|
+
})[];
|
|
286
|
+
":filter-type/date-time": (Operator | {
|
|
287
|
+
id: string;
|
|
288
|
+
title: string;
|
|
289
|
+
pattern: (string | {
|
|
290
|
+
id: ":expression-pattern/expression-placeholder";
|
|
291
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
292
|
+
} | {
|
|
293
|
+
id: ":expression-pattern/param-placeholder";
|
|
294
|
+
matchFn: (_x: unknown) => boolean;
|
|
295
|
+
})[];
|
|
296
|
+
type: string;
|
|
297
|
+
isNegative: false;
|
|
298
|
+
})[];
|
|
299
|
+
":filter-type/location": (Operator | {
|
|
300
|
+
id: string;
|
|
301
|
+
title: string;
|
|
302
|
+
pattern: (string | {
|
|
303
|
+
id: ":expression-pattern/expression-placeholder";
|
|
304
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
305
|
+
} | {
|
|
306
|
+
id: ":expression-pattern/param-placeholder";
|
|
307
|
+
matchFn: (_x: unknown) => boolean;
|
|
308
|
+
})[];
|
|
309
|
+
type: string;
|
|
310
|
+
isNegative: false;
|
|
311
|
+
})[];
|
|
312
|
+
":filter-type/user-role": (Operator | {
|
|
313
|
+
id: string;
|
|
314
|
+
title: string;
|
|
315
|
+
pattern: (string | {
|
|
316
|
+
id: ":expression-pattern/expression-placeholder";
|
|
317
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
318
|
+
} | {
|
|
319
|
+
id: ":expression-pattern/param-placeholder";
|
|
320
|
+
matchFn: (_x: unknown) => boolean;
|
|
321
|
+
})[];
|
|
322
|
+
type: string;
|
|
323
|
+
isNegative: false;
|
|
324
|
+
})[];
|
|
325
|
+
":filter-type/collection-count": (Operator | {
|
|
326
|
+
id: string;
|
|
327
|
+
title: string;
|
|
328
|
+
pattern: (string | {
|
|
329
|
+
id: ":expression-pattern/expression-placeholder";
|
|
330
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
331
|
+
} | {
|
|
332
|
+
id: ":expression-pattern/param-placeholder";
|
|
333
|
+
matchFn: (_x: unknown) => boolean;
|
|
334
|
+
})[];
|
|
335
|
+
type: string;
|
|
336
|
+
isNegative: false;
|
|
337
|
+
})[];
|
|
109
338
|
};
|
|
110
|
-
declare const operators: Operator
|
|
339
|
+
declare const operators: (Operator | {
|
|
340
|
+
id: string;
|
|
341
|
+
title: string;
|
|
342
|
+
pattern: (string | {
|
|
343
|
+
id: ":expression-pattern/expression-placeholder";
|
|
344
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
345
|
+
} | {
|
|
346
|
+
id: ":expression-pattern/param-placeholder";
|
|
347
|
+
matchFn: (_x: unknown) => boolean;
|
|
348
|
+
})[];
|
|
349
|
+
type: string;
|
|
350
|
+
isNegative: false;
|
|
351
|
+
})[];
|
|
111
352
|
declare const hiddenValidOperators: Operator[];
|
|
112
353
|
//#endregion
|
|
113
354
|
export { hiddenValidOperators, operatorBoolIs, operatorCollectionContains, operatorCollectionContainsAnyOf, operatorCollectionContainsMe, operatorCollectionCountDoesNotEqual, operatorCollectionCountEquals, operatorCollectionCountGreaterThan, operatorCollectionCountGreaterThanOrEqual, operatorCollectionCountLessThan, operatorCollectionCountLessThanOrEqual, operatorCollectionDoesNotContain, operatorCollectionDoesNotContainAnyOf, operatorCollectionDoesNotContainMe, operatorCollectionIsEmpty, operatorCollectionIsNotEmpty, operatorDateIs, operatorDateIsAfter, operatorDateIsBefore, operatorDateIsEmptyV1, operatorDateIsEmptyV2, operatorDateIsNotEmptyV1, operatorDateIsNotEmptyV2, operatorDateIsOnOrAfter, operatorDateIsOnOrBefore, operatorDateIsWithin, operatorDateTimeIs, operatorDateTimeIsAfter, operatorDateTimeIsBefore, operatorDateTimeIsOnOrAfter, operatorDateTimeIsOnOrBefore, operatorDateTimeIsWithin, operatorGreaterThan, operatorGreaterThanOrEqual, operatorLessThan, operatorLessThanOrEqual, operatorLocationContains, operatorLocationDoesNotContain, operatorLocationIsEmpty, operatorLocationIsNotEmpty, operatorNumberDoesNotEqual, operatorNumberEquals, operatorNumberIsEmptyV1, operatorNumberIsEmptyV2, operatorNumberIsNotEmptyV1, operatorNumberIsNotEmptyV2, operatorReferenceIs, operatorReferenceIsAnyOf, operatorReferenceIsEmpty, operatorReferenceIsMe, operatorReferenceIsNoneOf, operatorReferenceIsNot, operatorReferenceIsNotEmpty, operatorReferenceIsNotMe, operatorTextContains, operatorTextDoesNotContain, operatorTextEndsWith, operatorTextExactlyIs, operatorTextIs, operatorTextIsEmptyV1, operatorTextIsEmptyV2, operatorTextIsNot, operatorTextIsNotEmptyV1, operatorTextIsNotEmptyV2, operatorTextStartsWith, operatorUserRoleIsAnyOf, operators, operatorsGroups, operatorsGroupsWithoutMe, operators_d_exports, withoutLastIdAccess };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { doPatternMatch } from "./pattern-match.js";
|
|
2
|
+
import { doPatternMatch, getExpressionArrayMatchValue, isExpressionPatternMatch, isParamPatternMatch } from "./pattern-match.js";
|
|
3
3
|
import { dateToDateTimeIntervalLookup, isDynamicFilterParam, paramsPlaceholdersLookup, parseRelativeDatePlaceholder, toRelativeDatePlaceholder } from "../params-placeholders.js";
|
|
4
4
|
import { anyDateExpressionPlaceholder, boolFieldPlaceholder, collectionCountExpressionPlaceholder, dateOrDateRangeExpressionPlaceholder, dateTimeOrDateTimeRangeExpressionPlaceholder, getConstantPlaceholder, getParamPlaceholder, locationFieldPlaceholder, numberFieldPlaceholder, referenceCollectionExpressionPlaceholder, referenceCollectionFieldPlaceholder, referenceExpressionPlaceholder, textFieldPlaceholder } from "./pattern-match-placeholders.js";
|
|
5
5
|
import { getCompareOperatorForDateTime, getWithinOperatorCustomConvertFn, getWithinOperatorCustomMatchFn, isDateTime, isNoValue } from "./operator-utils.js";
|
|
@@ -102,13 +102,13 @@ const getReferenceMeOperator = ({ id, title, pattern, isNegative }) => {
|
|
|
102
102
|
title,
|
|
103
103
|
customMatch: (where, params, typeObject) => {
|
|
104
104
|
const { matchSuccess, matches } = doPatternMatch(where, params, pattern, typeObject);
|
|
105
|
-
if (matchSuccess) return {
|
|
105
|
+
if (matchSuccess && isExpressionPatternMatch(matches[0])) return {
|
|
106
106
|
matchSuccess,
|
|
107
107
|
expression: matches[0].value
|
|
108
108
|
};
|
|
109
109
|
return { matchSuccess: false };
|
|
110
110
|
},
|
|
111
|
-
customConvertToWhereExpression: (expression,
|
|
111
|
+
customConvertToWhereExpression: (expression, _value, getNextParamName) => {
|
|
112
112
|
return convertToExpression(pattern, expression, "$my-id", getNextParamName);
|
|
113
113
|
},
|
|
114
114
|
isNegative
|
|
@@ -127,7 +127,7 @@ const operatorReferenceIsNotMe = getReferenceMeOperator({
|
|
|
127
127
|
isNegative: true
|
|
128
128
|
});
|
|
129
129
|
function isValidReferenceUUID(val) {
|
|
130
|
-
return
|
|
130
|
+
return isString(val) && (validate(val) || isDynamicFilterParam(val));
|
|
131
131
|
}
|
|
132
132
|
const operatorReferenceIs = {
|
|
133
133
|
id: ":operator/reference-is",
|
|
@@ -602,9 +602,10 @@ const operatorCollectionContains = {
|
|
|
602
602
|
title: "contains",
|
|
603
603
|
customMatch: (where, params, typeObject) => {
|
|
604
604
|
const { matchSuccess, matches } = doPatternMatch(where, params, collectionContainsPattern, typeObject);
|
|
605
|
-
|
|
605
|
+
const expression = getExpressionArrayMatchValue(matches[0]);
|
|
606
|
+
if (matchSuccess && expression && isParamPatternMatch(matches[1])) return {
|
|
606
607
|
matchSuccess,
|
|
607
|
-
expression: [...
|
|
608
|
+
expression: [...expression, "fibery/id"],
|
|
608
609
|
value: matches[1].value
|
|
609
610
|
};
|
|
610
611
|
return { matchSuccess: false };
|
|
@@ -620,13 +621,14 @@ const getOperatorCollectionMe = ({ id, title, pattern, isNegative }) => ({
|
|
|
620
621
|
title,
|
|
621
622
|
customMatch: (where, params, typeObject) => {
|
|
622
623
|
const { matchSuccess, matches } = doPatternMatch(where, params, pattern, typeObject);
|
|
623
|
-
|
|
624
|
+
const expression = getExpressionArrayMatchValue(matches[0]);
|
|
625
|
+
if (matchSuccess && expression) return {
|
|
624
626
|
matchSuccess,
|
|
625
|
-
expression: [...
|
|
627
|
+
expression: [...expression, "fibery/id"]
|
|
626
628
|
};
|
|
627
629
|
return { matchSuccess: false };
|
|
628
630
|
},
|
|
629
|
-
customConvertToWhereExpression: (expression,
|
|
631
|
+
customConvertToWhereExpression: (expression, _value, getNextParamName) => {
|
|
630
632
|
return convertToExpression(pattern, withoutLastIdAccess(expression), "$my-id", getNextParamName);
|
|
631
633
|
},
|
|
632
634
|
type: ":operator-type/unary",
|
|
@@ -639,18 +641,18 @@ const operatorCollectionContainsMe = getOperatorCollectionMe({
|
|
|
639
641
|
isNegative: false
|
|
640
642
|
});
|
|
641
643
|
const withoutLastIdAccess = (expression) => {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
return arr.slice(0, -1);
|
|
644
|
+
if (!Array.isArray(expression) || last(expression) !== "fibery/id") throw new Error("not supported");
|
|
645
|
+
return expression.slice(0, -1);
|
|
645
646
|
};
|
|
646
647
|
const operatorCollectionContainsAnyOf = {
|
|
647
648
|
id: ":operator/collection-contains-any-of",
|
|
648
649
|
title: "contains any of",
|
|
649
650
|
customMatch: (where, params, typeObject) => {
|
|
650
651
|
const { matchSuccess, matches } = doPatternMatch(where, params, collectionContainsAnyOfPattern, typeObject);
|
|
651
|
-
|
|
652
|
+
const expression = getExpressionArrayMatchValue(matches[0]);
|
|
653
|
+
if (matchSuccess && expression && isParamPatternMatch(matches[1])) return {
|
|
652
654
|
matchSuccess,
|
|
653
|
-
expression: [...
|
|
655
|
+
expression: [...expression, "fibery/id"],
|
|
654
656
|
value: matches[1].value
|
|
655
657
|
};
|
|
656
658
|
return { matchSuccess: false };
|
|
@@ -666,9 +668,10 @@ const operatorCollectionDoesNotContain = {
|
|
|
666
668
|
title: "does not contain",
|
|
667
669
|
customMatch: (where, params, typeObject) => {
|
|
668
670
|
const { matchSuccess, matches } = doPatternMatch(where, params, collectionDoesNotContainPattern, typeObject);
|
|
669
|
-
|
|
671
|
+
const expression = getExpressionArrayMatchValue(matches[0]);
|
|
672
|
+
if (matchSuccess && expression && isParamPatternMatch(matches[1])) return {
|
|
670
673
|
matchSuccess,
|
|
671
|
-
expression: [...
|
|
674
|
+
expression: [...expression, "fibery/id"],
|
|
672
675
|
value: matches[1].value
|
|
673
676
|
};
|
|
674
677
|
return { matchSuccess: false };
|
|
@@ -690,9 +693,10 @@ const operatorCollectionDoesNotContainAnyOf = {
|
|
|
690
693
|
title: "contains none of",
|
|
691
694
|
customMatch: (where, params, typeObject) => {
|
|
692
695
|
const { matchSuccess, matches } = doPatternMatch(where, params, collectionDoesNotContainAnyOfPattern, typeObject);
|
|
693
|
-
|
|
696
|
+
const expression = getExpressionArrayMatchValue(matches[0]);
|
|
697
|
+
if (matchSuccess && expression && isParamPatternMatch(matches[1])) return {
|
|
694
698
|
matchSuccess,
|
|
695
|
-
expression: [...
|
|
699
|
+
expression: [...expression, "fibery/id"],
|
|
696
700
|
value: matches[1].value
|
|
697
701
|
};
|
|
698
702
|
return { matchSuccess: false };
|
|
@@ -735,7 +739,7 @@ const operatorBoolIs = {
|
|
|
735
739
|
boolFieldPlaceholder,
|
|
736
740
|
getParamPlaceholder((x) => x === true || x === false)
|
|
737
741
|
], typeObject);
|
|
738
|
-
if (matchSuccess) return {
|
|
742
|
+
if (matchSuccess && isExpressionPatternMatch(matches[0]) && isParamPatternMatch(matches[1])) return {
|
|
739
743
|
matchSuccess,
|
|
740
744
|
expression: matches[0].value,
|
|
741
745
|
value: matches[1].value
|
|
@@ -755,7 +759,7 @@ const operatorBoolIs = {
|
|
|
755
759
|
getParamPlaceholder((x) => x === null)
|
|
756
760
|
]
|
|
757
761
|
], typeObject);
|
|
758
|
-
if (matchSuccess) return {
|
|
762
|
+
if (matchSuccess && isExpressionPatternMatch(matches[0])) return {
|
|
759
763
|
matchSuccess,
|
|
760
764
|
expression: matches[0].value,
|
|
761
765
|
value: false
|
|
@@ -902,10 +906,10 @@ const operatorDateTimeIs = {
|
|
|
902
906
|
getParamPlaceholder()
|
|
903
907
|
]
|
|
904
908
|
], typeObject);
|
|
905
|
-
if (matchSuccess && isEqual(firstFieldMatch.value, secondFieldMatch.value)) {
|
|
909
|
+
if (matchSuccess && isExpressionPatternMatch(firstFieldMatch) && isParamPatternMatch(firstParamMatch) && isExpressionPatternMatch(secondFieldMatch) && isParamPatternMatch(secondParamMatch) && isEqual(firstFieldMatch.value, secondFieldMatch.value)) {
|
|
906
910
|
const firstParamValue = firstParamMatch.value;
|
|
907
911
|
const secondParamValue = secondParamMatch.value;
|
|
908
|
-
if (paramsPlaceholdersLookup[firstParamValue] && paramsPlaceholdersLookup[secondParamValue]) {
|
|
912
|
+
if (typeof firstParamValue === "string" && typeof secondParamValue === "string" && paramsPlaceholdersLookup[firstParamValue] && paramsPlaceholdersLookup[secondParamValue]) {
|
|
909
913
|
const value = findKey(dateToDateTimeIntervalLookup, (val) => val.start === firstParamValue && val.end === secondParamValue);
|
|
910
914
|
return {
|
|
911
915
|
matchSuccess,
|
|
@@ -934,7 +938,7 @@ const operatorDateTimeIs = {
|
|
|
934
938
|
dateTimeOrDateTimeRangeExpressionPlaceholder,
|
|
935
939
|
getParamPlaceholder((x) => isString(x) && isDateTime(x) || isNoValue(x))
|
|
936
940
|
], typeObject);
|
|
937
|
-
if (matchSuccess) return {
|
|
941
|
+
if (matchSuccess && isExpressionPatternMatch(fieldMatch) && isParamPatternMatch(paramMatch)) return {
|
|
938
942
|
matchSuccess,
|
|
939
943
|
expression: fieldMatch.value,
|
|
940
944
|
value: paramMatch.value
|
|
@@ -943,7 +947,7 @@ const operatorDateTimeIs = {
|
|
|
943
947
|
return { matchSuccess: false };
|
|
944
948
|
},
|
|
945
949
|
customConvertToWhereExpression: (expression, value, getNextParamName) => {
|
|
946
|
-
const dateTimePlaceholders = dateToDateTimeIntervalLookup[value];
|
|
950
|
+
const dateTimePlaceholders = typeof value === "string" ? dateToDateTimeIntervalLookup[value] : void 0;
|
|
947
951
|
let relativeDateInfo = null;
|
|
948
952
|
if (dateTimePlaceholders) {
|
|
949
953
|
const { start, end } = dateTimePlaceholders;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { Expression
|
|
2
|
-
import {
|
|
1
|
+
import { Expression } from "../types.js";
|
|
2
|
+
import { PatternNode } from "./types.js";
|
|
3
3
|
import { TypeObject } from "@fibery/schema";
|
|
4
4
|
//#region src/filter-expression/pattern-match.d.ts
|
|
5
|
-
type ExpressionToMatch = SubQuery | Record<string, Expression> | Expression | undefined;
|
|
6
5
|
type ParamPatternMatch = {
|
|
7
6
|
matchType: ":expression-match-type/param";
|
|
8
|
-
value:
|
|
7
|
+
value: unknown;
|
|
9
8
|
};
|
|
10
9
|
type ExpressionPatternMatch = {
|
|
11
10
|
matchType: ":expression-match-type/expression";
|
|
12
11
|
value: Expression;
|
|
13
12
|
};
|
|
14
|
-
type
|
|
13
|
+
type PatternMatch = ParamPatternMatch | ExpressionPatternMatch;
|
|
14
|
+
declare const isParamPatternMatch: (match: PatternMatch | undefined) => match is ParamPatternMatch;
|
|
15
|
+
declare const isExpressionPatternMatch: (match: PatternMatch | undefined) => match is ExpressionPatternMatch;
|
|
16
|
+
declare const getExpressionArrayMatchValue: (match: PatternMatch | undefined) => Expression[] | null;
|
|
15
17
|
type PatternMatchResult = {
|
|
16
18
|
matchSuccess: boolean;
|
|
17
|
-
matches:
|
|
19
|
+
matches: PatternMatch[];
|
|
18
20
|
};
|
|
19
|
-
declare const doPatternMatch: (expression:
|
|
21
|
+
declare const doPatternMatch: (expression: unknown, params: Record<string, unknown>, pattern: PatternNode, typeObject: TypeObject) => PatternMatchResult;
|
|
20
22
|
//#endregion
|
|
21
|
-
export { ExpressionPatternMatch, ParamPatternMatch,
|
|
23
|
+
export { ExpressionPatternMatch, ParamPatternMatch, PatternMatch, PatternMatchResult, doPatternMatch, getExpressionArrayMatchValue, isExpressionPatternMatch, isParamPatternMatch };
|
|
@@ -2,125 +2,115 @@ import { getFieldObjectByFieldExpression, isFieldExpressionValid, isVariableExpr
|
|
|
2
2
|
import { isRecord } from "@fibery/helpers/src/_";
|
|
3
3
|
import isPlainObject from "lodash/isPlainObject.js";
|
|
4
4
|
import isString from "lodash/isString.js";
|
|
5
|
-
import zipWith from "lodash/zipWith.js";
|
|
6
5
|
//#region src/filter-expression/pattern-match.ts
|
|
6
|
+
const isPlaceholderNode = (node) => {
|
|
7
|
+
if (typeof node !== "object" || node === null || Array.isArray(node)) return false;
|
|
8
|
+
const { id, matchFn } = node;
|
|
9
|
+
return typeof matchFn === "function" && (id === ":expression-pattern/expression-placeholder" || id === ":expression-pattern/param-placeholder" || id === ":expression-pattern/constant-placeholder");
|
|
10
|
+
};
|
|
11
|
+
const isQueryPatternNode = (node) => typeof node === "object" && node !== null && !Array.isArray(node) && "q/from" in node;
|
|
12
|
+
const isQueryExpression = (expression) => isRecord(expression) && "q/from" in expression && Array.isArray(expression["q/from"]);
|
|
13
|
+
const isSelectPatternRecord = (pattern) => pattern !== void 0 && isPlainObject(pattern) && !isPlaceholderNode(pattern);
|
|
14
|
+
const isParamPatternMatch = (match) => match?.matchType === ":expression-match-type/param";
|
|
15
|
+
const isExpressionPatternMatch = (match) => match?.matchType === ":expression-match-type/expression";
|
|
16
|
+
const getExpressionArrayMatchValue = (match) => isExpressionPatternMatch(match) && Array.isArray(match.value) ? match.value : null;
|
|
17
|
+
const noMatch = () => ({
|
|
18
|
+
matchSuccess: false,
|
|
19
|
+
matches: []
|
|
20
|
+
});
|
|
7
21
|
const matchSelectClause = (selectExpression, params, selectPattern, typeObject) => {
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
if (selectPattern === void 0) return {
|
|
23
|
+
matchSuccess: selectExpression === void 0,
|
|
24
|
+
matches: []
|
|
25
|
+
};
|
|
26
|
+
if (isSelectPatternRecord(selectPattern)) {
|
|
27
|
+
if (!isPlainObject(selectExpression)) return noMatch();
|
|
28
|
+
const expressionRecord = selectExpression;
|
|
29
|
+
const expressionKeys = Object.keys(expressionRecord);
|
|
30
|
+
const patternKeys = Object.keys(selectPattern);
|
|
31
|
+
if (expressionKeys.length !== patternKeys.length || patternKeys.some((key) => !Object.hasOwn(expressionRecord, key))) return noMatch();
|
|
32
|
+
const matches = [];
|
|
33
|
+
for (const key of patternKeys) {
|
|
34
|
+
const result = doPatternMatch(expressionRecord[key], params, selectPattern[key], typeObject);
|
|
35
|
+
if (!result.matchSuccess) return noMatch();
|
|
36
|
+
matches.push(...result.matches);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
20
39
|
matchSuccess: true,
|
|
21
|
-
matches
|
|
22
|
-
}
|
|
23
|
-
}
|
|
40
|
+
matches
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return doPatternMatch(selectExpression, params, selectPattern, typeObject);
|
|
24
44
|
};
|
|
25
45
|
const matchQuery = (expression, params, pattern, typeObject) => {
|
|
26
46
|
const fromExpression = expression["q/from"];
|
|
27
47
|
if (!isFieldExpressionValid({
|
|
28
48
|
typeObject,
|
|
29
49
|
expression: fromExpression
|
|
30
|
-
})) return
|
|
31
|
-
matchSuccess: false,
|
|
32
|
-
matches: []
|
|
33
|
-
};
|
|
50
|
+
})) return noMatch();
|
|
34
51
|
const fromTypeObject = getFieldObjectByFieldExpression({
|
|
35
52
|
typeObject,
|
|
36
53
|
expression: fromExpression
|
|
37
54
|
}).typeObject;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
55
|
+
const fromResult = doPatternMatch(fromExpression, params, pattern["q/from"], typeObject);
|
|
56
|
+
if (!fromResult.matchSuccess) return noMatch();
|
|
57
|
+
const selectResult = matchSelectClause(expression["q/select"], params, pattern["q/select"], fromTypeObject);
|
|
58
|
+
if (!selectResult.matchSuccess || pattern["q/limit"] !== expression["q/limit"]) return noMatch();
|
|
59
|
+
const wherePattern = pattern["q/where"];
|
|
60
|
+
const whereResult = wherePattern === void 0 ? {
|
|
61
|
+
matchSuccess: expression["q/where"] === void 0,
|
|
62
|
+
matches: []
|
|
63
|
+
} : doPatternMatch(expression["q/where"], params, wherePattern, fromTypeObject);
|
|
64
|
+
if (!whereResult.matchSuccess) return noMatch();
|
|
42
65
|
return {
|
|
43
|
-
matchSuccess:
|
|
66
|
+
matchSuccess: true,
|
|
44
67
|
matches: [
|
|
45
|
-
...
|
|
46
|
-
...
|
|
47
|
-
...
|
|
68
|
+
...fromResult.matches,
|
|
69
|
+
...whereResult.matches,
|
|
70
|
+
...selectResult.matches
|
|
48
71
|
]
|
|
49
72
|
};
|
|
50
73
|
};
|
|
51
74
|
const matchExpression = (expressionPlaceholder, expression, typeObject) => {
|
|
52
|
-
if (!isString(expression) && !Array.isArray(expression)) return
|
|
53
|
-
|
|
54
|
-
matches: []
|
|
55
|
-
};
|
|
75
|
+
if (!isString(expression) && !Array.isArray(expression)) return noMatch();
|
|
76
|
+
const expressionValue = expression;
|
|
56
77
|
return {
|
|
57
|
-
matchSuccess:
|
|
78
|
+
matchSuccess: expressionPlaceholder.matchFn(expressionValue, typeObject),
|
|
58
79
|
matches: [{
|
|
59
80
|
matchType: ":expression-match-type/expression",
|
|
60
|
-
value: isString(
|
|
81
|
+
value: isString(expressionValue) ? [expressionValue] : expressionValue
|
|
61
82
|
}]
|
|
62
83
|
};
|
|
63
84
|
};
|
|
85
|
+
const matchPlaceholder = (expression, params, placeholder) => {
|
|
86
|
+
const value = isString(expression) && isVariableExpression(expression) ? params[expression] : expression;
|
|
87
|
+
if (!placeholder.matchFn(value)) return noMatch();
|
|
88
|
+
return {
|
|
89
|
+
matchSuccess: true,
|
|
90
|
+
matches: placeholder.id === ":expression-pattern/param-placeholder" ? [{
|
|
91
|
+
matchType: ":expression-match-type/param",
|
|
92
|
+
value
|
|
93
|
+
}] : []
|
|
94
|
+
};
|
|
95
|
+
};
|
|
64
96
|
const doPatternMatch = (expression, params, pattern, typeObject) => {
|
|
65
97
|
if (expression === pattern) return {
|
|
66
98
|
matchSuccess: true,
|
|
67
99
|
matches: []
|
|
68
100
|
};
|
|
69
|
-
if (pattern ===
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return zipWith(expression, pattern, (expressionNode, patternNode) => {
|
|
80
|
-
if (!patternNode) return {
|
|
81
|
-
matchSuccess: false,
|
|
82
|
-
matches: []
|
|
83
|
-
};
|
|
84
|
-
else if (isString(patternNode)) return {
|
|
85
|
-
matchSuccess: expressionNode === patternNode,
|
|
86
|
-
matches: []
|
|
87
|
-
};
|
|
88
|
-
else if (Array.isArray(patternNode)) return doPatternMatch(expressionNode, params, patternNode, typeObject);
|
|
89
|
-
else if (patternNode.id === ":expression-pattern/expression-placeholder") return matchExpression(patternNode, expressionNode, typeObject);
|
|
90
|
-
else if (patternNode.id === ":expression-pattern/param-placeholder" || patternNode.id === ":expression-pattern/constant-placeholder") {
|
|
91
|
-
const shouldReturnValue = patternNode.id === ":expression-pattern/param-placeholder";
|
|
92
|
-
if (isString(expressionNode) && isVariableExpression(expressionNode)) return {
|
|
93
|
-
matchSuccess: patternNode.matchFn(params[expressionNode]),
|
|
94
|
-
matches: shouldReturnValue ? [{
|
|
95
|
-
matchType: ":expression-match-type/param",
|
|
96
|
-
value: params[expressionNode]
|
|
97
|
-
}] : []
|
|
98
|
-
};
|
|
99
|
-
else return {
|
|
100
|
-
matchSuccess: patternNode.matchFn(expressionNode),
|
|
101
|
-
matches: shouldReturnValue ? [{
|
|
102
|
-
matchType: ":expression-match-type/param",
|
|
103
|
-
value: expressionNode
|
|
104
|
-
}] : []
|
|
105
|
-
};
|
|
106
|
-
} else if (patternNode["q/from"] && isRecord(expressionNode) && "q/from" in expressionNode) return matchQuery(expressionNode, params, patternNode, typeObject);
|
|
107
|
-
else return {
|
|
108
|
-
matchSuccess: false,
|
|
109
|
-
matches: []
|
|
110
|
-
};
|
|
111
|
-
}).reduce(({ matchSuccess: accMatchSuccess, matches: accMatches }, { matchSuccess, matches }) => {
|
|
112
|
-
if (!matchSuccess || !accMatchSuccess) return {
|
|
113
|
-
matchSuccess: false,
|
|
114
|
-
matches: []
|
|
115
|
-
};
|
|
116
|
-
return {
|
|
117
|
-
matchSuccess: true,
|
|
118
|
-
matches: matches ? [...accMatches, ...matches] : accMatches
|
|
119
|
-
};
|
|
120
|
-
}, {
|
|
101
|
+
if (isPlaceholderNode(pattern)) return pattern.id === ":expression-pattern/expression-placeholder" ? matchExpression(pattern, expression, typeObject) : matchPlaceholder(expression, params, pattern);
|
|
102
|
+
if (isQueryPatternNode(pattern)) return isQueryExpression(expression) ? matchQuery(expression, params, pattern, typeObject) : noMatch();
|
|
103
|
+
if (!Array.isArray(expression) || !Array.isArray(pattern) || expression.length !== pattern.length) return noMatch();
|
|
104
|
+
const matches = [];
|
|
105
|
+
for (let index = 0; index < pattern.length; index += 1) {
|
|
106
|
+
const result = doPatternMatch(expression[index], params, pattern[index], typeObject);
|
|
107
|
+
if (!result.matchSuccess) return noMatch();
|
|
108
|
+
matches.push(...result.matches);
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
121
111
|
matchSuccess: true,
|
|
122
|
-
matches
|
|
123
|
-
}
|
|
112
|
+
matches
|
|
113
|
+
};
|
|
124
114
|
};
|
|
125
115
|
//#endregion
|
|
126
|
-
export { doPatternMatch };
|
|
116
|
+
export { doPatternMatch, getExpressionArrayMatchValue, isExpressionPatternMatch, isParamPatternMatch };
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { Expression } from "../types.js";
|
|
2
|
+
import { ConvertResult, PatternNode } from "./types.js";
|
|
2
3
|
//#region src/filter-expression/pattern-to-expression.d.ts
|
|
3
|
-
|
|
4
|
-
id: string;
|
|
5
|
-
value?: unknown;
|
|
6
|
-
} | PatternNode[] | {
|
|
7
|
-
"q/from"?: unknown;
|
|
8
|
-
"q/select"?: PatternNode[];
|
|
9
|
-
"q/where"?: PatternNode[];
|
|
10
|
-
"q/limit"?: unknown;
|
|
11
|
-
};
|
|
12
|
-
declare const convertToExpression: (pattern: PatternNode[], filterExpression: Expression, value: string, getNextParamName: () => string) => {
|
|
13
|
-
expression: unknown[];
|
|
14
|
-
params: Record<string, unknown>;
|
|
15
|
-
};
|
|
4
|
+
declare const convertToExpression: (pattern: PatternNode[], filterExpression: Expression, value: unknown, getNextParamName: () => string) => ConvertResult;
|
|
16
5
|
//#endregion
|
|
17
6
|
export { convertToExpression };
|
|
@@ -1,42 +1,40 @@
|
|
|
1
1
|
import { paramsPlaceholdersLookup, parseRelativeDatePlaceholder } from "../params-placeholders.js";
|
|
2
2
|
//#region src/filter-expression/pattern-to-expression.ts
|
|
3
|
+
const isPlaceholderNode = (node) => {
|
|
4
|
+
if (typeof node !== "object" || node === null || Array.isArray(node)) return false;
|
|
5
|
+
const { id, matchFn } = node;
|
|
6
|
+
return typeof matchFn === "function" && (id === ":expression-pattern/expression-placeholder" || id === ":expression-pattern/param-placeholder" || id === ":expression-pattern/constant-placeholder");
|
|
7
|
+
};
|
|
8
|
+
const isQueryPatternNode = (node) => typeof node === "object" && node !== null && !Array.isArray(node) && "q/from" in node;
|
|
9
|
+
const isSelectPatternRecord = (pattern) => pattern !== void 0 && typeof pattern === "object" && pattern !== null && !Array.isArray(pattern) && !isPlaceholderNode(pattern);
|
|
3
10
|
const convertToExpression = (pattern, filterExpression, value, getNextParamName) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
const params = {};
|
|
12
|
+
const convertNode = (patternNode) => {
|
|
13
|
+
if (isPlaceholderNode(patternNode)) {
|
|
7
14
|
if (patternNode.id === ":expression-pattern/expression-placeholder") return filterExpression;
|
|
8
|
-
|
|
9
|
-
const paramName = Object.hasOwn(paramsPlaceholdersLookup, value) || parseRelativeDatePlaceholder(value) !== null ? value : getNextParamName();
|
|
15
|
+
if (patternNode.id === ":expression-pattern/param-placeholder") {
|
|
16
|
+
const paramName = typeof value === "string" && (Object.hasOwn(paramsPlaceholdersLookup, value) || parseRelativeDatePlaceholder(value) !== null) ? value : getNextParamName();
|
|
10
17
|
params[paramName] = value;
|
|
11
18
|
return paramName;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
return {
|
|
33
|
-
"q/from": filterExpression,
|
|
34
|
-
"q/select": selectExpression,
|
|
35
|
-
"q/where": whereExpression,
|
|
36
|
-
"q/limit": subQuery["q/limit"]
|
|
37
|
-
};
|
|
38
|
-
} else return patternNode;
|
|
39
|
-
}),
|
|
19
|
+
}
|
|
20
|
+
const paramName = getNextParamName();
|
|
21
|
+
params[paramName] = patternNode.value;
|
|
22
|
+
return paramName;
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(patternNode)) return patternNode.map(convertNode);
|
|
25
|
+
if (isQueryPatternNode(patternNode)) {
|
|
26
|
+
const query = { "q/from": filterExpression };
|
|
27
|
+
const selectPattern = patternNode["q/select"];
|
|
28
|
+
if (isSelectPatternRecord(selectPattern)) query["q/select"] = Object.fromEntries(Object.entries(selectPattern).map(([key, selectNode]) => [key, convertNode(selectNode)]));
|
|
29
|
+
else if (selectPattern !== void 0) query["q/select"] = convertNode(selectPattern);
|
|
30
|
+
if (patternNode["q/where"] !== void 0) query["q/where"] = convertNode(patternNode["q/where"]);
|
|
31
|
+
if (patternNode["q/limit"] !== void 0) query["q/limit"] = patternNode["q/limit"];
|
|
32
|
+
return query;
|
|
33
|
+
}
|
|
34
|
+
return patternNode;
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
expression: pattern.map(convertNode),
|
|
40
38
|
params
|
|
41
39
|
};
|
|
42
40
|
};
|
|
@@ -1,24 +1,47 @@
|
|
|
1
|
-
import { Expression } from "../types.js";
|
|
2
|
-
import { $TSFixMe } from "../tsfixme.js";
|
|
1
|
+
import { Expression, QueryLimit } from "../types.js";
|
|
3
2
|
import { TypeObject } from "@fibery/schema";
|
|
4
3
|
//#region src/filter-expression/types.d.ts
|
|
5
4
|
type CustomMatchResult = {
|
|
6
5
|
matchSuccess: false;
|
|
7
6
|
} | {
|
|
8
7
|
matchSuccess: true;
|
|
9
|
-
value?:
|
|
8
|
+
value?: unknown;
|
|
10
9
|
expression: Expression;
|
|
11
10
|
};
|
|
12
11
|
type CustomMatchFn = (where: Expression, params: Record<string, unknown>, typeObject: TypeObject) => CustomMatchResult;
|
|
12
|
+
type ExpressionPlaceholder = {
|
|
13
|
+
id: ":expression-pattern/expression-placeholder";
|
|
14
|
+
matchFn: (expression: Expression, typeObject: TypeObject) => boolean;
|
|
15
|
+
};
|
|
16
|
+
type ParamPlaceholder = {
|
|
17
|
+
id: ":expression-pattern/param-placeholder";
|
|
18
|
+
matchFn: (value: unknown) => boolean;
|
|
19
|
+
};
|
|
20
|
+
type ConstantPlaceholder = {
|
|
21
|
+
id: ":expression-pattern/constant-placeholder";
|
|
22
|
+
value: unknown;
|
|
23
|
+
matchFn: (value: unknown) => boolean;
|
|
24
|
+
};
|
|
25
|
+
type QueryPatternNode = {
|
|
26
|
+
"q/from": PatternNode;
|
|
27
|
+
"q/select"?: PatternNode | Record<string, PatternNode>;
|
|
28
|
+
"q/where"?: PatternNode;
|
|
29
|
+
"q/limit"?: QueryLimit;
|
|
30
|
+
};
|
|
31
|
+
type PatternNode = string | ExpressionPlaceholder | ParamPlaceholder | ConstantPlaceholder | QueryPatternNode | PatternNode[];
|
|
32
|
+
type ConvertResult = {
|
|
33
|
+
expression: Expression;
|
|
34
|
+
params: Record<string, unknown>;
|
|
35
|
+
};
|
|
13
36
|
type Operator = {
|
|
14
37
|
id: string;
|
|
15
38
|
type: string;
|
|
16
39
|
title: string;
|
|
17
40
|
/** Whether this is a negative operator (e.g. "is not", "does not contain"). Used for UI hints like filter color display. */
|
|
18
41
|
isNegative: boolean;
|
|
19
|
-
pattern?:
|
|
42
|
+
pattern?: PatternNode[];
|
|
20
43
|
customMatch?: CustomMatchFn;
|
|
21
|
-
customConvertToWhereExpression?: (expression: Expression, value:
|
|
44
|
+
customConvertToWhereExpression?: (expression: Expression, value: unknown, getNextParamName: () => string) => ConvertResult;
|
|
22
45
|
};
|
|
23
46
|
type ExpressionToFilterBy = {
|
|
24
47
|
title?: string;
|
|
@@ -30,4 +53,4 @@ type ExpressionToFilterBy = {
|
|
|
30
53
|
calculateRelationFieldExpressions?: () => ExpressionToFilterBy[];
|
|
31
54
|
};
|
|
32
55
|
//#endregion
|
|
33
|
-
export { CustomMatchFn, CustomMatchResult, ExpressionToFilterBy, Operator };
|
|
56
|
+
export { ConstantPlaceholder, ConvertResult, CustomMatchFn, CustomMatchResult, ExpressionPlaceholder, ExpressionToFilterBy, Operator, ParamPlaceholder, PatternNode, QueryPatternNode };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,193 +1,17 @@
|
|
|
1
1
|
import { ContextVariable, context_variables_d_exports } from "./context-variables.js";
|
|
2
2
|
import { Expression, ExpressionVisitor, ExpressionVisitorWithDefault, FieldExpression, FromRootExpression, FunctionCallExpression, MultiFieldAccess, OrderBy, Query, Select, SubQuery } from "./types.js";
|
|
3
3
|
import { ExpressionToFilterBy, Operator } from "./filter-expression/types.js";
|
|
4
|
+
import { findMatchedFilter } from "./filter-expression/index.js";
|
|
4
5
|
import { operators_d_exports } from "./filter-expression/operators.js";
|
|
6
|
+
import { convertToExpression } from "./filter-expression/pattern-to-expression.js";
|
|
5
7
|
import { params_placeholders_d_exports } from "./params-placeholders.js";
|
|
6
8
|
import { utils_d_exports } from "./utils.js";
|
|
7
9
|
import { visitors_d_exports } from "./visitors.js";
|
|
8
|
-
import "./index.js";
|
|
9
10
|
//#region src/index.d.ts
|
|
10
11
|
declare const filterExpression: {
|
|
11
|
-
findMatchedFilter:
|
|
12
|
-
operator: Operator;
|
|
13
|
-
value: any;
|
|
14
|
-
expression: Expression;
|
|
15
|
-
type: string;
|
|
16
|
-
id: string;
|
|
17
|
-
} | null;
|
|
12
|
+
findMatchedFilter: typeof findMatchedFilter;
|
|
18
13
|
operators: typeof operators_d_exports;
|
|
19
|
-
convertToExpression:
|
|
20
|
-
id: string;
|
|
21
|
-
value?: unknown;
|
|
22
|
-
} | {
|
|
23
|
-
"q/from"?: unknown;
|
|
24
|
-
"q/select"?: ( /*elided*/ any | {
|
|
25
|
-
id: string;
|
|
26
|
-
value?: unknown;
|
|
27
|
-
} | /*elided*/ any)[];
|
|
28
|
-
"q/where"?: ( /*elided*/ any | {
|
|
29
|
-
id: string;
|
|
30
|
-
value?: unknown;
|
|
31
|
-
} | /*elided*/ any)[];
|
|
32
|
-
"q/limit"?: unknown;
|
|
33
|
-
})[] | {
|
|
34
|
-
id: string;
|
|
35
|
-
value?: unknown;
|
|
36
|
-
} | {
|
|
37
|
-
"q/from"?: unknown;
|
|
38
|
-
"q/select"?: (any | {
|
|
39
|
-
id: string;
|
|
40
|
-
value?: unknown;
|
|
41
|
-
} | any)[];
|
|
42
|
-
"q/where"?: (any | {
|
|
43
|
-
id: string;
|
|
44
|
-
value?: unknown;
|
|
45
|
-
} | any)[];
|
|
46
|
-
"q/limit"?: unknown;
|
|
47
|
-
})[] | {
|
|
48
|
-
id: string;
|
|
49
|
-
value?: unknown;
|
|
50
|
-
} | {
|
|
51
|
-
"q/from"?: unknown;
|
|
52
|
-
"q/select"?: (any | {
|
|
53
|
-
id: string;
|
|
54
|
-
value?: unknown;
|
|
55
|
-
} | any)[];
|
|
56
|
-
"q/where"?: (any | {
|
|
57
|
-
id: string;
|
|
58
|
-
value?: unknown;
|
|
59
|
-
} | any)[];
|
|
60
|
-
"q/limit"?: unknown;
|
|
61
|
-
})[] | {
|
|
62
|
-
id: string;
|
|
63
|
-
value?: unknown;
|
|
64
|
-
} | {
|
|
65
|
-
"q/from"?: unknown;
|
|
66
|
-
"q/select"?: (any | {
|
|
67
|
-
id: string;
|
|
68
|
-
value?: unknown;
|
|
69
|
-
} | any)[];
|
|
70
|
-
"q/where"?: (any | {
|
|
71
|
-
id: string;
|
|
72
|
-
value?: unknown;
|
|
73
|
-
} | any)[];
|
|
74
|
-
"q/limit"?: unknown;
|
|
75
|
-
})[] | {
|
|
76
|
-
id: string;
|
|
77
|
-
value?: unknown;
|
|
78
|
-
} | {
|
|
79
|
-
"q/from"?: unknown;
|
|
80
|
-
"q/select"?: (any | {
|
|
81
|
-
id: string;
|
|
82
|
-
value?: unknown;
|
|
83
|
-
} | any)[];
|
|
84
|
-
"q/where"?: (any | {
|
|
85
|
-
id: string;
|
|
86
|
-
value?: unknown;
|
|
87
|
-
} | any)[];
|
|
88
|
-
"q/limit"?: unknown;
|
|
89
|
-
})[] | {
|
|
90
|
-
id: string;
|
|
91
|
-
value?: unknown;
|
|
92
|
-
} | {
|
|
93
|
-
"q/from"?: unknown;
|
|
94
|
-
"q/select"?: (any | {
|
|
95
|
-
id: string;
|
|
96
|
-
value?: unknown;
|
|
97
|
-
} | any)[];
|
|
98
|
-
"q/where"?: (any | {
|
|
99
|
-
id: string;
|
|
100
|
-
value?: unknown;
|
|
101
|
-
} | any)[];
|
|
102
|
-
"q/limit"?: unknown;
|
|
103
|
-
})[] | {
|
|
104
|
-
id: string;
|
|
105
|
-
value?: unknown;
|
|
106
|
-
} | {
|
|
107
|
-
"q/from"?: unknown;
|
|
108
|
-
"q/select"?: (any | {
|
|
109
|
-
id: string;
|
|
110
|
-
value?: unknown;
|
|
111
|
-
} | any)[];
|
|
112
|
-
"q/where"?: (any | {
|
|
113
|
-
id: string;
|
|
114
|
-
value?: unknown;
|
|
115
|
-
} | any)[];
|
|
116
|
-
"q/limit"?: unknown;
|
|
117
|
-
})[] | {
|
|
118
|
-
id: string;
|
|
119
|
-
value?: unknown;
|
|
120
|
-
} | {
|
|
121
|
-
"q/from"?: unknown;
|
|
122
|
-
"q/select"?: (any | {
|
|
123
|
-
id: string;
|
|
124
|
-
value?: unknown;
|
|
125
|
-
} | any)[];
|
|
126
|
-
"q/where"?: (any | {
|
|
127
|
-
id: string;
|
|
128
|
-
value?: unknown;
|
|
129
|
-
} | any)[];
|
|
130
|
-
"q/limit"?: unknown;
|
|
131
|
-
})[] | {
|
|
132
|
-
id: string;
|
|
133
|
-
value?: unknown;
|
|
134
|
-
} | {
|
|
135
|
-
"q/from"?: unknown;
|
|
136
|
-
"q/select"?: (any | {
|
|
137
|
-
id: string;
|
|
138
|
-
value?: unknown;
|
|
139
|
-
} | any)[];
|
|
140
|
-
"q/where"?: (any | {
|
|
141
|
-
id: string;
|
|
142
|
-
value?: unknown;
|
|
143
|
-
} | any)[];
|
|
144
|
-
"q/limit"?: unknown;
|
|
145
|
-
})[] | {
|
|
146
|
-
id: string;
|
|
147
|
-
value?: unknown;
|
|
148
|
-
} | {
|
|
149
|
-
"q/from"?: unknown;
|
|
150
|
-
"q/select"?: (any | {
|
|
151
|
-
id: string;
|
|
152
|
-
value?: unknown;
|
|
153
|
-
} | any)[];
|
|
154
|
-
"q/where"?: (any | {
|
|
155
|
-
id: string;
|
|
156
|
-
value?: unknown;
|
|
157
|
-
} | any)[];
|
|
158
|
-
"q/limit"?: unknown;
|
|
159
|
-
})[] | {
|
|
160
|
-
id: string;
|
|
161
|
-
value?: unknown;
|
|
162
|
-
} | {
|
|
163
|
-
"q/from"?: unknown;
|
|
164
|
-
"q/select"?: (any | {
|
|
165
|
-
id: string;
|
|
166
|
-
value?: unknown;
|
|
167
|
-
} | any)[];
|
|
168
|
-
"q/where"?: (any | {
|
|
169
|
-
id: string;
|
|
170
|
-
value?: unknown;
|
|
171
|
-
} | any)[];
|
|
172
|
-
"q/limit"?: unknown;
|
|
173
|
-
})[] | {
|
|
174
|
-
id: string;
|
|
175
|
-
value?: unknown;
|
|
176
|
-
} | {
|
|
177
|
-
"q/from"?: unknown;
|
|
178
|
-
"q/select"?: (any | {
|
|
179
|
-
id: string;
|
|
180
|
-
value?: unknown;
|
|
181
|
-
} | any)[];
|
|
182
|
-
"q/where"?: (any | {
|
|
183
|
-
id: string;
|
|
184
|
-
value?: unknown;
|
|
185
|
-
} | any)[];
|
|
186
|
-
"q/limit"?: unknown;
|
|
187
|
-
})[], filterExpression: Expression, value: string, getNextParamName: () => string) => {
|
|
188
|
-
expression: unknown[];
|
|
189
|
-
params: Record<string, unknown>;
|
|
190
|
-
};
|
|
14
|
+
convertToExpression: typeof convertToExpression;
|
|
191
15
|
};
|
|
192
16
|
//#endregion
|
|
193
17
|
export { type ContextVariable, type Expression, type ExpressionToFilterBy, type ExpressionVisitor, type ExpressionVisitorWithDefault, type FieldExpression, type FromRootExpression, type FunctionCallExpression, type MultiFieldAccess, type Operator, type OrderBy, type Query, type Select, type SubQuery, context_variables_d_exports as contextVariables, filterExpression, params_placeholders_d_exports as paramsPlaceholders, utils_d_exports as utils, visitors_d_exports as visitors };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/expression-utils",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.3",
|
|
4
4
|
"description": "utils for working with fibery api expressions",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"files": [
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"lodash": "4.17.21",
|
|
29
29
|
"moment": "2.29.4",
|
|
30
30
|
"uuid": "11.1.0",
|
|
31
|
-
"@fibery/helpers": "3.
|
|
31
|
+
"@fibery/helpers": "3.3.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@fibery/schema": "10.3.
|
|
34
|
+
"@fibery/schema": "10.3.2"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/lib/tsfixme.d.ts
DELETED
package/lib/tsfixme.js
DELETED
|
File without changes
|