Repository navigation
feat(cli): gh-style api fields, --paginate/--slurp, --jq and --template - #21
Conversation
|
Warning Review limit reached
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 19 minutes. View limit detailsLimit details: You’ve used the included review currently available. Your 89 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. The included review limit has been reached and this organization has disabled usage-based review continuation. Wait for reviews to reset or ask a billing admin to change After included review limits. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (11)
Comment |
|
@coderabbitai review |
|
|
@coderabbitai review |
|
|
Reviewed locally because CodeRabbit is rate-limited (it answered Fixed:
Tests added for all four. Left unfixed: the action lexer finds |
|
Tip For best results, initiate chat on the files or code changes.
The four fixes address incorrect behavior and error reporting in the new CLI features. The remaining ✏️ Learnings added
You are interacting with an AI system. |
-f/--raw-field and typed -F/--field with nesting, arrays and @file, --paginate with --slurp and --max-pages, embedded jq via jq-wasm, and a Go-style --template.
Reject prototype keys and object overwrites in fields, stop on any repeated cursor, and drop a dead stdin guard.
…okups
- jq-wasm parses a string argument as JSON text, so a JSON string body
failed with a parse error blamed on the user's filter. Serialize first.
- nextCursor never fell back to the top level once a page envelope was
present, silently stopping after one page.
- Template function lookup resolved inherited names such as toString and
constructor; restrict it to own properties.
- {{else if .cond}} dropped the condition and rendered unconditionally;
reject it with a clear message instead.
6efadc9 to
b1c7f30
Compare
|
@coderabbitai review |
|
…ile reads --quiet disabled per-page streaming, so a paginated --jq filter ran once over an array of page bodies instead of each body, changing the exit code for filters like .data[].id. Only --json aggregates now. Also stat field files before reading, so the 10 MiB limit rejects rather than buffers.
|
Rebased onto Two further fixes:
Left unfixed: nothing outstanding from this round. From the earlier round, the action lexer still finds |
--paginate only rejected a cursor passed via query fields, so a cursor already in the endpoint path produced a duplicate parameter. A response claiming more pages with no cursor also ended pagination successfully, hiding an incomplete result; it now fails with a clear message. Name the field flags accurately in the conflicting-body error.
|
A second local pass turned up three more issues, now fixed:
Tests added for the first two. Deliberately left unfixed:
None of these produce silently wrong data; they are documented-behaviour or loud-failure cases better handled as follow-ups than folded into this PR. |
Summary
Brings
polymorfa apicloser togh api:-f/--raw-field(always string) and typed-F/--field(true/false/null/integers become JSON;@fileand@-read file/stdin). Both supportname[key]=vnesting andname[]=vappends. GET/HEAD query parameters accept scalars andname[]arrays; nested objects are rejected. Short aliases-X,-H,-i.--paginate(GET only) followspage.nextCursor(or top-levelnextCursor) as thecursorquery parameter, stops onhasMore: false/null cursor, rejects a repeated cursor, and caps at--max-pages(default 100).--jsonprints one document{data: [pageBodies], metadata: {..., pages}}; human output streams each page.--slurpcombines page bodies into one array before filters.-q/--jquses the embedded WebAssembly jq 1.8 (jq-wasm@3.0.0-jq-1.8.2, MIT, no dependencies, no native binary). Strings print raw likegh. jq's$ENVis the WASM sandbox env, so host credentials are not exposed (verified).-t/--template: Go-template subset (paths,range/if/else/end,$,json,len,upper,lower,join, string literals, comments,{{-/-}}trimming).Behavior change:
--fieldwas string-only; it is now typed likegh api -F.-f/--raw-fieldkeeps the old string behavior. README documents this.No overlap with open PRs #10–#16 (none touch
src/commands/api.tsorsrc/api/).Five-part assessment
cursorquery parameter andpage.nextCursor/hasMoreenvelope (CursorPageMetadatain the management spec).RawClient.requestthrough the existingexecuteRawRequest.jq-wasm, pinned exactly;npm audit --omit=devclean).Verification
npm run verifypasses.test/api/fields.test.ts,test/api/template.test.ts(unit),test/commands/api-gh.test.ts(typed body, GET query, multi-page cursor following, per-page jq, slurp jq, template, jq error exit code 2,--slurp/--paginatemisuse,--max-pagesstop). Existingtest/commands/api.test.tsunchanged and passing.dist/api/jq.jsloads the WASM module outside vitest.Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.