Repository navigation
v0.7.0
core:
isDefinedError()takes an optional second argument, a client route or tree or a route or route tree, and narrows the error to their defined errors. A caught error isunknown, soisDefinedError(error)narrows it only toRouteError, andisDefinedError(error, client.posts.create)now types itscodeanddatafor that route, or for every route of a tree. The argument is only read for its type. (c04340d)
core:
- Add
contractFromJson<typeof router>(json), which types a contract thatextractContract()wrote to JSON as the route tree it was extracted from, so it no longer needs anas unknown ascast. It throws aTypeErrorwhen the value doesn't have the shape of an extracted contract. (c04340d)
core:
- Remove the
timeoutMsclient option. A timeout is now an interceptor, which decides what the time covers, such as only the wait for the response or the body too: (f341bac)
core:
- The client passes fetch options to
fetchas its second argument when the client'sfetchOptionsor the call set any, the way the globalfetchtakes them. Options aRequestdoesn't keep, such as ones a runtime or framework adds tofetch, now reach it instead of being dropped. A customfetchreceives them too, andFetchLiketakes them as an optional second parameter. Calls without fetch options still callfetch(request). (c04340d)
core, server:
acceptandauthorizationheader parameters are left out likecontent-type, since OpenAPI ignores them. Usesecurityfor credentials.
core, server:
createOpenApiDocument()needs no options.info.titledefaults to"API"andinfo.versionto"0.0.0".info,servers,tagsandexternalDocsaccept any other fields of their OpenAPI objects, such ascontactorlicenseininfo, and copy them to the document as they are. The document's other top-level fields,security,externalDocsandx-extensions, are now copied to the document likeservers,componentsandtags. (c04340d)
core, server:
- A parameter's or response header's
descriptionanddeprecatedare set on the parameter or header itself, and response headers are markedrequiredwhen their schema requires them.
core, server:
- Every path segment is documented as a parameter, as a string when the params schema doesn't convert it, so documents without a schema converter stay valid.
core, server:
- Type the
pathof an intercepted route as always set. Client and server interceptors receive the path resolved from the route tree, also for routes that take their path from their key, soroute.pathno longer needs anundefinedcheck. (c04340d)
core, server, tanstack-query:
- Add a
defaultcondition next toimportin each package'sexports, so resolvers that don't use theimportcondition, such as some bundler plugins, find the entry points. (c04340d)
server:
implement()rejects a contract tree whose top-level keys includeuseor$contextwith a type error. The implementer's methods use those names, so such a route or group used to be replaced by the method. (c04340d)
server:
implement()requires a contract route to define its responses. A contract route without.response()has no handler to infer its response from, so its handler used to accept any value and the client typed the call asnever. Itshandler()is now a type error that says to add.response(), which can be a response without a body, such as.response({ status: 204 }). (c04340d)
server:
- A defined response or error without a headers schema sends the headers the handler and middleware set. They used to be dropped, so a
content-typeset withrespond(), or a header such ascache-controladded by middleware, was not sent on routes that define their responses. With a headers schema, its output is still what's sent, so a schema that strips unknown keys sends only the headers it declares. (c04340d)
tanstack-query:
key()returns the key that matches every query of the utils, of a group or of a route, prefix included, such asqueryClient.invalidateQueries({ queryKey: queryUtils.posts.key() }).keyis reserved, so a client tree with a route or group namedkeyis a type error.
tanstack-query:
prefixstarts every query and mutation key of the utils. Query keys hold the route and its request, so a value the client sends with every request that changes the response, such as a locale inglobalHeaders, can be added to the keys withcreateTanstackQueryUtils(client, { prefix: ["locale", locale] }).
tanstack-query:
queryOptions()andinfiniteQueryOptions()with a request are accepted byuseSuspenseQuery()anduseSuspenseInfiniteQuery(). TheirqueryFnwas typed as possiblyskipToken, which the suspense hooks reject. Options with askipTokenrequest keep that type, so the suspense hooks still reject them. (c04340d)
tanstack-query:
- Add a
prefixoption tocreateTanstackQueryUtils()and akey()util on every node of the util tree. (c04340d)