@nymphjs/query-parser 1.0.0-beta.121 → 1.0.0-beta.123
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/CHANGELOG.md +10 -0
- package/README.md +52 -48
- package/dist/queryParser.js +285 -120
- package/dist/queryParser.js.map +1 -1
- package/dist/queryParser.test.js +402 -29
- package/dist/queryParser.test.js.map +1 -1
- package/package.json +8 -5
- package/src/queryParser.test.ts +454 -29
- package/src/queryParser.ts +300 -120
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-beta.123](https://forge.sciactive.com/sciactive/nymphjs/compare/v1.0.0-beta.122...v1.0.0-beta.123) (2026-09-23)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add new colon search syntax to, and fix issues with, query parser, change negation syntax ([510991a](https://forge.sciactive.com/sciactive/nymphjs/commits/510991a1466777d64a24062c82f81c7c83afa52b))
|
|
11
|
+
|
|
12
|
+
# [1.0.0-beta.122](https://forge.sciactive.com/sciactive/nymphjs/compare/v1.0.0-beta.121...v1.0.0-beta.122) (2026-09-22)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @nymphjs/query-parser
|
|
15
|
+
|
|
6
16
|
# [1.0.0-beta.121](https://forge.sciactive.com/sciactive/nymphjs/compare/v1.0.0-beta.120...v1.0.0-beta.121) (2026-09-17)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @nymphjs/query-parser
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Nymph Query Parser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Application Data and Access Framework for Node.js and the browser.
|
|
4
|
+
|
|
5
|
+
https://nymph.io/
|
|
4
6
|
|
|
5
7
|
The Query Parser is a utility for creating complex Nymph entity queries from a simple text input. Essentially, it turns a string into a Nymph query.
|
|
6
8
|
|
|
@@ -23,11 +25,11 @@ import Category from './Category';
|
|
|
23
25
|
async function doQuery() {
|
|
24
26
|
const [options, ...selectors] = queryParser({
|
|
25
27
|
query:
|
|
26
|
-
'limit:4 sort:mdate foobar (| [archived] mdate<"2 weeks ago") category<{
|
|
28
|
+
'limit:4 sort:mdate foobar (| [archived] mdate<"2 weeks ago") category<{Cat Tech}>',
|
|
27
29
|
entityClass: BlogPost,
|
|
28
30
|
defaultFields: ['title', 'body'],
|
|
29
31
|
qrefMap: {
|
|
30
|
-
|
|
32
|
+
Cat: {
|
|
31
33
|
class: Category,
|
|
32
34
|
defaultFields: ['name'],
|
|
33
35
|
},
|
|
@@ -97,127 +99,129 @@ Using a dash for sort means the results will not be sorted in any particular ord
|
|
|
97
99
|
|
|
98
100
|
These are the available clauses, and their syntax.
|
|
99
101
|
|
|
100
|
-
### equal and
|
|
102
|
+
### equal and not equal
|
|
101
103
|
|
|
102
104
|
Check for string or JSON representation equality.
|
|
103
105
|
|
|
104
|
-
- `name=string` or
|
|
105
|
-
- `name="string value"` or
|
|
106
|
+
- `name=string` or `-name=string`
|
|
107
|
+
- `name="string value"` or `-name="string value"`
|
|
106
108
|
- (Use this if you have a space in your string, or if your string could be interpreted as valid JSON. Escape double quotes with a leading backslash.)
|
|
107
|
-
- `name=JSON` or
|
|
109
|
+
- `name=JSON` or `-name=JSON`
|
|
108
110
|
- (Match a JSON encoded value (like `true`, `1`, `[1,2,3]`, or `{"prop":"val"}`).)
|
|
109
111
|
|
|
110
|
-
### guid and
|
|
112
|
+
### guid and not guid
|
|
111
113
|
|
|
112
114
|
Check for entity GUID.
|
|
113
115
|
|
|
114
|
-
- `{guid}` or
|
|
116
|
+
- `{guid}` or `-{guid}`
|
|
115
117
|
|
|
116
|
-
### tag and
|
|
118
|
+
### tag and not tag
|
|
117
119
|
|
|
118
120
|
Check for a tag.
|
|
119
121
|
|
|
120
|
-
- `<name>` or
|
|
122
|
+
- `<name>` or `-<name>`
|
|
121
123
|
|
|
122
|
-
### truthy and
|
|
124
|
+
### truthy and not truthy
|
|
123
125
|
|
|
124
126
|
Check for truthiness.
|
|
125
127
|
|
|
126
|
-
- `[name]` or
|
|
128
|
+
- `[name]` or `-[name]`
|
|
127
129
|
|
|
128
|
-
### ref and
|
|
130
|
+
### ref and not ref
|
|
129
131
|
|
|
130
132
|
Check for a reference to another entity.
|
|
131
133
|
|
|
132
|
-
- `name<{guid}>` or
|
|
134
|
+
- `name<{guid}>` or `-name<{guid}>`
|
|
133
135
|
|
|
134
|
-
### qref and
|
|
136
|
+
### qref and not qref
|
|
135
137
|
|
|
136
138
|
Check for a reference to another entity using a query.
|
|
137
139
|
|
|
138
|
-
- `name<{refclassname inner query}>` or
|
|
140
|
+
- `name<{refclassname inner query}>` or `-name<{refclassname inner query}>`
|
|
139
141
|
- (Escape curly brackets with a leading backslash.)
|
|
140
142
|
- (Requires a map of refclassname to their actual class and default fields.)
|
|
141
143
|
|
|
142
|
-
### contain and
|
|
144
|
+
### contain and not contain
|
|
143
145
|
|
|
144
146
|
Check if the array at the named property contains a value.
|
|
145
147
|
|
|
146
|
-
- `name<value>` or
|
|
148
|
+
- `name<value>` or `-name<value>`
|
|
147
149
|
- (Escape angle brackets with a leading backslash. If your value could be interpreted as valid JSON, encode it as a JSON string and use the JSON syntax instead.)
|
|
148
|
-
- `name<JSON>` or
|
|
150
|
+
- `name<JSON>` or `-name<JSON>`
|
|
149
151
|
- (Search for a JSON encoded value (like `true`, `1`, `[1,2,3]`, or `{"prop":"val"}`).)
|
|
150
152
|
|
|
151
|
-
### search and
|
|
153
|
+
### search and not search
|
|
152
154
|
|
|
153
155
|
Check for full-text search query match. Use single quotes to find sequential terms and double quotes to find exact terms. Use "or" as the or operator. Use "-" before a term as the negation operator. Stop words and punctuation are stripped. Case insensitive.
|
|
154
156
|
|
|
155
|
-
- `name(query)` or
|
|
157
|
+
- `name(query)` or `-name(query)`
|
|
158
|
+
- `name:query` or `name:'sequence query'` or `name:"exact query"` or `-name:query` or `-name:'sequence query'` or `-name:"exact query"`
|
|
159
|
+
- (The "limit", "offset", "sort", and "reverse" properties cannot be used with the colon syntax.)
|
|
156
160
|
|
|
157
|
-
### match and
|
|
161
|
+
### match and not match
|
|
158
162
|
|
|
159
163
|
Check for POSIX regex match.
|
|
160
164
|
|
|
161
|
-
- `name~/pattern/` or
|
|
165
|
+
- `name~/pattern/` or `-name~/pattern/`
|
|
162
166
|
|
|
163
|
-
### imatch and
|
|
167
|
+
### imatch and not imatch
|
|
164
168
|
|
|
165
169
|
Check for case insensitive POSIX regex match.
|
|
166
170
|
|
|
167
|
-
- `name~/pattern/i` or
|
|
171
|
+
- `name~/pattern/i` or `-name~/pattern/i`
|
|
168
172
|
|
|
169
|
-
### like and
|
|
173
|
+
### like and not like
|
|
170
174
|
|
|
171
175
|
Check for pattern match where \_ is single char wildcard and % is any length wildcard.
|
|
172
176
|
|
|
173
|
-
- `name~pattern` or
|
|
174
|
-
- `name~"pattern"` or
|
|
177
|
+
- `name~pattern` or `-name~pattern`
|
|
178
|
+
- `name~"pattern"` or `-name~"pattern"`
|
|
175
179
|
- (Use this if you have a space in your pattern.)
|
|
176
180
|
|
|
177
|
-
### ilike and
|
|
181
|
+
### ilike and not ilike
|
|
178
182
|
|
|
179
183
|
Check for case insensitive pattern match where \_ is single char wildcard and % is any length wildcard.
|
|
180
184
|
|
|
181
|
-
- `name~"pattern"i` or
|
|
185
|
+
- `name~"pattern"i` or `-name~"pattern"i`
|
|
182
186
|
|
|
183
|
-
### gt
|
|
187
|
+
### gt and not gt
|
|
184
188
|
|
|
185
189
|
Check a prop's value is greater than a given value.
|
|
186
190
|
|
|
187
|
-
- `name>number`
|
|
188
|
-
- `name>relative`
|
|
191
|
+
- `name>number` or `-name>number`
|
|
192
|
+
- `name>relative` or `-name>relative`
|
|
189
193
|
- (A single relative time value like `now` or `yesterday`.)
|
|
190
|
-
- `name>"relative time value"`
|
|
194
|
+
- `name>"relative time value"` or `-name>"relative time value"`
|
|
191
195
|
- (Use this for a time value with a space like `"two days from now"`, `"last thursday"`, `"+4 weeks"`, or `"5 minutes ago"`.)
|
|
192
196
|
|
|
193
|
-
### gte
|
|
197
|
+
### gte and not gte
|
|
194
198
|
|
|
195
199
|
Check a prop's value is greater than or equal to a given value.
|
|
196
200
|
|
|
197
|
-
- `name>=number`
|
|
198
|
-
- `name>=relative`
|
|
201
|
+
- `name>=number` or `-name>=number`
|
|
202
|
+
- `name>=relative` or `-name>=relative`
|
|
199
203
|
- (A single relative time value like `now` or `yesterday`.)
|
|
200
|
-
- `name>="relative time value"`
|
|
204
|
+
- `name>="relative time value"` or `-name>="relative time value"`
|
|
201
205
|
- (Use this for a time value with a space like `"two days from now"`, `"last thursday"`, `"+4 weeks"`, or `"5 minutes ago"`.)
|
|
202
206
|
|
|
203
|
-
### lt
|
|
207
|
+
### lt and not lt
|
|
204
208
|
|
|
205
209
|
Check a prop's value is less than a given value.
|
|
206
210
|
|
|
207
|
-
- `name<number`
|
|
208
|
-
- `name<relative`
|
|
211
|
+
- `name<number` or `-name<number`
|
|
212
|
+
- `name<relative` or `-name<relative`
|
|
209
213
|
- (A single relative time value like `now` or `yesterday`.)
|
|
210
|
-
- `name<"relative time value"`
|
|
214
|
+
- `name<"relative time value"` or `-name<"relative time value"`
|
|
211
215
|
- (Use this for a time value with a space like `"two days from now"`, `"last thursday"`, `"+4 weeks"`, or `"5 minutes ago"`.)
|
|
212
216
|
|
|
213
|
-
### lte
|
|
217
|
+
### lte and not lte
|
|
214
218
|
|
|
215
219
|
Check a prop's value is less than or equal to a given value.
|
|
216
220
|
|
|
217
|
-
- `name<=number`
|
|
218
|
-
- `name<=relative`
|
|
221
|
+
- `name<=number` or `-name<=number`
|
|
222
|
+
- `name<=relative` or `-name<=relative`
|
|
219
223
|
- (A single relative time value like `now` or `yesterday`.)
|
|
220
|
-
- `name<="relative time value"`
|
|
224
|
+
- `name<="relative time value"` or `-name<="relative time value"`
|
|
221
225
|
- (Use this for a time value with a space like `"two days from now"`, `"last thursday"`, `"+4 weeks"`, or `"5 minutes ago"`.)
|
|
222
226
|
|
|
223
227
|
## Selectors
|
|
@@ -247,7 +251,7 @@ You can also supply a function in the option `bareHandler` that will handle bare
|
|
|
247
251
|
|
|
248
252
|
# License
|
|
249
253
|
|
|
250
|
-
Copyright 2021-
|
|
254
|
+
Copyright 2021-2026 SciActive Inc
|
|
251
255
|
|
|
252
256
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
253
257
|
you may not use this file except in compliance with the License.
|