Ok, as promised here's my solution. This doesn't handle the "all the services in an object" case but it does prevent the need for client code to import types from the server packages.
So the first thing is that yes, the types are kind of weird. The ServiceDefinition
type and its related types take both the name and parameters, but as you noted it just drops the parameters. The related version of ServiceDefinition returned by the client factory functions does hold on to the handler function info though, i'm guessing by using some infer
clauses in the client functions themselves.
It would be really convenient if the exposed types actually contained the relevant handler definitions as well, so that we can pass the types around more easily. But that said, here's what I'm doing right now.
I'm using a monorepo with a package named @repo/restate
which contains definitions of all the functions and also the factory functions for each service's client.
export interface TokenBucketLimiterFunct