@nymphjs/query-parser 1.0.0-beta.122 → 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 +6 -0
- package/README.md +48 -46
- 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 +3 -3
- package/src/queryParser.test.ts +454 -29
- package/src/queryParser.ts +300 -120
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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
|
+
|
|
6
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)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @nymphjs/query-parser
|
package/README.md
CHANGED
|
@@ -25,11 +25,11 @@ import Category from './Category';
|
|
|
25
25
|
async function doQuery() {
|
|
26
26
|
const [options, ...selectors] = queryParser({
|
|
27
27
|
query:
|
|
28
|
-
'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}>',
|
|
29
29
|
entityClass: BlogPost,
|
|
30
30
|
defaultFields: ['title', 'body'],
|
|
31
31
|
qrefMap: {
|
|
32
|
-
|
|
32
|
+
Cat: {
|
|
33
33
|
class: Category,
|
|
34
34
|
defaultFields: ['name'],
|
|
35
35
|
},
|
|
@@ -99,127 +99,129 @@ Using a dash for sort means the results will not be sorted in any particular ord
|
|
|
99
99
|
|
|
100
100
|
These are the available clauses, and their syntax.
|
|
101
101
|
|
|
102
|
-
### equal and
|
|
102
|
+
### equal and not equal
|
|
103
103
|
|
|
104
104
|
Check for string or JSON representation equality.
|
|
105
105
|
|
|
106
|
-
- `name=string` or
|
|
107
|
-
- `name="string value"` or
|
|
106
|
+
- `name=string` or `-name=string`
|
|
107
|
+
- `name="string value"` or `-name="string value"`
|
|
108
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.)
|
|
109
|
-
- `name=JSON` or
|
|
109
|
+
- `name=JSON` or `-name=JSON`
|
|
110
110
|
- (Match a JSON encoded value (like `true`, `1`, `[1,2,3]`, or `{"prop":"val"}`).)
|
|
111
111
|
|
|
112
|
-
### guid and
|
|
112
|
+
### guid and not guid
|
|
113
113
|
|
|
114
114
|
Check for entity GUID.
|
|
115
115
|
|
|
116
|
-
- `{guid}` or
|
|
116
|
+
- `{guid}` or `-{guid}`
|
|
117
117
|
|
|
118
|
-
### tag and
|
|
118
|
+
### tag and not tag
|
|
119
119
|
|
|
120
120
|
Check for a tag.
|
|
121
121
|
|
|
122
|
-
- `<name>` or
|
|
122
|
+
- `<name>` or `-<name>`
|
|
123
123
|
|
|
124
|
-
### truthy and
|
|
124
|
+
### truthy and not truthy
|
|
125
125
|
|
|
126
126
|
Check for truthiness.
|
|
127
127
|
|
|
128
|
-
- `[name]` or
|
|
128
|
+
- `[name]` or `-[name]`
|
|
129
129
|
|
|
130
|
-
### ref and
|
|
130
|
+
### ref and not ref
|
|
131
131
|
|
|
132
132
|
Check for a reference to another entity.
|
|
133
133
|
|
|
134
|
-
- `name<{guid}>` or
|
|
134
|
+
- `name<{guid}>` or `-name<{guid}>`
|
|
135
135
|
|
|
136
|
-
### qref and
|
|
136
|
+
### qref and not qref
|
|
137
137
|
|
|
138
138
|
Check for a reference to another entity using a query.
|
|
139
139
|
|
|
140
|
-
- `name<{refclassname inner query}>` or
|
|
140
|
+
- `name<{refclassname inner query}>` or `-name<{refclassname inner query}>`
|
|
141
141
|
- (Escape curly brackets with a leading backslash.)
|
|
142
142
|
- (Requires a map of refclassname to their actual class and default fields.)
|
|
143
143
|
|
|
144
|
-
### contain and
|
|
144
|
+
### contain and not contain
|
|
145
145
|
|
|
146
146
|
Check if the array at the named property contains a value.
|
|
147
147
|
|
|
148
|
-
- `name<value>` or
|
|
148
|
+
- `name<value>` or `-name<value>`
|
|
149
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.)
|
|
150
|
-
- `name<JSON>` or
|
|
150
|
+
- `name<JSON>` or `-name<JSON>`
|
|
151
151
|
- (Search for a JSON encoded value (like `true`, `1`, `[1,2,3]`, or `{"prop":"val"}`).)
|
|
152
152
|
|
|
153
|
-
### search and
|
|
153
|
+
### search and not search
|
|
154
154
|
|
|
155
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.
|
|
156
156
|
|
|
157
|
-
- `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.)
|
|
158
160
|
|
|
159
|
-
### match and
|
|
161
|
+
### match and not match
|
|
160
162
|
|
|
161
163
|
Check for POSIX regex match.
|
|
162
164
|
|
|
163
|
-
- `name~/pattern/` or
|
|
165
|
+
- `name~/pattern/` or `-name~/pattern/`
|
|
164
166
|
|
|
165
|
-
### imatch and
|
|
167
|
+
### imatch and not imatch
|
|
166
168
|
|
|
167
169
|
Check for case insensitive POSIX regex match.
|
|
168
170
|
|
|
169
|
-
- `name~/pattern/i` or
|
|
171
|
+
- `name~/pattern/i` or `-name~/pattern/i`
|
|
170
172
|
|
|
171
|
-
### like and
|
|
173
|
+
### like and not like
|
|
172
174
|
|
|
173
175
|
Check for pattern match where \_ is single char wildcard and % is any length wildcard.
|
|
174
176
|
|
|
175
|
-
- `name~pattern` or
|
|
176
|
-
- `name~"pattern"` or
|
|
177
|
+
- `name~pattern` or `-name~pattern`
|
|
178
|
+
- `name~"pattern"` or `-name~"pattern"`
|
|
177
179
|
- (Use this if you have a space in your pattern.)
|
|
178
180
|
|
|
179
|
-
### ilike and
|
|
181
|
+
### ilike and not ilike
|
|
180
182
|
|
|
181
183
|
Check for case insensitive pattern match where \_ is single char wildcard and % is any length wildcard.
|
|
182
184
|
|
|
183
|
-
- `name~"pattern"i` or
|
|
185
|
+
- `name~"pattern"i` or `-name~"pattern"i`
|
|
184
186
|
|
|
185
|
-
### gt
|
|
187
|
+
### gt and not gt
|
|
186
188
|
|
|
187
189
|
Check a prop's value is greater than a given value.
|
|
188
190
|
|
|
189
|
-
- `name>number`
|
|
190
|
-
- `name>relative`
|
|
191
|
+
- `name>number` or `-name>number`
|
|
192
|
+
- `name>relative` or `-name>relative`
|
|
191
193
|
- (A single relative time value like `now` or `yesterday`.)
|
|
192
|
-
- `name>"relative time value"`
|
|
194
|
+
- `name>"relative time value"` or `-name>"relative time value"`
|
|
193
195
|
- (Use this for a time value with a space like `"two days from now"`, `"last thursday"`, `"+4 weeks"`, or `"5 minutes ago"`.)
|
|
194
196
|
|
|
195
|
-
### gte
|
|
197
|
+
### gte and not gte
|
|
196
198
|
|
|
197
199
|
Check a prop's value is greater than or equal to a given value.
|
|
198
200
|
|
|
199
|
-
- `name>=number`
|
|
200
|
-
- `name>=relative`
|
|
201
|
+
- `name>=number` or `-name>=number`
|
|
202
|
+
- `name>=relative` or `-name>=relative`
|
|
201
203
|
- (A single relative time value like `now` or `yesterday`.)
|
|
202
|
-
- `name>="relative time value"`
|
|
204
|
+
- `name>="relative time value"` or `-name>="relative time value"`
|
|
203
205
|
- (Use this for a time value with a space like `"two days from now"`, `"last thursday"`, `"+4 weeks"`, or `"5 minutes ago"`.)
|
|
204
206
|
|
|
205
|
-
### lt
|
|
207
|
+
### lt and not lt
|
|
206
208
|
|
|
207
209
|
Check a prop's value is less than a given value.
|
|
208
210
|
|
|
209
|
-
- `name<number`
|
|
210
|
-
- `name<relative`
|
|
211
|
+
- `name<number` or `-name<number`
|
|
212
|
+
- `name<relative` or `-name<relative`
|
|
211
213
|
- (A single relative time value like `now` or `yesterday`.)
|
|
212
|
-
- `name<"relative time value"`
|
|
214
|
+
- `name<"relative time value"` or `-name<"relative time value"`
|
|
213
215
|
- (Use this for a time value with a space like `"two days from now"`, `"last thursday"`, `"+4 weeks"`, or `"5 minutes ago"`.)
|
|
214
216
|
|
|
215
|
-
### lte
|
|
217
|
+
### lte and not lte
|
|
216
218
|
|
|
217
219
|
Check a prop's value is less than or equal to a given value.
|
|
218
220
|
|
|
219
|
-
- `name<=number`
|
|
220
|
-
- `name<=relative`
|
|
221
|
+
- `name<=number` or `-name<=number`
|
|
222
|
+
- `name<=relative` or `-name<=relative`
|
|
221
223
|
- (A single relative time value like `now` or `yesterday`.)
|
|
222
|
-
- `name<="relative time value"`
|
|
224
|
+
- `name<="relative time value"` or `-name<="relative time value"`
|
|
223
225
|
- (Use this for a time value with a space like `"two days from now"`, `"last thursday"`, `"+4 weeks"`, or `"5 minutes ago"`.)
|
|
224
226
|
|
|
225
227
|
## Selectors
|