@fibery/expression-utils 9.7.2 → 10.0.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.
- package/lib/_virtual/_rolldown/runtime.js +13 -0
- package/lib/index.d.ts +191 -585
- package/lib/index.js +15 -50
- package/lib/src/context-variables.d.ts +27 -22
- package/lib/src/context-variables.js +106 -138
- package/lib/src/errors.d.ts +5 -2
- package/lib/src/errors.js +14 -14
- package/lib/src/field-expression-visitor-type-aware.d.ts +18 -16
- package/lib/src/field-expression-visitor-type-aware.js +116 -131
- package/lib/src/filter-expression/index.d.ts +12 -9
- package/lib/src/filter-expression/index.js +34 -47
- package/lib/src/filter-expression/operator-utils.d.ts +14 -11
- package/lib/src/filter-expression/operator-utils.js +191 -185
- package/lib/src/filter-expression/operators.d.ts +111 -106
- package/lib/src/filter-expression/operators.js +1130 -846
- package/lib/src/filter-expression/pattern-match-placeholders.d.ts +63 -61
- package/lib/src/filter-expression/pattern-match-placeholders.js +107 -138
- package/lib/src/filter-expression/pattern-match.d.ts +17 -15
- package/lib/src/filter-expression/pattern-match.js +118 -130
- package/lib/src/filter-expression/pattern-to-expression.d.ts +13 -11
- package/lib/src/filter-expression/pattern-to-expression.js +42 -45
- package/lib/src/filter-expression/types.d.ts +29 -26
- package/lib/src/filter-expression/types.js +0 -3
- package/lib/src/params-placeholders.d.ts +55 -51
- package/lib/src/params-placeholders.js +199 -192
- package/lib/src/tsfixme.d.ts +4 -1
- package/lib/src/tsfixme.js +0 -3
- package/lib/src/types.d.ts +47 -45
- package/lib/src/types.js +0 -3
- package/lib/src/utils.d.ts +53 -48
- package/lib/src/utils.js +276 -338
- package/lib/src/visitors.d.ts +43 -37
- package/lib/src/visitors.js +306 -365
- package/lib/test-data/schema-mock.d.ts +68 -751
- package/lib/test-data/schema-mock.js +175 -139
- package/package.json +17 -10
- package/lib/index.js.map +0 -1
- package/lib/src/context-variables.js.map +0 -1
- package/lib/src/errors.js.map +0 -1
- package/lib/src/field-expression-visitor-type-aware.js.map +0 -1
- package/lib/src/filter-expression/index.js.map +0 -1
- package/lib/src/filter-expression/operator-utils.js.map +0 -1
- package/lib/src/filter-expression/operators.js.map +0 -1
- package/lib/src/filter-expression/pattern-match-placeholders.js.map +0 -1
- package/lib/src/filter-expression/pattern-match.js.map +0 -1
- package/lib/src/filter-expression/pattern-to-expression.js.map +0 -1
- package/lib/src/filter-expression/types.js.map +0 -1
- package/lib/src/params-placeholders.js.map +0 -1
- package/lib/src/tsfixme.js.map +0 -1
- package/lib/src/types.js.map +0 -1
- package/lib/src/utils.js.map +0 -1
- package/lib/src/visitors.js.map +0 -1
- package/lib/test-data/schema-mock.js.map +0 -1
|
@@ -1,138 +1,126 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const isObject_1 = __importDefault(require("lodash/isObject"));
|
|
8
|
-
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
9
|
-
const isString_1 = __importDefault(require("lodash/isString"));
|
|
10
|
-
const zipWith_1 = __importDefault(require("lodash/zipWith"));
|
|
11
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import { getFieldObjectByFieldExpression, isFieldExpressionValid, isVariableExpression } from "../utils.js";
|
|
2
|
+
import { isRecord } from "@fibery/helpers/src/_";
|
|
3
|
+
import isPlainObject from "lodash/isPlainObject.js";
|
|
4
|
+
import isString from "lodash/isString.js";
|
|
5
|
+
import zipWith from "lodash/zipWith.js";
|
|
6
|
+
//#region src/filter-expression/pattern-match.ts
|
|
12
7
|
const matchSelectClause = (selectExpression, params, selectPattern, typeObject) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
if (selectExpression && isPlainObject(selectExpression) && isPlainObject(selectPattern)) {
|
|
9
|
+
if (Object.keys(selectExpression).length !== Object.keys(selectPattern).length) return {
|
|
10
|
+
matchSuccess: false,
|
|
11
|
+
matches: []
|
|
12
|
+
};
|
|
13
|
+
return Object.entries(selectExpression).reduce((acc, [key, value]) => {
|
|
14
|
+
const { matchSuccess, matches } = doPatternMatch(value, params, selectPattern[key], typeObject);
|
|
15
|
+
return {
|
|
16
|
+
matchSuccess: acc.matchSuccess && matchSuccess,
|
|
17
|
+
matches: acc.matches.concat(matches)
|
|
18
|
+
};
|
|
19
|
+
}, {
|
|
20
|
+
matchSuccess: true,
|
|
21
|
+
matches: []
|
|
22
|
+
});
|
|
23
|
+
} else return doPatternMatch(selectExpression, params, selectPattern, typeObject);
|
|
28
24
|
};
|
|
29
25
|
const matchQuery = (expression, params, pattern, typeObject) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
26
|
+
const fromExpression = expression["q/from"];
|
|
27
|
+
if (!isFieldExpressionValid({
|
|
28
|
+
typeObject,
|
|
29
|
+
expression: fromExpression
|
|
30
|
+
})) return {
|
|
31
|
+
matchSuccess: false,
|
|
32
|
+
matches: []
|
|
33
|
+
};
|
|
34
|
+
const fromTypeObject = getFieldObjectByFieldExpression({
|
|
35
|
+
typeObject,
|
|
36
|
+
expression: fromExpression
|
|
37
|
+
}).typeObject;
|
|
38
|
+
const { matchSuccess: fromMatchSuccess, matches: fromMatches } = doPatternMatch(fromExpression, params, pattern["q/from"], typeObject);
|
|
39
|
+
const { matchSuccess: selectMatchSuccess, matches: selectMatches } = matchSelectClause(expression["q/select"], params, pattern["q/select"], fromTypeObject);
|
|
40
|
+
const limitMatchSuccess = pattern["q/limit"] === expression["q/limit"];
|
|
41
|
+
const { matchSuccess: whereMatchSuccess, matches: whereMatches } = doPatternMatch(expression["q/where"], params, pattern["q/where"], fromTypeObject);
|
|
42
|
+
return {
|
|
43
|
+
matchSuccess: fromMatchSuccess && selectMatchSuccess && limitMatchSuccess && whereMatchSuccess,
|
|
44
|
+
matches: [
|
|
45
|
+
...fromMatches,
|
|
46
|
+
...whereMatches,
|
|
47
|
+
...selectMatches
|
|
48
|
+
]
|
|
49
|
+
};
|
|
49
50
|
};
|
|
50
51
|
const matchExpression = (expressionPlaceholder, expression, typeObject) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
52
|
+
if (!isString(expression) && !Array.isArray(expression)) return {
|
|
53
|
+
matchSuccess: false,
|
|
54
|
+
matches: []
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
matchSuccess: Boolean(expressionPlaceholder.matchFn(expression, typeObject)),
|
|
58
|
+
matches: [{
|
|
59
|
+
matchType: ":expression-match-type/expression",
|
|
60
|
+
value: isString(expression) ? [expression] : expression
|
|
61
|
+
}]
|
|
62
|
+
};
|
|
63
63
|
};
|
|
64
64
|
const doPatternMatch = (expression, params, pattern, typeObject) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return { matchSuccess: false, matches: [] };
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return zipped.reduce(({ matchSuccess: accMatchSuccess, matches: accMatches }, { matchSuccess, matches }) => {
|
|
128
|
-
if (!matchSuccess || !accMatchSuccess) {
|
|
129
|
-
return { matchSuccess: false, matches: [] };
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
matchSuccess: true,
|
|
133
|
-
matches: matches ? [...accMatches, ...matches] : accMatches,
|
|
134
|
-
};
|
|
135
|
-
}, { matchSuccess: true, matches: [] });
|
|
65
|
+
if (expression === pattern) return {
|
|
66
|
+
matchSuccess: true,
|
|
67
|
+
matches: []
|
|
68
|
+
};
|
|
69
|
+
if (pattern === void 0 || pattern === null) return {
|
|
70
|
+
matchSuccess: false,
|
|
71
|
+
matches: []
|
|
72
|
+
};
|
|
73
|
+
if (pattern.id === ":expression-pattern/expression-placeholder") return matchExpression(pattern, expression, typeObject);
|
|
74
|
+
if (expression && !isString(expression) && Object.hasOwn(expression, "q/from") && pattern["q/from"]) return matchQuery(expression, params, pattern, typeObject);
|
|
75
|
+
if (!(Array.isArray(expression) && Array.isArray(pattern))) return {
|
|
76
|
+
matchSuccess: false,
|
|
77
|
+
matches: []
|
|
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
|
+
}, {
|
|
121
|
+
matchSuccess: true,
|
|
122
|
+
matches: []
|
|
123
|
+
});
|
|
136
124
|
};
|
|
137
|
-
|
|
138
|
-
|
|
125
|
+
//#endregion
|
|
126
|
+
export { doPatternMatch };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Expression } from "../types.js";
|
|
2
|
+
//#region src/filter-expression/pattern-to-expression.d.ts
|
|
2
3
|
type PatternNode = {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
id: string;
|
|
5
|
+
value?: unknown;
|
|
5
6
|
} | PatternNode[] | {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
"q/from"?: unknown;
|
|
8
|
+
"q/select"?: PatternNode[];
|
|
9
|
+
"q/where"?: PatternNode[];
|
|
10
|
+
"q/limit"?: unknown;
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
declare const convertToExpression: (pattern: PatternNode[], filterExpression: Expression, value: string, getNextParamName: () => string) => {
|
|
13
|
+
expression: unknown[];
|
|
14
|
+
params: Record<string, unknown>;
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
//#endregion
|
|
17
|
+
export { convertToExpression };
|
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.convertToExpression = void 0;
|
|
4
|
-
const params_placeholders_1 = require("../params-placeholders");
|
|
1
|
+
import { paramsPlaceholdersLookup, parseRelativeDatePlaceholder } from "../params-placeholders.js";
|
|
2
|
+
//#region src/filter-expression/pattern-to-expression.ts
|
|
5
3
|
const convertToExpression = (pattern, filterExpression, value, getNextParamName) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return { expression, params };
|
|
4
|
+
let params = {};
|
|
5
|
+
return {
|
|
6
|
+
expression: pattern.map((patternNode) => {
|
|
7
|
+
if (patternNode.id === ":expression-pattern/expression-placeholder") return filterExpression;
|
|
8
|
+
else if (patternNode.id === ":expression-pattern/param-placeholder") {
|
|
9
|
+
const paramName = Object.hasOwn(paramsPlaceholdersLookup, value) || parseRelativeDatePlaceholder(value) !== null ? value : getNextParamName();
|
|
10
|
+
params[paramName] = value;
|
|
11
|
+
return paramName;
|
|
12
|
+
} else if (patternNode.id === ":expression-pattern/constant-placeholder") {
|
|
13
|
+
const paramName = getNextParamName();
|
|
14
|
+
params[paramName] = patternNode.value;
|
|
15
|
+
return paramName;
|
|
16
|
+
} else if (Array.isArray(patternNode)) {
|
|
17
|
+
const { expression, params: innerParams } = convertToExpression(patternNode, filterExpression, value, getNextParamName);
|
|
18
|
+
params = {
|
|
19
|
+
...params,
|
|
20
|
+
...innerParams
|
|
21
|
+
};
|
|
22
|
+
return expression;
|
|
23
|
+
} else if (patternNode["q/from"]) {
|
|
24
|
+
const subQuery = patternNode;
|
|
25
|
+
const { expression: selectExpression, params: selectParams } = convertToExpression(subQuery["q/select"], filterExpression, value, getNextParamName);
|
|
26
|
+
const { expression: whereExpression, params: whereParams } = convertToExpression(subQuery["q/where"], filterExpression, value, getNextParamName);
|
|
27
|
+
params = {
|
|
28
|
+
...params,
|
|
29
|
+
...selectParams,
|
|
30
|
+
...whereParams
|
|
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
|
+
}),
|
|
40
|
+
params
|
|
41
|
+
};
|
|
45
42
|
};
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
export { convertToExpression };
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Expression } from "../types.js";
|
|
2
|
+
import { $TSFixMe } from "../tsfixme.js";
|
|
3
|
+
import { TypeObject } from "@fibery/schema";
|
|
4
|
+
//#region src/filter-expression/types.d.ts
|
|
5
|
+
type CustomMatchResult = {
|
|
6
|
+
matchSuccess: false;
|
|
6
7
|
} | {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
matchSuccess: true;
|
|
9
|
+
value?: $TSFixMe;
|
|
10
|
+
expression: Expression;
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
type CustomMatchFn = (where: Expression, params: Record<string, unknown>, typeObject: TypeObject) => CustomMatchResult;
|
|
13
|
+
type Operator = {
|
|
14
|
+
id: string;
|
|
15
|
+
type: string;
|
|
16
|
+
title: string;
|
|
17
|
+
/** Whether this is a negative operator (e.g. "is not", "does not contain"). Used for UI hints like filter color display. */
|
|
18
|
+
isNegative: boolean;
|
|
19
|
+
pattern?: $TSFixMe;
|
|
20
|
+
customMatch?: CustomMatchFn;
|
|
21
|
+
customConvertToWhereExpression?: (expression: Expression, value: $TSFixMe, getNextParamName: () => string) => $TSFixMe;
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
type ExpressionToFilterBy = {
|
|
24
|
+
title?: string;
|
|
25
|
+
icon?: string;
|
|
26
|
+
itemExpressions: Array<{
|
|
27
|
+
expression: Expression;
|
|
28
|
+
type: string;
|
|
29
|
+
}>;
|
|
30
|
+
calculateRelationFieldExpressions?: () => ExpressionToFilterBy[];
|
|
30
31
|
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { CustomMatchFn, CustomMatchResult, ExpressionToFilterBy, Operator };
|
|
@@ -1,54 +1,58 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { Moment, unitOfTime } from "moment";
|
|
2
|
+
declare namespace params_placeholders_d_exports {
|
|
3
|
+
export { dateToDateTimeIntervalLookup, dynamicFilterParamPrefix, formulaNowDateTimeParamPlaceholder, formulaTodayDateParamPlaceholder, getFieldIdFromDynamicParam, getRelativeDateValue, getRelativeMomentDate, isDynamicFilterParam, mapDynamicParams, monthAgoDateParamPlaceholder, monthAgoEndDateTimeParamPlaceholder, monthAgoStartDateTimeParamPlaceholder, monthFromNowDateParamPlaceholder, monthFromNowEndDateTimeParamPlaceholder, monthFromNowStartDateTimeParamPlaceholder, paramsPlaceholdersLookup, parseRelativeDatePlaceholder, replacePlaceholdersInParams, toRelativeDatePlaceholder, todayDateParamPlaceholder, todayEndDateTimeParamPlaceholder, todayStartDateTimeParamPlaceholder, tomorrowDateParamPlaceholder, tomorrowEndDateTimeParamPlaceholder, tomorrowStartDateTimeParamPlaceholder, weekAgoDateParamPlaceholder, weekAgoEndDateTimeParamPlaceholder, weekAgoStartDateTimeParamPlaceholder, weekFromNowDateParamPlaceholder, weekFromNowEndDateTimeParamPlaceholder, weekFromNowStartDateTimeParamPlaceholder, whereParamPrefix, yearAgoDateParamPlaceholder, yearAgoEndDateTimeParamPlaceholder, yearAgoStartDateTimeParamPlaceholder, yearFromNowDateParamPlaceholder, yearFromNowEndDateTimeParamPlaceholder, yearFromNowStartDateTimeParamPlaceholder, yesterdayDateParamPlaceholder, yesterdayEndDateTimeParamPlaceholder, yesterdayStartDateTimeParamPlaceholder };
|
|
4
|
+
}
|
|
5
|
+
declare const formulaTodayDateParamPlaceholder = "$formula-today-date-placeholder";
|
|
6
|
+
declare const formulaNowDateTimeParamPlaceholder = "$formula-now-date-time-placeholder";
|
|
7
|
+
declare const todayDateParamPlaceholder = "$today-date";
|
|
8
|
+
declare const tomorrowDateParamPlaceholder = "$tomorrow-date";
|
|
9
|
+
declare const yesterdayDateParamPlaceholder = "$yesterday-date";
|
|
10
|
+
declare const weekAgoDateParamPlaceholder = "$week-ago-date";
|
|
11
|
+
declare const weekFromNowDateParamPlaceholder = "$week-from-now-date";
|
|
12
|
+
declare const monthAgoDateParamPlaceholder = "$month-ago-date";
|
|
13
|
+
declare const monthFromNowDateParamPlaceholder = "$month-from-now-date";
|
|
14
|
+
declare const yearAgoDateParamPlaceholder = "$year-ago-date";
|
|
15
|
+
declare const yearFromNowDateParamPlaceholder = "$year-from-now-date";
|
|
16
|
+
declare const todayStartDateTimeParamPlaceholder = "$today-date-time-start";
|
|
17
|
+
declare const todayEndDateTimeParamPlaceholder = "$today-date-time-end";
|
|
18
|
+
declare const tomorrowStartDateTimeParamPlaceholder = "$tomorrow-date-time-start";
|
|
19
|
+
declare const tomorrowEndDateTimeParamPlaceholder = "$tomorrow-date-time-end";
|
|
20
|
+
declare const yesterdayStartDateTimeParamPlaceholder = "$yesterday-date-time-start";
|
|
21
|
+
declare const yesterdayEndDateTimeParamPlaceholder = "$yesterday-date-time-end";
|
|
22
|
+
declare const weekAgoStartDateTimeParamPlaceholder = "$week-ago-date-time-start";
|
|
23
|
+
declare const weekAgoEndDateTimeParamPlaceholder = "$week-ago-date-time-end";
|
|
24
|
+
declare const weekFromNowStartDateTimeParamPlaceholder = "$week-from-now-date-time-start";
|
|
25
|
+
declare const weekFromNowEndDateTimeParamPlaceholder = "$week-from-now-date-time-end";
|
|
26
|
+
declare const monthAgoStartDateTimeParamPlaceholder = "$month-ago-date-time-start";
|
|
27
|
+
declare const monthAgoEndDateTimeParamPlaceholder = "$month-ago-date-time-end";
|
|
28
|
+
declare const monthFromNowStartDateTimeParamPlaceholder = "$month-from-now-date-time-start";
|
|
29
|
+
declare const monthFromNowEndDateTimeParamPlaceholder = "$month-from-now-date-time-end";
|
|
30
|
+
declare const yearAgoStartDateTimeParamPlaceholder = "$year-ago-date-time-start";
|
|
31
|
+
declare const yearAgoEndDateTimeParamPlaceholder = "$year-ago-date-time-end";
|
|
32
|
+
declare const yearFromNowStartDateTimeParamPlaceholder = "$year-from-now-date-time-start";
|
|
33
|
+
declare const yearFromNowEndDateTimeParamPlaceholder = "$year-from-now-date-time-end";
|
|
34
|
+
declare const paramsPlaceholdersLookup: Record<string, () => string>;
|
|
35
|
+
declare const dynamicFilterParamPrefix = "$dynamic_";
|
|
36
|
+
declare const isDynamicFilterParam: (paramValue: string) => boolean;
|
|
37
|
+
declare const getFieldIdFromDynamicParam: (paramValue: string) => string;
|
|
38
|
+
declare const whereParamPrefix = "$where";
|
|
39
|
+
declare const mapDynamicParams: <T extends Record<string, unknown>>(params: T | null, onDynamicParam: (value: string) => string) => T | null;
|
|
37
40
|
type RelativeDateInfo = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
isStartOfInterval?: boolean;
|
|
42
|
+
unitForStart?: unitOfTime.DurationConstructor;
|
|
43
|
+
amount: number;
|
|
44
|
+
unit: unitOfTime.DurationConstructor;
|
|
45
|
+
isBeforeNow: boolean;
|
|
46
|
+
isDateTime?: boolean;
|
|
44
47
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
declare const getRelativeMomentDate: ({ isStartOfInterval, unitForStart, amount, unit, isBeforeNow }: Omit<RelativeDateInfo, "isDateTime">) => Moment;
|
|
49
|
+
declare const getRelativeDateValue: ({ isStartOfInterval, unitForStart, amount, unit, isBeforeNow, isDateTime }: RelativeDateInfo) => string;
|
|
50
|
+
declare const toRelativeDatePlaceholder: ({ isStartOfInterval, unitForStart, amount, unit, isBeforeNow, isDateTime }: RelativeDateInfo) => string;
|
|
51
|
+
declare const parseRelativeDatePlaceholder: (placeholder: unknown) => RelativeDateInfo | null;
|
|
52
|
+
declare function replacePlaceholdersInParams<T extends Record<string, unknown>>(params: T | null | undefined): T | null | undefined;
|
|
53
|
+
declare const dateToDateTimeIntervalLookup: Record<string, {
|
|
54
|
+
start: string;
|
|
55
|
+
end: string;
|
|
53
56
|
}>;
|
|
54
|
-
|
|
57
|
+
//#endregion
|
|
58
|
+
export { dateToDateTimeIntervalLookup, dynamicFilterParamPrefix, formulaNowDateTimeParamPlaceholder, formulaTodayDateParamPlaceholder, getFieldIdFromDynamicParam, getRelativeDateValue, getRelativeMomentDate, isDynamicFilterParam, mapDynamicParams, monthAgoDateParamPlaceholder, monthAgoEndDateTimeParamPlaceholder, monthAgoStartDateTimeParamPlaceholder, monthFromNowDateParamPlaceholder, monthFromNowEndDateTimeParamPlaceholder, monthFromNowStartDateTimeParamPlaceholder, paramsPlaceholdersLookup, params_placeholders_d_exports, parseRelativeDatePlaceholder, replacePlaceholdersInParams, toRelativeDatePlaceholder, todayDateParamPlaceholder, todayEndDateTimeParamPlaceholder, todayStartDateTimeParamPlaceholder, tomorrowDateParamPlaceholder, tomorrowEndDateTimeParamPlaceholder, tomorrowStartDateTimeParamPlaceholder, weekAgoDateParamPlaceholder, weekAgoEndDateTimeParamPlaceholder, weekAgoStartDateTimeParamPlaceholder, weekFromNowDateParamPlaceholder, weekFromNowEndDateTimeParamPlaceholder, weekFromNowStartDateTimeParamPlaceholder, whereParamPrefix, yearAgoDateParamPlaceholder, yearAgoEndDateTimeParamPlaceholder, yearAgoStartDateTimeParamPlaceholder, yearFromNowDateParamPlaceholder, yearFromNowEndDateTimeParamPlaceholder, yearFromNowStartDateTimeParamPlaceholder, yesterdayDateParamPlaceholder, yesterdayEndDateTimeParamPlaceholder, yesterdayStartDateTimeParamPlaceholder };
|