feat: relative queries, per-node query buttons, static-view cleanup - #39
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Querying-nested-data improvements, plus a static-view cleanup:
|resolves against the piped subtree, not the document root.ƒ 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).null. Now it chains onto the active query with a pipe.How it works
Relative queries —
splitPipes(top-level pipe segments, ignoring||/quotes/brackets) +suggestAtScoped(resolves after a pipe against the left side's value;suggestAtunchanged) +createScopeResolver(memoized left-side eval, injected soquery-suggeststays jmespath-free). Placeholder advertises the pipe.Inline buttons —
projectLastIndex(replace last[n]with[*]; quoted keys untouched) +viewer.tsadds the two buttons (ƒ allhidden unless the path has an index) + delegation incontent.ts.Query-then-query fix —
composeNodeQuery(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 views —
updateViewControls()togglesdisabledon the depth select / search / query toggles per view;openQueryPanel/openSearchPaneland 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, thenchrome://extensions→ Developer mode → Load unpackeddist/(ornpm run dev).Test pages
A. Inline buttons (hover any row)
/users, hover a user'scompany→ƒ query→ renders[0].company. →ƒ all→[*].company, all 10 companies.ƒ allis hidden on nodes not inside an array.B. Query-then-query (the reported bug)
ƒ queryonstory→content. The result tree shows the content object.ƒ queryon a child (e.g.featured_story). It should render the correct value (chip showsstory.content | featured_story), NOTnull.C. Relative queries (press
Q)[0] |+ a letter → suggests the first user's keys.[0].address |+ letter →street/city/zipcode/geo.[0].company | keys(@)→["name","catchPhrase","bs"]. Chained:[0] | address | geo→{lat,lng}.[*]:[].company.D. Static views
⌕search, andƒquery toggle are disabled (dimmed).⌘FandQdo nothing there.E. No regressions
[*].name(no pipe) works as before.[0].id || [0].namedoesn'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 typecheckandnpm run buildclean.