import * as Context from "effect/Context"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; import type { Aspect } from "./Aspect.ts"; import type { ContextPlugin, ContextPluginService } from "./ContextPlugin.ts"; export type Plugins = { readonly context: Plugin, ContextPluginService>; }; export type Plugin = { effect: ( eff: Effect.Effect, ) => Layer.Layer; succeed: (service: Service) => Layer.Layer; }; export type ContextPlugins = C extends Aspect ? ContextPlugin : never; export const createPluginBuilder = < Tag extends Context.Service, Service, >( tag: Tag, ) => ({ effect: (eff: Effect.Effect) => Layer.effect(tag, eff), succeed: (service: Service) => Layer.succeed(tag, service), });