Skip to content

v0.77.0

Choose a tag to compare

@joshmossas joshmossas released this 25 Mar 20:51
· 86 commits to master since this release

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 v1 or v2 and then publish a ClientV1 and ClientV2
  • internal vs public clients: prefix private procedures with admin and public procedures with public

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 rootService option

Go

  • [go-server] fix cors issues when connecting from browsers
  • [go-server] event stream procedures now emit a start event upon successful connection
  • [go-server] BREAKING: all app hooks (onRequest, onBeforeResponse, onAfterResponse, and onError) no longer receive a pointer to *http.Request as their first parameter. Instead this can be accessed from the RpcEvent like so event.Request()

Kotlin

  • [kotlin-codegen] add support for the rootService option
  • [kotlin-codegen] tests are now run using the following dependency versions
    • kotlinx-seralization-json v1.8.0
    • ktor v3.1.1

Rust

  • [rust-codegen] add support for the rootService option

Typescript

  • [ts-codegen] add support for the rootService option
  • [ts-server] event stream procedures now emit a start event 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-imports lint rule for users that want to enforce keeping as small a bundle size as possible

Swift

  • [swift-codegen] add support for the rootService option
  • [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 message event

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 rootService in code generators [ts, rust, dart, kotlin, swift] by @joshmossas in #159
  • [ts-schema] feat: document modular/tree-shakable imports + add arri/prefer-modular-imports eslint rule to @arrirpc/eslint-plugin by @joshmossas in #160

Full Changelog: v0.76.4...v0.77.0