@react-querybuilder/core 8.14.4 → 8.16.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/README.md +114 -53
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +288 -22
- package/dist/cjs/react-querybuilder_core.cjs.development.js +796 -77
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +288 -22
- package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
- package/dist/{convertQuery-CeJSNn37.mjs → convertQuery-BeJJH9BI.mjs} +2 -2
- package/dist/convertQuery-BeJJH9BI.mjs.map +1 -0
- package/dist/{convertQuery-J8LpTG-7.js → convertQuery-Lx2HQa0m.js} +2 -2
- package/dist/convertQuery-Lx2HQa0m.js.map +1 -0
- package/dist/formatQuery.d.mts +89 -2
- package/dist/formatQuery.d.ts +89 -2
- package/dist/formatQuery.js +775 -66
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +768 -67
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-BwQqExpO.d.mts → import-BHlzBLM_.d.mts} +2 -2
- package/dist/{import-CrJf23Nf.d.ts → import-C6imciDf.d.ts} +2 -2
- package/dist/{index-CYT4Saz-.d.mts → index-Cjapnb-H.d.ts} +161 -10
- package/dist/{index-DBlQeLax.d.ts → index-D-Iej37L.d.mts} +161 -10
- package/dist/{objectUtils-ButT0Mng.js → objectUtils-Bzug_QfX.js} +2 -2
- package/dist/objectUtils-Bzug_QfX.js.map +1 -0
- package/dist/{objectUtils-C0WB-8ex.mjs → objectUtils-D96eEEzL.mjs} +2 -2
- package/dist/objectUtils-D96eEEzL.mjs.map +1 -0
- package/dist/parseCEL.d.mts +2 -2
- package/dist/parseCEL.d.ts +2 -2
- package/dist/parseCEL.js +35 -35
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +35 -35
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseCypher.d.mts +49 -0
- package/dist/parseCypher.d.ts +49 -0
- package/dist/parseCypher.js +578 -0
- package/dist/parseCypher.js.map +1 -0
- package/dist/parseCypher.mjs +575 -0
- package/dist/parseCypher.mjs.map +1 -0
- package/dist/parseGremlin.d.mts +35 -0
- package/dist/parseGremlin.d.ts +35 -0
- package/dist/parseGremlin.js +192 -0
- package/dist/parseGremlin.js.map +1 -0
- package/dist/parseGremlin.mjs +191 -0
- package/dist/parseGremlin.mjs.map +1 -0
- package/dist/parseJSONata.d.mts +2 -2
- package/dist/parseJSONata.d.ts +2 -2
- package/dist/parseJSONata.js +11 -11
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +11 -11
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +2 -2
- package/dist/parseJsonLogic.d.ts +2 -2
- package/dist/parseJsonLogic.js +6 -6
- package/dist/parseJsonLogic.js.map +1 -1
- package/dist/parseJsonLogic.mjs +6 -6
- package/dist/parseJsonLogic.mjs.map +1 -1
- package/dist/parseMongoDB.d.mts +2 -2
- package/dist/parseMongoDB.d.ts +2 -2
- package/dist/parseMongoDB.js +6 -6
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +6 -6
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSPARQL.d.mts +34 -0
- package/dist/parseSPARQL.d.ts +34 -0
- package/dist/parseSPARQL.js +253 -0
- package/dist/parseSPARQL.js.map +1 -0
- package/dist/parseSPARQL.mjs +251 -0
- package/dist/parseSPARQL.mjs.map +1 -0
- package/dist/parseSQL.d.mts +2 -2
- package/dist/parseSQL.d.ts +2 -2
- package/dist/parseSQL.js +16 -16
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +16 -16
- package/dist/parseSQL.mjs.map +1 -1
- package/dist/parseSpEL.d.mts +2 -2
- package/dist/parseSpEL.d.ts +2 -2
- package/dist/parseSpEL.js +10 -10
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +10 -10
- package/dist/parseSpEL.mjs.map +1 -1
- package/dist/{prepareQueryObjects-DO3qXriW.js → prepareQueryObjects-BoG5Rt8z.js} +6 -6
- package/dist/prepareQueryObjects-BoG5Rt8z.js.map +1 -0
- package/dist/{prepareQueryObjects-BfMlS4ql.mjs → prepareQueryObjects-uA10ZpZX.mjs} +6 -6
- package/dist/prepareQueryObjects-uA10ZpZX.mjs.map +1 -0
- package/dist/query-builder.css +1 -1
- package/dist/query-builder.css.map +1 -1
- package/dist/react-querybuilder_core.d.mts +288 -22
- package/dist/react-querybuilder_core.legacy-esm.d.ts +288 -22
- package/dist/react-querybuilder_core.legacy-esm.js +833 -108
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +788 -78
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +288 -22
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/styles/_main.scss +4 -0
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.d.ts +1 -1
- package/dist/transformQuery.js +1 -1
- package/dist/transformQuery.mjs +1 -1
- package/dist/{utils-BlMGIhvx.mjs → utils-ChLG90DP.mjs} +3 -3
- package/dist/utils-ChLG90DP.mjs.map +1 -0
- package/dist/{utils-CZRhzje-.js → utils-Qwkq2Q0F.js} +3 -3
- package/dist/utils-Qwkq2Q0F.js.map +1 -0
- package/formatQuery/package.json +1 -1
- package/package.json +53 -14
- package/parseCEL/package.json +1 -1
- package/parseCypher/package.json +4 -0
- package/parseGremlin/package.json +4 -0
- package/parseJSONata/package.json +1 -1
- package/parseJsonLogic/package.json +1 -1
- package/parseMongoDB/package.json +1 -1
- package/parseSPARQL/package.json +4 -0
- package/parseSQL/package.json +1 -1
- package/parseSpEL/package.json +1 -1
- package/transformQuery/package.json +1 -1
- package/dist/convertQuery-CeJSNn37.mjs.map +0 -1
- package/dist/convertQuery-J8LpTG-7.js.map +0 -1
- package/dist/objectUtils-ButT0Mng.js.map +0 -1
- package/dist/objectUtils-C0WB-8ex.mjs.map +0 -1
- package/dist/prepareQueryObjects-BfMlS4ql.mjs.map +0 -1
- package/dist/prepareQueryObjects-DO3qXriW.js.map +0 -1
- package/dist/utils-BlMGIhvx.mjs.map +0 -1
- package/dist/utils-CZRhzje-.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,84 +1,145 @@
|
|
|
1
1
|
# @react-querybuilder/core
|
|
2
2
|
|
|
3
|
-
Core non-React utilities for
|
|
3
|
+
Core non-React utilities for [React Query Builder](https://react-querybuilder.js.org/) — types, query processing, validation, formatters, and parsers.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Basic usage
|
|
8
|
-
|
|
9
|
-
`react-querybuilder` re-exports everything from this package, so you normally won't need to install `@react-querybuilder/core` by itself.
|
|
5
|
+
## Installation
|
|
10
6
|
|
|
11
7
|
```bash
|
|
12
8
|
npm i @react-querybuilder/core
|
|
13
9
|
# OR yarn add / pnpm add / bun add
|
|
14
10
|
```
|
|
15
11
|
|
|
16
|
-
|
|
12
|
+
> **Note:** `react-querybuilder` re-exports everything from this package, so projects already using the main package don't need to install `@react-querybuilder/core` separately.
|
|
13
|
+
|
|
14
|
+
## Export
|
|
15
|
+
|
|
16
|
+
[Full export documentation](https://react-querybuilder.js.org/docs/utils/export)
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Use `formatQuery` to convert a query object into any of the supported output formats:
|
|
19
19
|
|
|
20
20
|
```ts
|
|
21
|
+
import { formatQuery } from '@react-querybuilder/core';
|
|
22
|
+
|
|
21
23
|
const query = {
|
|
22
24
|
combinator: 'and',
|
|
23
25
|
rules: [
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
operator: 'beginsWith',
|
|
27
|
-
value: 'Stev',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
field: 'last_name',
|
|
31
|
-
operator: 'in',
|
|
32
|
-
value: 'Vai, Vaughan',
|
|
33
|
-
},
|
|
26
|
+
{ field: 'first_name', operator: 'beginsWith', value: 'Stev' },
|
|
27
|
+
{ field: 'last_name', operator: 'in', value: 'Vai, Vaughan' },
|
|
34
28
|
],
|
|
35
29
|
};
|
|
36
30
|
|
|
37
31
|
formatQuery(query, 'sql');
|
|
38
|
-
|
|
39
|
-
"(first_name like 'Stev%' and last_name in ('Vai', 'Vaughan'))"
|
|
40
|
-
*/
|
|
32
|
+
// "(first_name like 'Stev%' and last_name in ('Vai', 'Vaughan'))"
|
|
41
33
|
```
|
|
42
34
|
|
|
43
|
-
###
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
### Supported export formats
|
|
36
|
+
|
|
37
|
+
| Format | `formatQuery` type string | Output type | Description |
|
|
38
|
+
| ------------------------------------------------------------------------------- | ------------------------- | ----------------------- | ------------------------------------------- |
|
|
39
|
+
| JSON (formatted) | `"json"` | `string` | 2-space indented `JSON.stringify` |
|
|
40
|
+
| JSON (no IDs) | `"json_without_ids"` | `string` | Compact JSON without `id`/`path` properties |
|
|
41
|
+
| [SQL](https://en.wikipedia.org/wiki/SQL) | `"sql"` | `string` | Standard `WHERE` clause |
|
|
42
|
+
| SQL (parameterized) | `"parameterized"` | `ParameterizedSQL` | SQL with anonymous (`?`) bind variables |
|
|
43
|
+
| SQL (named params) | `"parameterized_named"` | `ParameterizedNamedSQL` | SQL with named (`:param`) bind variables |
|
|
44
|
+
| [MongoDB](https://www.mongodb.com/) | `"mongodb_query"` | `Record<string, any>` | MongoDB query object |
|
|
45
|
+
| [CEL](https://cel.dev/) | `"cel"` | `string` | Common Expression Language |
|
|
46
|
+
| [SpEL](https://docs.spring.io/spring-framework/reference/core/expressions.html) | `"spel"` | `string` | Spring Expression Language |
|
|
47
|
+
| [JsonLogic](https://jsonlogic.com/) | `"jsonlogic"` | `JsonLogic` | JsonLogic object |
|
|
48
|
+
| [JSONata](https://jsonata.org/) | `"jsonata"` | `string` | JSONata expression |
|
|
49
|
+
| [ElasticSearch](https://www.elastic.co/elasticsearch) | `"elasticsearch"` | `Record<string, any>` | ElasticSearch query DSL |
|
|
50
|
+
| [LDAP](https://ldap.com/) | `"ldap"` | `string` | LDAP filter string |
|
|
51
|
+
| [Cypher](https://neo4j.com/docs/cypher-manual/current/) | `"cypher"` | `string` | Neo4j Cypher `WHERE` clause |
|
|
52
|
+
| [SPARQL](https://www.w3.org/TR/sparql11-query/) | `"sparql"` | `string` | SPARQL `FILTER` clause |
|
|
53
|
+
| [Gremlin](https://tinkerpop.apache.org/gremlin.html) | `"gremlin"` | `string` | Apache TinkerPop Gremlin traversal |
|
|
54
|
+
| Natural language | `"natural_language"` | `string` | Human-readable description |
|
|
55
|
+
| [Drizzle](https://orm.drizzle.team/) | `"drizzle"` | Drizzle `SQL` | Drizzle ORM `where` clause |
|
|
56
|
+
| [Prisma](https://www.prisma.io/) | `"prisma"` | `Record<string, any>` | Prisma `where` object |
|
|
57
|
+
| [Sequelize](https://sequelize.org/) | `"sequelize"` | `Record<string, any>` | Sequelize `where` object |
|
|
58
|
+
|
|
59
|
+
## Import
|
|
60
|
+
|
|
61
|
+
[Full import documentation](https://react-querybuilder.js.org/docs/utils/import)
|
|
62
|
+
|
|
63
|
+
Parser functions convert query strings or objects from various languages into React Query Builder query objects. Each parser must be imported from its own sub-path.
|
|
46
64
|
|
|
47
65
|
```ts
|
|
48
|
-
|
|
49
|
-
// Everything but the `WHERE` expressions will be ignored.
|
|
66
|
+
import { parseSQL } from '@react-querybuilder/core/parseSQL';
|
|
50
67
|
|
|
68
|
+
// Accepts a full SELECT statement or just a WHERE clause
|
|
51
69
|
const query = parseSQL(
|
|
52
|
-
`SELECT * FROM my_table WHERE first_name LIKE 'Stev%' AND last_name
|
|
70
|
+
`SELECT * FROM my_table WHERE first_name LIKE 'Stev%' AND last_name IN ('Vai', 'Vaughan')`
|
|
53
71
|
);
|
|
72
|
+
```
|
|
54
73
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
### Supported import formats
|
|
75
|
+
|
|
76
|
+
| Format | Import statement |
|
|
77
|
+
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
78
|
+
| [SQL](https://en.wikipedia.org/wiki/SQL) | `import { parseSQL } from "@react-querybuilder/core/parseSQL"` |
|
|
79
|
+
| [MongoDB](https://www.mongodb.com/) | `import { parseMongoDB } from "@react-querybuilder/core/parseMongoDB"` |
|
|
80
|
+
| [JsonLogic](https://jsonlogic.com/) | `import { parseJsonLogic } from "@react-querybuilder/core/parseJsonLogic"` |
|
|
81
|
+
| [JSONata](https://jsonata.org/) | `import { parseJSONata } from "@react-querybuilder/core/parseJSONata"` |
|
|
82
|
+
| [CEL](https://cel.dev/) | `import { parseCEL } from "@react-querybuilder/core/parseCEL"` |
|
|
83
|
+
| [SpEL](https://docs.spring.io/spring-framework/reference/core/expressions.html) | `import { parseSpEL } from "@react-querybuilder/core/parseSpEL"` |
|
|
84
|
+
| [Cypher](https://neo4j.com/docs/cypher-manual/current/) | `import { parseCypher } from "@react-querybuilder/core/parseCypher"` |
|
|
85
|
+
| [GQL](https://www.iso.org/standard/76120.html) | `import { parseGQL } from "@react-querybuilder/core/parseCypher"` |
|
|
86
|
+
| [SPARQL](https://www.w3.org/TR/sparql11-query/) | `import { parseSPARQL } from "@react-querybuilder/core/parseSPARQL"` |
|
|
87
|
+
| [Gremlin](https://tinkerpop.apache.org/gremlin.html) | `import { parseGremlin } from "@react-querybuilder/core/parseGremlin"` |
|
|
88
|
+
|
|
89
|
+
## Query manipulation
|
|
90
|
+
|
|
91
|
+
[Full documentation](https://react-querybuilder.js.org/docs/utils/misc#query-tools)
|
|
92
|
+
|
|
93
|
+
Programmatically modify query objects with the same functions used internally by the `<QueryBuilder />` component:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { add, remove, update, move } from '@react-querybuilder/core';
|
|
97
|
+
|
|
98
|
+
const updated = add(query, newRule, parentPath);
|
|
99
|
+
const removed = remove(query, rulePath);
|
|
100
|
+
const modified = update(query, 'value', 'newValue', rulePath);
|
|
101
|
+
const moved = move(query, oldPath, newPath);
|
|
73
102
|
```
|
|
74
103
|
|
|
75
|
-
|
|
104
|
+
Available methods: `add`, `remove`, `update`, `move`, `insert`, `group`.
|
|
76
105
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
106
|
+
## `transformQuery`
|
|
107
|
+
|
|
108
|
+
[Full documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)
|
|
109
|
+
|
|
110
|
+
Recursively processes a query object, transforming rules, groups, operators, combinators, and property names:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import { transformQuery } from '@react-querybuilder/core';
|
|
114
|
+
|
|
115
|
+
const transformed = transformQuery(query, {
|
|
116
|
+
operatorMap: { '=': '==', '!=': '<>' },
|
|
117
|
+
combinatorMap: { and: '&&', or: '||' },
|
|
118
|
+
propertyMap: { field: 'column' },
|
|
119
|
+
ruleProcessor: rule => ({ ...rule, value: rule.value.trim() }),
|
|
120
|
+
});
|
|
84
121
|
```
|
|
122
|
+
|
|
123
|
+
## TypeScript
|
|
124
|
+
|
|
125
|
+
The core package exports the complete type system used throughout React Query Builder, enabling strongly-typed query manipulation without a React dependency:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import type {
|
|
129
|
+
RuleGroupType, // Standard query structure (combinators at group level)
|
|
130
|
+
RuleGroupTypeIC, // Independent combinators structure
|
|
131
|
+
RuleType, // Individual rule
|
|
132
|
+
FullField, // Field definition with all options
|
|
133
|
+
FullOperator, // Operator definition
|
|
134
|
+
FullCombinator, // Combinator definition
|
|
135
|
+
ExportFormat, // Union of all format strings
|
|
136
|
+
DefaultRuleGroupType,
|
|
137
|
+
DefaultRuleType,
|
|
138
|
+
} from '@react-querybuilder/core';
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Further reading
|
|
142
|
+
|
|
143
|
+
- [Full documentation](https://react-querybuilder.js.org/)
|
|
144
|
+
- [API reference](https://react-querybuilder.js.org/docs/api)
|
|
145
|
+
- [Demo](https://react-querybuilder.js.org/demo)
|