Skip to content

v0.7.0

Choose a tag to compare

@github-actions github-actions released this 23 Nov 12:55
· 12 commits to main since this release
447a23a

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 is unknown, so isDefinedError(error) narrows it only to RouteError, and isDefinedError(error, client.posts.create) now types its code and data for 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 that extractContract() wrote to JSON as the route tree it was extracted from, so it no longer needs an as unknown as cast. It throws a TypeError when the value doesn't have the shape of an extracted contract. (c04340d)

core:

  • Remove the timeoutMs client 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 fetch as its second argument when the client's fetchOptions or the call set any, the way the global fetch takes them. Options a Request doesn't keep, such as ones a runtime or framework adds to fetch, now reach it instead of being dropped. A custom fetch receives them too, and FetchLike takes them as an optional second parameter. Calls without fetch options still call fetch(request). (c04340d)

core, server:

  • accept and authorization header parameters are left out like content-type, since OpenAPI ignores them. Use security for credentials.

core, server:

  • createOpenApiDocument() needs no options. info.title defaults to "API" and info.version to "0.0.0". info, servers, tags and externalDocs accept any other fields of their OpenAPI objects, such as contact or license in info, and copy them to the document as they are. The document's other top-level fields, security, externalDocs and x- extensions, are now copied to the document like servers, components and tags. (c04340d)

core, server:

  • A parameter's or response header's description and deprecated are set on the parameter or header itself, and response headers are marked required when 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 path of 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, so route.path no longer needs an undefined check. (c04340d)

core, server, tanstack-query:

  • Add a default condition next to import in each package's exports, so resolvers that don't use the import condition, such as some bundler plugins, find the entry points. (c04340d)

server:

  • implement() rejects a contract tree whose top-level keys include use or $context with 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 as never. Its handler() 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-type set with respond(), or a header such as cache-control added 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 as queryClient.invalidateQueries({ queryKey: queryUtils.posts.key() }). key is reserved, so a client tree with a route or group named key is a type error.

tanstack-query:

  • prefix starts 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 in globalHeaders, can be added to the keys with createTanstackQueryUtils(client, { prefix: ["locale", locale] }).

tanstack-query:

  • queryOptions() and infiniteQueryOptions() with a request are accepted by useSuspenseQuery() and useSuspenseInfiniteQuery(). Their queryFn was typed as possibly skipToken, which the suspense hooks reject. Options with a skipToken request keep that type, so the suspense hooks still reject them. (c04340d)

tanstack-query:

  • Add a prefix option to createTanstackQueryUtils() and a key() util on every node of the util tree. (c04340d)