@marianmeres/condition-parser 1.3.0 → 1.4.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/dist/parser.d.ts +6 -0
- package/dist/parser.js +7 -0
- package/package.json +1 -1
package/dist/parser.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { ConditionDump, ExpressionContext } from "@marianmeres/condition-builder";
|
|
2
|
+
interface ExpressionData {
|
|
3
|
+
key: string;
|
|
4
|
+
operator: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
2
7
|
interface Meta {
|
|
3
8
|
keys: string[];
|
|
4
9
|
operators: string[];
|
|
5
10
|
values: any[];
|
|
11
|
+
expressions: ExpressionData[];
|
|
6
12
|
}
|
|
7
13
|
/** ConditionParser.parse options */
|
|
8
14
|
export interface ConditionParserOptions {
|
package/dist/parser.js
CHANGED
|
@@ -20,6 +20,7 @@ export class ConditionParser {
|
|
|
20
20
|
keys: new Set([]),
|
|
21
21
|
operators: new Set([]),
|
|
22
22
|
values: new Set([]),
|
|
23
|
+
expressions: new Set([]),
|
|
23
24
|
};
|
|
24
25
|
#transform;
|
|
25
26
|
#preAddHook;
|
|
@@ -258,6 +259,8 @@ export class ConditionParser {
|
|
|
258
259
|
this.#meta.keys.add(expression.key);
|
|
259
260
|
this.#meta.operators.add(expression.operator);
|
|
260
261
|
this.#meta.values.add(expression.value);
|
|
262
|
+
// need to make it unique... so just quick-n-dirty
|
|
263
|
+
this.#meta.expressions.add(JSON.stringify([expression.key, expression.operator, expression.value]));
|
|
261
264
|
out.push(result);
|
|
262
265
|
}
|
|
263
266
|
/** Will recursively parse (...) */
|
|
@@ -387,6 +390,10 @@ export class ConditionParser {
|
|
|
387
390
|
keys: [...parser.#meta.keys],
|
|
388
391
|
operators: [...parser.#meta.operators],
|
|
389
392
|
values: [...parser.#meta.values],
|
|
393
|
+
expressions: [...parser.#meta.expressions].map((v) => {
|
|
394
|
+
const [key, operator, value] = JSON.parse(v);
|
|
395
|
+
return { key, operator, value };
|
|
396
|
+
}),
|
|
390
397
|
},
|
|
391
398
|
};
|
|
392
399
|
}
|