Repository navigation
feat(bruno-js): add jsdoc annotations to Script APIs - #9725
Conversation
* feat: setup typedoc and ts compilation for js files * feat: add jsdoc annotations for js classes * feat: add typescript to bruno-js dependency and add additional comments for js * feat: generate script.d.ts * fix: add docs cleanup, lint checks on CI and unit test for checking parity between docs and script API * fix: add custom header to render theme switcher and sidebar padding * fix: reorganise return types to new category * feat: remove typedoc related changes * fix: remove unused package installs * fix: fix claude code review comments * feat: add script-api.d.ts to bruno-js files list
Findings
|
| Layer / File(s) | Summary |
|---|---|
Globals and HTTP scripting API packages/bruno-js/types/globals.d.ts, packages/bruno-js/src/bru.js, packages/bruno-js/src/bruno-request.js, packages/bruno-js/src/bruno-response.js |
Global declarations and JSDoc describe the bru, HTTP request, and HTTP response APIs, including types, contexts, and internal members. |
Cookie, header, and property lists packages/bruno-js/src/cookie-list.js, packages/bruno-js/src/header-list.js, packages/bruno-js/src/property-list.js, packages/bruno-js/src/readonly-property-list.js |
JSDoc and typedefs document list APIs, matching rules, method returns, and internal or protected members. |
gRPC scripting API packages/bruno-js/src/grpc/* |
JSDoc and typedefs describe gRPC request and response properties, message lists, metadata operations, and hook contexts. |
Declaration and manifest generation packages/bruno-js/scripts/generate-script-api.js |
The generator validates source documentation and types, emits declarations, builds a context- and runtime-aware manifest, and supports check and write modes. |
Generated declarations and runtime parity packages/bruno-js/types/script-api.d.ts, packages/bruno-js/types/globals.d.ts, packages/bruno-js/tsconfig.script-api.json, packages/bruno-js/tests/script-api-parity.spec.js, packages/bruno-js/package.json |
The committed declarations cover the scripting API. Tests compare documented members with members available in seven runtime contexts. The TypeScript configuration and package metadata support generation and publication. |
Generation workflow and contributor guidance package.json, packages/bruno-js/package.json, .github/workflows/lint-checks.yml, packages/bruno-js/readme.md, .claude/rules/feature-parity.md |
Package scripts and lint checks expose declaration generation and verification. The README and feature-parity rule document JSDoc and generated declaration requirements. |
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Other
Possibly related PRs
- usebruno/bruno#9596: Adds the Script API JSDoc generator, generated declarations, parity tests, and package scripts in the same implementation areas.
Suggested reviewers: bijin-bruno, helloanoop, sanish-bruno
Merge Risk: 
Low · up to 73ba6
-
This change documents the scripting API and generates a TypeScript reference. It does not alter runtime behavior. Two documentation and type inaccuracies should be fixed before the generated reference is published: the header toObject precedence note, and the sendRequest return type in callback mode. Neither blocks merge.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 16 files. (6 skipped: 6 unsupported.)
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Typed globals step into view
JSDoc names each path and cue
Declarations bloom from source
Parity checks confirm their course
Seven contexts join the song
One generated reference grows strong
JIRA - 4772
Description
This PR adds JSDoc annotations to Script API classes which is then used a source of truth for an API reference.
Problem
The script API (bru, req, res, test, expect, assert and the gRPC hooks) has no single, reliable reference. Some members only work in Developer Mode, and nothing tells users this until a script fails in Safe Mode. Docs written separately from the code drift out of date. Nothing checks that what’s documented matches what scripts can actually reach.
Fix
Adding JSdoc annotations to the script classes makes sure the reference doesnt drift away from the implementation. Adding custom tags like runtime and context helps defining what surfaces are available in different sandbox modes and script runtimes respectively.
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit