Repository navigation
feat(javascript): add WithHTTPInfo methods - #6682
Merged
eric-zaharia merged 7 commits intoJul 13, 2026
Merged
Conversation
Refs: #5852, API-144
Contributor
✔️ Code generated!
📊 Benchmark resultsBenchmarks performed on the method using a mock server, the results might not reflect the real-world performance.
|
… WithHTTPInfo methods" This reverts commit 6b4691b.
… dropping requestOptions on x-timeouts operations
Fluf22
approved these changes
Jul 10, 2026
eric-zaharia
deleted the
port/added-withhttpinfo-methods-20260706/javascript
branch
July 13, 2026 07:39
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 and Why
🎟 JIRA Ticket: API-144
Mirrors #5852 for the JavaScript client: every generated operation gets a
{method}WithHTTPInfosibling that resolves with the full HTTP response — status code, headers (when the requester captures them), raw body and deserialized data — so callers can inspect HTTP metadata (status code, rate-limit headers, …) without writing a custom requester. Plain method signatures, return values and caching behavior are unchanged.Changes included:
AlgoliaHttpResponse<TData>type inclient-common({ status, headers?, content, data }), name aligned with the C#AlgoliaHttpResponsewrapper.transporter.requestWithHttpInfoverb next torequest/requestStream, sharing the same retry/failover path and throwing the exact sameApiError/DetailedApiErroron non-2xx. It bypasses both the requests and the responses caches, so the returned status and headers always reflect an actual API call — including forcacheableoperations likesearch. The verb is declared on a newTransporterWithHttpInfotype (Transporter & { requestWithHttpInfo }) returned bycreateTransporter; declaring it onTransporteritself would be a type-level breaking change for hand-written implementations and test mocks of that type, soTransporteris untouched and they all remain type-valid.headers?: Record<string, string>field on the requesterResponsetype, populated (lower-cased names) by all four requesters:requester-node-http,requester-fetch,requester-browser-xhrandrequester-testing. User-supplied custom requesters remain type-valid without changes; the wrapper'sheadersis simplyundefinedfor them. The echo requester echoes the request headers as responseheaders— consistent with its contract that everything it returns is the serialized request — so tests doing exact-equality assertions on full echoResponseobjects need to account for the new field.templates/javascript/clients/api-single.mustacheemits the{{nickname}}WithHTTPInfosibling per operation (same parameter handling, validation, legacy-signature support and timeouts as the plain method), following the existingStreamRaw/requestStreampattern. Each sibling gets its own JSDoc via a dedicatedjsdocWithHttpInfo.mustachepartial (mustache partials take no parameters, so the extra return/cache-bypass paragraph can't be injected into the sharedjsdocpartial): the operation description plus the full-HTTP-response return and cache-bypass behavior, keeping the ACL list,@deprecatedflags and param docs. Thealgoliasearchfat client and the lite client pick the methods up automatically. Suffix spellingWithHTTPInfomatches the Java/C#/Go/Swift clients.buildRequest.mustachepartial used by each method and itsWithHTTPInfosibling, so the two can't drift; generated output for the plain methods is unchanged. Validation and legacy-signature blocks stay per-method becausevalidateRequiredmust report the calling method's name.push,pushTask,validateSource,validateSourceBeforeUpdate,discoverSource), user-suppliedrequestOptionsother thantimeouts— extra headers, query parameters,cacheable— were silently discarded; they are now preserved and merged with the spec-default timeouts, matching the other language clients. The fix lands in the shared partial, covering both the plain methods and the new siblings.requestWithHttpInfobypasses the caches, so delegation would silently disable caching forcacheableoperations.Usage
Fully backwards compatible: additive methods and optional fields only.
🧪 Test
client-commonvitest suite forrequestWithHttpInfo: parity withrequeston success,undefineddata on 204/empty bodies, identicalApiError/DetailedApiErroron failures,headersleftundefinedfor requesters that don't capture them, and cache bypass forcacheablerequests.algoliasearchbundle test asserts the transporter exposes the new verb and smoke-testssearchWithHTTPInfoend to end against the echo requester.