@sanity-labs/groq-wasm 1.2.6 → 1.3.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 CHANGED
@@ -193,22 +193,29 @@ interface ParamReference {
193
193
 
194
194
  ## Lint Rules
195
195
 
196
- The following rules are available (from Rust groq-lint):
196
+ The following rules are available. They run on Rust groq-lint's IR. `join-in-filter`, `computed-value-in-filter`, `deep-pagination`, `deep-pagination-param`, `large-pages`, `non-literal-comparison`, `count-in-correlated-subquery` and `many-joins` are reimplemented in `rust/src/rules/` so their findings match the Content Lake query plan:
197
+
198
+ - Slices of one document's attribute array (`reviews[1500..1600]`) are not pagination.
199
+ - A correlated `count()` is only reported when its `^` condition is not `==` or `references()`, because those are batched into one index read.
200
+ - `dateTime("…")` is a literal, and `lower(^.name)` is a batch key.
201
+ - A join inside a filter over an attribute array in a projection is not reported. The suggested rewrite is `a._ref in *[b == "c"]._id`, which the index serves.
202
+ - Repeated joins on the same reference count once.
203
+ - `upper()`, `length()`, `round()`, `coalesce()`, `select()`, `string::split(...)[i]` and `defined(arr[i])` in a filter over documents are reported, because they are evaluated in memory.
197
204
 
198
205
  | Rule ID | Severity | Description |
199
206
  | ------------------------------ | -------- | ---------------------------------------------------- |
200
- | `join-in-filter` | error | Dereference (->) inside filter prevents optimization |
207
+ | `join-in-filter` | error | Dereference (->) inside a document filter |
201
208
  | `join-to-get-id` | warning | Using -> to get \_id (use .\_ref instead) |
202
- | `computed-value-in-filter` | error | Computed values in filter prevent optimization |
209
+ | `computed-value-in-filter` | error | Arithmetic or in-memory function in a dataset filter |
203
210
  | `match-on-id` | info | Using match on \_id with wildcard |
204
211
  | `order-on-expr` | error | Ordering on computed values |
205
- | `deep-pagination` | warning | Large offset in slice (>=1000) |
206
- | `large-pages` | warning | Fetching >100 results from index 0 |
212
+ | `deep-pagination` | warning | Document offset >= 1000 (`[1000...]`, `[5000]`) |
213
+ | `large-pages` | warning | Fetching >100 documents from index 0 |
207
214
  | `non-literal-comparison` | error | Comparing two non-literal expressions |
208
- | `count-in-correlated-subquery` | info | count() on correlated subqueries |
215
+ | `count-in-correlated-subquery` | info | count() on a subquery not batched on `^` |
209
216
  | `very-large-query` | error | Query exceeds 10KB |
210
217
  | `extremely-large-query` | error | Query exceeds 100KB |
211
- | `many-joins` | warning | Query has >10 dereference operators |
218
+ | `many-joins` | warning | Query has >10 distinct joins |
212
219
  | `unlimited-query` | warning | Top-level query without a slice or element limit |
213
220
 
214
221
  ## Error Handling
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity-labs/groq-wasm",
3
- "version": "1.2.6",
3
+ "version": "1.3.0",
4
4
  "description": "WASM bindings for GROQ linting and formatting (groq-lint + groq-format)",
5
5
  "keywords": [
6
6
  "sanity",
Binary file