feat(group): make HTTP consumer client identifiers configurable#1942
Open
easonliu8899 wants to merge 1 commit into
Open
feat(group): make HTTP consumer client identifiers configurable#1942easonliu8899 wants to merge 1 commit into
easonliu8899 wants to merge 1 commit into
Conversation
The Node HTTP plugin hard-coded the consumer client identifier to `axios` (`(#eq? @obj "axios")`), so member-style calls made through a wrapped HTTP client — e.g. uni-app / luch-request style `import request from "@/utils/request"; request.get("/x")` — produced zero consumer contracts and therefore zero cross-links, even though the URLs are plain string literals. Add a `detect.http_client_aliases` option to group.yaml. The `<client>.<verb>(url)` query now captures the object identifier instead of pinning it to "axios", and the plugin filters it against a config-driven client-identifier set (default {"axios"}) threaded from group.yaml -> HttpRouteExtractor -> each Node plugin's prepareRepo. Backward compatible: default `[]` recognizes only axios, identical to prior behavior. Object-form (`axios({url})`), fetch and jQuery detection are untouched. Tests: wrapped `request.get` is not detected without aliases and is detected (GET + DELETE) when opted in; config-parser default/parse/ validation for the new field. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@claude is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
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
Adds a
detect.http_client_aliasesoption togroup.yamlso the JS/TS HTTPconsumer extractor recognizes member-style calls (
client.get(url),client.post(url), …) made through a wrapped HTTP client, not just thebuilt-in
axios.With the example above, calls like
request.get('/api/users')andhttp.post('/orders')are extracted as HTTP consumer contracts and cancross-link to provider endpoints during
group sync.Why
Many front-ends wrap their HTTP client behind a small helper instead of
calling
axios/fetchdirectly — e.g. uni-app /luch-requestprojects do:The Node HTTP plugin hard-coded the consumer client identifier to
axios(
(#eq? @obj "axios")), so these wrapped calls produced zero consumercontracts and therefore zero cross-links, even though the URLs are plain
string literals that are trivially extractable. This affects any codebase
that renames or wraps its HTTP client.
How it works
axios.<verb>(url)tree-sitter query no longer pins@objto"axios"; it captures the object identifier and the plugin filters itagainst a configurable client-identifier set in
scanBundle.{"axios"}(built-in), and is widened by the aliasesthreaded from
group.yaml→HttpRouteExtractor→ each Node plugin'sprepareRepo→scan. No tree-sitter query is recompiled per config.frameworkon each detection is now the matched identifier (axiosstaysaxios; a wrappedrequestreportsrequest).Backward compatibility
http_client_aliases: []⇒ onlyaxiosis recognized — identicalbehavior to before. The existing axios/fetch/jQuery consumer tests pass
unchanged.
axios({ url })) andfetch/jQuery detection are untouched.detectkey defaults to[], so existing groups are unaffected on thenext sync.
How to verify
New tests:
http-route-extractor.test.ts: a wrappedrequest.get()is not detectedwithout aliases (no false positives), and is detected (GET + DELETE) when
new HttpRouteExtractor(['request'])is configured.config-parser.test.ts: default[], explicit list parsing, and validationerrors for non-array / non-string entries.
Real-world validation
Validated on a real 2-repo group (a uni-app /
luch-requestfrontend thatwraps its client as
request+ a Spring backend). Withdetect.http_client_aliases: [request],group synccross-links went from0 → 135 (exact, confidence 1.0). Spot-checked links are correct round
trips, e.g.
POST /wx/loginmatches the frontendrequest.post("wx/login")to the backend
@PostMapping("/login")under a/wxclass mapping. Withoutthe alias the same group produces 0 cross-links.
Risk / rollback
ident.verb(stringLiteral)consumer calls.String-concatenation URLs and
uni.request({ url })object-form calls arestill out of scope (documented limitation, not a regression).
format change.
Out of scope (possible follow-ups)
@RequestMapping(value = "...")named-argument extraction(separate precision improvement, unrelated to this consumer-side change).
client({ url })) and fornon-Node language plugins.
api_impact/route_mapresolve a single repo's graphRoutenodes, whichfor Spring/Java back-ends are not always populated from
@RequestMapping/@GetMappinghandlers — so an exact lookup likeapi_impact route="/wx/login"can return "no routes" even though the route exists as a provider contract and
cross-links correctly in
group sync. Cross-repo consumers remain reachablevia
query repo:"@group"and the group contracts resource; populating graphRoutenodes from Spring handlers would letapi_impactcover Java back-ends.