import type { Effect } from "effect/Effect"; import type { Capability } from "./capability.ts"; import type { IResource } from "./resource.ts"; import type { IRuntime, RuntimeHandler, RuntimeProps } from "./runtime.ts"; export interface IService< ID extends string = string, F extends IRuntime = IRuntime, Handler extends RuntimeHandler = RuntimeHandler, Props extends RuntimeProps = RuntimeProps, Attr = (F & { props: Props })["attr"], Base = unknown, > extends IResource { kind: "Service"; type: F["type"]; id: ID; runtime: F; /** * The raw handler function as passed in to the Runtime. * * @internal phantom type */ impl: Handler; /** * An Effect that produces a handler stripped of its Infrastructure-time-only Capabilities. */ handler: Effect< ( ...inputs: Parameters ) => Effect< Effect.Success>, Effect.Error>, never >, never, Exclude>, Capability> >; props: Props; /** @internal phantom type of this resource's output attributes */ attr: Attr; /** @internal phantom type of this resource's parent */ parent: unknown; new (): Service; } export interface AnyService extends IService {} export interface Service< ID extends string = string, F extends IRuntime = IRuntime, Handler extends RuntimeHandler = RuntimeHandler, Props extends RuntimeProps = RuntimeProps, Attr = (F & { props: Props })["attr"], Base = unknown, > extends IService {} export const isService = (resource: any): resource is IService => { return resource && resource.kind === "Service"; };