Repository navigation
Release 0.1.0-rc.3 - #7
Merged
Merged
Conversation
monarcode
commented
Nov 16, 2026
Owner
- feat: add Fetch.Service to declare a client as a service class
- feat: add Fetch.Endpoints and client.bindAll to share a module's endpoints as a service
- feat(plugins): add token refresh to bearer, plus retryAfter and budget to retry
- feat: add a decoded-and-response mode and text and bytes outputs
- feat: add endpoint query schemas, endpoint.url, catchStatus and optional
- feat: add @monarcode/effetch/test with FetchTest, a typed fake backend from endpoints
- feat: add SSE and NDJSON streams and Fetch.paginate
- fix!: tighten the rc.3 APIs and add a streams example
- docs: rewrite the README around Fetch.Service
- fix: type inline endpoint definitions in pairs, and port examples to Fetch.Service
- Add Service, ServiceClass and isService; the class carries a static layer and a frozen config - Use Fetch.Service in the README, the examples, the smoke test and the editor check - Bump version to 0.1.0-rc.3 and add the changelog entry
…oints as a service
…t to retry
- bearer({ refresh }) gets a new token on a 401 and sends the request again
once; requests refused with the same token share one refresh
- retry({ retryAfter }) waits as long as a response's Retry-After header asks;
retry({ budget }) caps the whole call and fails with TimeoutError when it runs
out
- Add the RefreshSource, RetryBudgetPlugin and RetryBudgetOptions types, with
docs and tests
- responseMode: "decoded-and-response" makes a call succeed with [decoded, response], on calls, endpoints and definitions; ResponseMode adds a defaulted type parameter to the call and endpoint types - Fetch.text() and Fetch.bytes() read a 2xx body as text or a Uint8Array; Fetch.text(schema) trims the text and decodes one value - consoleLogger and onExit handle the pair; add TextSchema and BytesSchema with tests and docs
- A query schema on an endpoint types each call's query and encodes it before it's sent; adds QuerySchema and EndpointQuery, and a defaulted type parameter on the endpoint and call types - endpoint.url(options) builds the URL a call would use, for links and cache keys - Fetch.catchStatus handles HttpErrors with the given statuses, and Fetch.optional turns a 404 into Option.none()
- api.sse and api.ndjson read a streamed body as a Stream, decoding each event or line with output; calls go through plugins, retry and status errors as usual - stream: "sse" | "ndjson" on an endpoint definition makes its calls return a Stream; FetchTest.respond can answer them with a list of events - Fetch.paginate pages through a bound endpoint as a lazy Stream of pages
- client.bind's response mode and query schema type parameters lose their defaults, so a definition written inline keeps its literal types; stream endpoint definitions reject responseMode and Fetch.bytes() - FetchTest decodes a single query value for a field that takes a list or a value, and matches the root route only for "/"; retry gets a no-budget overload - Add examples/streams.ts and its test, and reorganise the 0.1.0-rc.3 changelog
Make Fetch.Service the recommended way to set up a client, with a section on when to use Fetch.make instead. Lead endpoints with Fetch.endpoint and Fetch.Endpoints, add "Providing the client", list statusErrors in the config table, fold edge cases into Details blocks, and add badges for bundle size, types, provenance, license and the supported runtimes.1
Fetch.Service An inline Fetch.endpoint(...) inside a [definition, options] pair, in Fetch.Endpoints or client.bindAll, took its unset stream and response mode from the surrounding type and was typed as a stream endpoint. The return types of Fetch.endpoint and client.endpoint are now NoInfer. Port examples/endpoints.ts, status-errors.ts and backends.ts, and the JSDoc examples, to Fetch.Service and Fetch.Endpoints. Call the package Effetch in prose, including the log message for a failed plugin hook.
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.