ServeImplOf<S, R>The implementation serve expects — the tag's wire members, whose handlers may share a run-time
requirement R. R is inferred from the impl (via ServeRequirements, the union of every
handler's requirement) and preserved on the returned layer, so it's discharged per resource by
Layer.provide, not shared ambiently.
export type type ServeImplOf<S extends Spec, R> = {
readonly [K in keyof S as S[K] extends AnyLocalMethod
? never
: K]: S[K] extends {
readonly _tag: "ref"
}
? Subscribable<SuccessOf<AsMethod<S[K]>>>
: S[K] extends {
readonly kind: MethodKind
}
? ServeMethod<AsMethod<S[K]>, R>
: S[K] extends Spec
? ServeImplOf<S[K], R>
: never
}
The implementation
serve
expects — the tag's wire members, whose handlers may share a run-time
requirement R. R is inferred from the impl (via
ServeRequirements
, the union of every
handler's requirement) and preserved on the returned layer, so it's discharged per resource by
Layer.provide, not shared ambiently.
ServeImplOf<function (type parameter) S in type ServeImplOf<S extends Spec, R>S extends Spec, function (type parameter) R in type ServeImplOf<S extends Spec, R>R> = {
readonly [function (type parameter) KK in keyof function (type parameter) S in type ServeImplOf<S extends Spec, R>S as function (type parameter) S in type ServeImplOf<S extends Spec, R>S[function (type parameter) KK] extends type AnyLocalMethod = LocalMethod<unknown>Any
LocalMethod
, erased.
AnyLocalMethod ? never : function (type parameter) KK]: function (type parameter) S in type ServeImplOf<S extends Spec, R>S[function (type parameter) KK] extends {
readonly _tag: "ref"_tag: "ref";
}
? interface Subscribable<A>A read-only reactive value: its current value (
Subscribable.get
, an Effect) plus a stream
of every change (
Subscribable.changes
). This is what a
ref
field surfaces — uniform local
and remote — and it's exactly the read side of a SubscriptionRef (Effect ships no Subscribable type in
this beta, so we name it here).
Subscribable<type SuccessOf<M extends AnyMethod> =
M["success"]["Type"]
SuccessOf<type AsMethod<T> = T extends {
readonly kind: MethodKind
readonly payload: infer P extends
| Schema.Struct.Fields
| Schema.Top
| undefined
readonly success: infer Su extends Schema.Top
readonly error: infer E extends Schema.Top
readonly stream: infer Str extends boolean
readonly annotations: infer Ann extends MethodAnnotations
}
? Method<P, Su, E, Str, Ann, Derive>
: never
Reconstruct a proper
Method
from a leaf's parts via infer — prop-presence + infer …
extends … is F-independent (reduces under a generic item schema) and keeps the payload precise,
unlike Extract/&. Lets the recursive spec types feed the existing ServiceMethod/ServeMethod/
RpcOf under a nested, generic Spec.
AsMethod<function (type parameter) S in type ServeImplOf<S extends Spec, R>S[function (type parameter) KK]>>>
: function (type parameter) S in type ServeImplOf<S extends Spec, R>S[function (type parameter) KK] extends { readonly kind: MethodKindkind: type MethodKind = "query" | "mutate"How a method behaves, for tools (CLI/TUI/dashboard) — explicit, never inferred;
encoded by the constructor used (
effect
vs
effectFn
):
query — an idempotent read (CLI prints it, dashboard reads it as an Atom);
mutate — a mutation (CLI confirms, dashboard calls it as runtime.fn).
MethodKind }
? type ServeMethod<
M extends AnyMethod,
R
> = M["stream"] extends true
? [M["payload"]] extends [undefined]
? Stream.Stream<SuccessOf<M>, ErrorOf<M>, R>
: (
payload: PayloadOf<M>
) => Stream.Stream<
SuccessOf<M>,
ErrorOf<M>,
R
>
: [M["payload"]] extends [undefined]
? Effect.Effect<SuccessOf<M>, ErrorOf<M>, R>
: (
payload: PayloadOf<M>
) => Effect.Effect<
SuccessOf<M>,
ErrorOf<M>,
R
>
ServeMethod<type AsMethod<T> = T extends {
readonly kind: MethodKind
readonly payload: infer P extends
| Schema.Struct.Fields
| Schema.Top
| undefined
readonly success: infer Su extends Schema.Top
readonly error: infer E extends Schema.Top
readonly stream: infer Str extends boolean
readonly annotations: infer Ann extends MethodAnnotations
}
? Method<P, Su, E, Str, Ann, Derive>
: never
Reconstruct a proper
Method
from a leaf's parts via infer — prop-presence + infer …
extends … is F-independent (reduces under a generic item schema) and keeps the payload precise,
unlike Extract/&. Lets the recursive spec types feed the existing ServiceMethod/ServeMethod/
RpcOf under a nested, generic Spec.
AsMethod<function (type parameter) S in type ServeImplOf<S extends Spec, R>S[function (type parameter) KK]>, function (type parameter) R in type ServeImplOf<S extends Spec, R>R>
: function (type parameter) S in type ServeImplOf<S extends Spec, R>S[function (type parameter) KK] extends Spec
? type ServeImplOf<S extends Spec, R> = {
readonly [K in keyof S as S[K] extends AnyLocalMethod
? never
: K]: S[K] extends {
readonly _tag: "ref"
}
? Subscribable<SuccessOf<AsMethod<S[K]>>>
: S[K] extends {
readonly kind: MethodKind
}
? ServeMethod<AsMethod<S[K]>, R>
: S[K] extends Spec
? ServeImplOf<S[K], R>
: never
}
The implementation
serve
expects — the tag's wire members, whose handlers may share a run-time
requirement R. R is inferred from the impl (via
ServeRequirements
, the union of every
handler's requirement) and preserved on the returned layer, so it's discharged per resource by
Layer.provide, not shared ambiently.
ServeImplOf<function (type parameter) S in type ServeImplOf<S extends Spec, R>S[function (type parameter) KK], function (type parameter) R in type ServeImplOf<S extends Spec, R>R>
: never;
};