(
authorFactory: (
options?: TOptions,
) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
)
| 696 | |
| 697 | // eslint-disable-next-line @typescript-eslint/ban-types |
| 698 | export function definePlugin< |
| 699 | TId extends string, |
| 700 | TExtension extends object, |
| 701 | TStore, |
| 702 | TOptions extends object = {}, |
| 703 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 704 | TExtensionService extends Context.Service<any, any> | undefined = undefined, |
| 705 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 706 | THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>, |
| 707 | TGroup extends HttpApiGroup.Any = HttpApiGroup.Any, |
| 708 | >( |
| 709 | authorFactory: ( |
| 710 | options?: TOptions, |
| 711 | ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>, |
| 712 | ): ConfiguredPlugin<TId, TExtension, TStore, TOptions, TExtensionService, THandlersLayer, TGroup> { |
| 713 | return (options) => { |
| 714 | const { |
| 715 | storage: storageOverride, |
| 716 | ...rest |
| 717 | }: { |
| 718 | storage?: (deps: StorageDeps) => TStore; |
| 719 | [key: string]: unknown; |
| 720 | } = options ?? {}; |
| 721 | |
| 722 | const hasAuthorOptions = Object.keys(rest).length > 0; |
| 723 | const spec = authorFactory(hasAuthorOptions ? (rest as TOptions) : undefined); |
| 724 | |
| 725 | return { |
| 726 | ...spec, |
| 727 | storage: storageOverride ?? spec.storage, |
| 728 | }; |
| 729 | }; |
| 730 | } |
| 731 | |
| 732 | // --------------------------------------------------------------------------- |
| 733 | // AnyPlugin / PluginExtensions — type-level glue for the Executor surface. |
no outgoing calls