@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.
Files changed (123) hide show
  1. package/README.md +114 -53
  2. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +288 -22
  3. package/dist/cjs/react-querybuilder_core.cjs.development.js +796 -77
  4. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  5. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +288 -22
  6. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  7. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  8. package/dist/{convertQuery-CeJSNn37.mjs → convertQuery-BeJJH9BI.mjs} +2 -2
  9. package/dist/convertQuery-BeJJH9BI.mjs.map +1 -0
  10. package/dist/{convertQuery-J8LpTG-7.js → convertQuery-Lx2HQa0m.js} +2 -2
  11. package/dist/convertQuery-Lx2HQa0m.js.map +1 -0
  12. package/dist/formatQuery.d.mts +89 -2
  13. package/dist/formatQuery.d.ts +89 -2
  14. package/dist/formatQuery.js +775 -66
  15. package/dist/formatQuery.js.map +1 -1
  16. package/dist/formatQuery.mjs +768 -67
  17. package/dist/formatQuery.mjs.map +1 -1
  18. package/dist/{import-BwQqExpO.d.mts → import-BHlzBLM_.d.mts} +2 -2
  19. package/dist/{import-CrJf23Nf.d.ts → import-C6imciDf.d.ts} +2 -2
  20. package/dist/{index-CYT4Saz-.d.mts → index-Cjapnb-H.d.ts} +161 -10
  21. package/dist/{index-DBlQeLax.d.ts → index-D-Iej37L.d.mts} +161 -10
  22. package/dist/{objectUtils-ButT0Mng.js → objectUtils-Bzug_QfX.js} +2 -2
  23. package/dist/objectUtils-Bzug_QfX.js.map +1 -0
  24. package/dist/{objectUtils-C0WB-8ex.mjs → objectUtils-D96eEEzL.mjs} +2 -2
  25. package/dist/objectUtils-D96eEEzL.mjs.map +1 -0
  26. package/dist/parseCEL.d.mts +2 -2
  27. package/dist/parseCEL.d.ts +2 -2
  28. package/dist/parseCEL.js +35 -35
  29. package/dist/parseCEL.js.map +1 -1
  30. package/dist/parseCEL.mjs +35 -35
  31. package/dist/parseCEL.mjs.map +1 -1
  32. package/dist/parseCypher.d.mts +49 -0
  33. package/dist/parseCypher.d.ts +49 -0
  34. package/dist/parseCypher.js +578 -0
  35. package/dist/parseCypher.js.map +1 -0
  36. package/dist/parseCypher.mjs +575 -0
  37. package/dist/parseCypher.mjs.map +1 -0
  38. package/dist/parseGremlin.d.mts +35 -0
  39. package/dist/parseGremlin.d.ts +35 -0
  40. package/dist/parseGremlin.js +192 -0
  41. package/dist/parseGremlin.js.map +1 -0
  42. package/dist/parseGremlin.mjs +191 -0
  43. package/dist/parseGremlin.mjs.map +1 -0
  44. package/dist/parseJSONata.d.mts +2 -2
  45. package/dist/parseJSONata.d.ts +2 -2
  46. package/dist/parseJSONata.js +11 -11
  47. package/dist/parseJSONata.js.map +1 -1
  48. package/dist/parseJSONata.mjs +11 -11
  49. package/dist/parseJSONata.mjs.map +1 -1
  50. package/dist/parseJsonLogic.d.mts +2 -2
  51. package/dist/parseJsonLogic.d.ts +2 -2
  52. package/dist/parseJsonLogic.js +6 -6
  53. package/dist/parseJsonLogic.js.map +1 -1
  54. package/dist/parseJsonLogic.mjs +6 -6
  55. package/dist/parseJsonLogic.mjs.map +1 -1
  56. package/dist/parseMongoDB.d.mts +2 -2
  57. package/dist/parseMongoDB.d.ts +2 -2
  58. package/dist/parseMongoDB.js +6 -6
  59. package/dist/parseMongoDB.js.map +1 -1
  60. package/dist/parseMongoDB.mjs +6 -6
  61. package/dist/parseMongoDB.mjs.map +1 -1
  62. package/dist/parseSPARQL.d.mts +34 -0
  63. package/dist/parseSPARQL.d.ts +34 -0
  64. package/dist/parseSPARQL.js +253 -0
  65. package/dist/parseSPARQL.js.map +1 -0
  66. package/dist/parseSPARQL.mjs +251 -0
  67. package/dist/parseSPARQL.mjs.map +1 -0
  68. package/dist/parseSQL.d.mts +2 -2
  69. package/dist/parseSQL.d.ts +2 -2
  70. package/dist/parseSQL.js +16 -16
  71. package/dist/parseSQL.js.map +1 -1
  72. package/dist/parseSQL.mjs +16 -16
  73. package/dist/parseSQL.mjs.map +1 -1
  74. package/dist/parseSpEL.d.mts +2 -2
  75. package/dist/parseSpEL.d.ts +2 -2
  76. package/dist/parseSpEL.js +10 -10
  77. package/dist/parseSpEL.js.map +1 -1
  78. package/dist/parseSpEL.mjs +10 -10
  79. package/dist/parseSpEL.mjs.map +1 -1
  80. package/dist/{prepareQueryObjects-DO3qXriW.js → prepareQueryObjects-BoG5Rt8z.js} +6 -6
  81. package/dist/prepareQueryObjects-BoG5Rt8z.js.map +1 -0
  82. package/dist/{prepareQueryObjects-BfMlS4ql.mjs → prepareQueryObjects-uA10ZpZX.mjs} +6 -6
  83. package/dist/prepareQueryObjects-uA10ZpZX.mjs.map +1 -0
  84. package/dist/query-builder.css +1 -1
  85. package/dist/query-builder.css.map +1 -1
  86. package/dist/react-querybuilder_core.d.mts +288 -22
  87. package/dist/react-querybuilder_core.legacy-esm.d.ts +288 -22
  88. package/dist/react-querybuilder_core.legacy-esm.js +833 -108
  89. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  90. package/dist/react-querybuilder_core.mjs +788 -78
  91. package/dist/react-querybuilder_core.mjs.map +1 -1
  92. package/dist/react-querybuilder_core.production.d.mts +288 -22
  93. package/dist/react-querybuilder_core.production.mjs +1 -1
  94. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  95. package/dist/styles/_main.scss +4 -0
  96. package/dist/transformQuery.d.mts +1 -1
  97. package/dist/transformQuery.d.ts +1 -1
  98. package/dist/transformQuery.js +1 -1
  99. package/dist/transformQuery.mjs +1 -1
  100. package/dist/{utils-BlMGIhvx.mjs → utils-ChLG90DP.mjs} +3 -3
  101. package/dist/utils-ChLG90DP.mjs.map +1 -0
  102. package/dist/{utils-CZRhzje-.js → utils-Qwkq2Q0F.js} +3 -3
  103. package/dist/utils-Qwkq2Q0F.js.map +1 -0
  104. package/formatQuery/package.json +1 -1
  105. package/package.json +53 -14
  106. package/parseCEL/package.json +1 -1
  107. package/parseCypher/package.json +4 -0
  108. package/parseGremlin/package.json +4 -0
  109. package/parseJSONata/package.json +1 -1
  110. package/parseJsonLogic/package.json +1 -1
  111. package/parseMongoDB/package.json +1 -1
  112. package/parseSPARQL/package.json +4 -0
  113. package/parseSQL/package.json +1 -1
  114. package/parseSpEL/package.json +1 -1
  115. package/transformQuery/package.json +1 -1
  116. package/dist/convertQuery-CeJSNn37.mjs.map +0 -1
  117. package/dist/convertQuery-J8LpTG-7.js.map +0 -1
  118. package/dist/objectUtils-ButT0Mng.js.map +0 -1
  119. package/dist/objectUtils-C0WB-8ex.mjs.map +0 -1
  120. package/dist/prepareQueryObjects-BfMlS4ql.mjs.map +0 -1
  121. package/dist/prepareQueryObjects-DO3qXriW.js.map +0 -1
  122. package/dist/utils-BlMGIhvx.mjs.map +0 -1
  123. 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 `react-querybuilder` and associated packages - types, query processing, validation, and formatters.
3
+ Core non-React utilities for [React Query Builder](https://react-querybuilder.js.org/) types, query processing, validation, formatters, and parsers.
4
4
 
5
- [Full documentation](https://react-querybuilder.js.org/)
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
- ### Export
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
- To [export queries](https://react-querybuilder.js.org/docs/utils/export) as a SQL `WHERE` clause, MongoDB query object, or one of several other formats, use `formatQuery`.
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
- field: 'first_name',
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
- ### Import
44
-
45
- To [import queries](https://react-querybuilder.js.org/docs/utils/import) use `parseSQL`, `parseMongoDB`, `parseJsonLogic`, `parseJSONata`, `parseCEL`, or `parseSpEL` depending on the source.
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
- // Tip: `parseSQL` will accept either a full `SELECT` statement or a `WHERE` clause by itself.
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 in ('Vai', 'Vaughan')`
70
+ `SELECT * FROM my_table WHERE first_name LIKE 'Stev%' AND last_name IN ('Vai', 'Vaughan')`
53
71
  );
72
+ ```
54
73
 
55
- console.log(query);
56
- /*
57
- {
58
- "combinator": "and",
59
- "rules": [
60
- {
61
- "field": "first_name",
62
- "operator": "beginsWith",
63
- "value": "Stev",
64
- },
65
- {
66
- "field": "last_name",
67
- "operator": "in",
68
- "value": "Vai, Vaughan",
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
- The `parse*` functions must be imported from a sub-path, like this:
104
+ Available methods: `add`, `remove`, `update`, `move`, `insert`, `group`.
76
105
 
77
- ```js
78
- import { parseCEL } from '@react-querybuilder/core/parseCEL';
79
- import { parseJSONata } from '@react-querybuilder/core/parseJSONata';
80
- import { parseJsonLogic } from '@react-querybuilder/core/parseJsonLogic';
81
- import { parseMongoDB } from '@react-querybuilder/core/parseMongoDB';
82
- import { parseSpEL } from '@react-querybuilder/core/parseSpEL';
83
- import { parseSQL } from '@react-querybuilder/core/parseSQL';
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)