Skip to content

feat: relative queries, per-node query buttons, static-view cleanup - #39

Merged
pedrosousa13 merged 8 commits into
mainfrom
feat/relative-queries
Jun 25, 2026
Merged

feat: relative queries, per-node query buttons, static-view cleanup#39
pedrosousa13 merged 8 commits into
mainfrom
feat/relative-queries

Conversation

@pedrosousa13

@pedrosousa13 pedrosousa13 commented Jun 25, 2026

Copy link
Copy Markdown
Owner

What

Querying-nested-data improvements, plus a static-view cleanup:

  1. Relative queries — JMESPath scoped to any node. The pipe already ran in jmespath; this makes autocomplete pipe-aware so the right side of | resolves against the piped subtree, not the document root.
  2. Inline per-node query buttons — every row gets ƒ query (query from here) and, for nodes inside an array, ƒ all (this field across all items — generalizes the nearest index to [*], so [0].company[*].company).
  3. Fix: query-then-query — a second "query from here" on a result tree previously ran a result-relative path against the original document → null. Now it chains onto the active query with a pipe.
  4. Static views cleanup — in formatted/raw/schema, the depth, search, and query controls (which only act on the tree/table) are disabled.

How it works

Relative queriessplitPipes (top-level pipe segments, ignoring ||/quotes/brackets) + suggestAtScoped (resolves after a pipe against the left side's value; suggestAt unchanged) + createScopeResolver (memoized left-side eval, injected so query-suggest stays jmespath-free). Placeholder advertises the pipe.

Inline buttonsprojectLastIndex (replace last [n] with [*]; quoted keys untouched) + viewer.ts adds the two buttons (ƒ all hidden unless the path has an index) + delegation in content.ts.

Query-then-query fixcomposeNodeQuery(activeExpression, nodePath): when a query is active, the node lives in the result tree, so its path is chained onto the active expression with a pipe (story.content | featured_story). Used by the inline buttons and the toolbar "Query from here".

Static viewsupdateViewControls() toggles disabled on the depth select / search / query toggles per view; openQueryPanel/openSearchPanel and the depth number-keys are guarded so the keyboard can't bypass the disable.

Query execution (runQuery) is unchanged. No new dependencies.

Manual testing

Build + load unpacked: npm run build, then chrome://extensions → Developer mode → Load unpacked dist/ (or npm run dev).

Test pages

A. Inline buttons (hover any row)

  1. On /users, hover a user's companyƒ query → renders [0].company. → ƒ all[*].company, all 10 companies.
  2. ƒ all is hidden on nodes not inside an array.

B. Query-then-query (the reported bug)

  1. On the Storyblok page, click ƒ query on storycontent. The result tree shows the content object.
  2. In that result, click ƒ query on a child (e.g. featured_story). It should render the correct value (chip shows story.content | featured_story), NOT null.

C. Relative queries (press Q)

  1. Placeholder shows the pipe example.
  2. [0] | + a letter → suggests the first user's keys. [0].address | + letter → street/city/zipcode/geo.
  3. [0].company | keys(@)["name","catchPhrase","bs"]. Chained: [0] | address | geo{lat,lng}.
  4. Terse "all" without [*]: [].company.

D. Static views

  1. Switch to Formatted / Raw / Schema → the depth selector, search, and ƒ query toggle are disabled (dimmed). ⌘F and Q do nothing there.
  2. Switch to Table → search + query re-enable; depth stays disabled. Tree → all re-enabled.

E. No regressions

  • [*].name (no pipe) works as before. [0].id || [0].name doesn't trigger pipe scoping. Toolbar "Query from here" still works.

Automated tests

npm test — 242 passing (24 new: splitPipes ×8, suggestAtScoped ×6, createScopeResolver ×4, projectLastIndex ×5, composeNodeQuery ×4, plus a static-views jsdom test). npm run typecheck and npm run build clean.

@pedrosousa13 pedrosousa13 changed the title feat: relative queries (query relative to any node via pipe) feat: relative queries + per-node query buttons Jun 25, 2026
@pedrosousa13 pedrosousa13 changed the title feat: relative queries + per-node query buttons feat: relative queries, per-node query buttons, static-view cleanup Jun 25, 2026
@pedrosousa13
pedrosousa13 merged commit d81bc09 into main Jun 25, 2026
2 checks passed
@pedrosousa13
pedrosousa13 deleted the feat/relative-queries branch June 25, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant