v0.77.0
What's Changed
Feature Release: Root Services
This release adds the ability to define a root service when generating clients. This makes it easier to publish more narrowly scoped RPC client from the same app. For example consider a service with the following procedures:
- users.getUser
- users.updateUser
- posts.createPost
- posts.updatePost
- posts.deletePost
Setting the rootService to users would generate a client that only has the following procedures: [getUser, updateUser]. While setting the rootService to posts would generate a client that only has [createPost, updatePost, deletePost].
Some potential use cases:
- versioned clients: prefix all procedures with a version such as
v1orv2and then publish aClientV1andClientV2 - internal vs public clients: prefix private procedures with
adminand public procedures withpublic
How to specify a root service
import { defineConfig, generators } from 'arri';
export default defineConfig({
generators: [
generators.typescriptClient({
clientName: 'ClientV1',
rootService: 'v1', // only include procedures from the `v1` service
outputFile: '<some-output-path>',
}),
generators.typescriptClient({
clientName: 'ClientV2',
rootService: 'v2', // only include procedures from the `v2` service
outputFile: '<some-output-path>',
}),
],
})Dart
- [dart-codegen] add support for the
rootServiceoption
Go
- [go-server] fix cors issues when connecting from browsers
- [go-server] event stream procedures now emit a
startevent upon successful connection - [go-server] BREAKING: all app hooks (
onRequest,onBeforeResponse,onAfterResponse, andonError) no longer receive a pointer to*http.Requestas their first parameter. Instead this can be accessed from theRpcEventlike soevent.Request()
Kotlin
- [kotlin-codegen] add support for the
rootServiceoption - [kotlin-codegen] tests are now run using the following dependency versions
- kotlinx-seralization-json
v1.8.0 - ktor
v3.1.1
- kotlinx-seralization-json
Rust
- [rust-codegen] add support for the
rootServiceoption
Typescript
- [ts-codegen] add support for the
rootServiceoption - [ts-server] event stream procedures now emit a
startevent upon successful connection - [ts-schema] document how to use modular imports to reduce bundle size
- [ts-schema] add benchmarks that measure difference in bundle size across competing libraries
- [eslint-plugin] add a
prefer-modular-importslint rule for users that want to enforce keeping as small a bundle size as possible
Swift
- [swift-codegen] add support for the
rootServiceoption - [swift-client] update async-http-client to
v1.25.2 - [swift-client] fix bug where unknown sse event types were falsely being emitted as a
messageevent
Merged PRs
- [ts-schema] chore: add benchmarks for arktype and typia by @joshmossas in #155
- [go-server] bugfix: fix cors issues + add initial msg for connection successful in SSE by @joshmossas in #156
- chore: update dependencies [ts, dart, kotlin, swift] by @joshmossas in #157
- feature: add ability to specify
rootServicein code generators [ts, rust, dart, kotlin, swift] by @joshmossas in #159 - [ts-schema] feat: document modular/tree-shakable imports + add
arri/prefer-modular-importseslint rule to@arrirpc/eslint-pluginby @joshmossas in #160
Full Changelog: v0.76.4...v0.77.0