(
authorFactory: (
options?: TOptions,
) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
)
| 799 | |
| 800 | // eslint-disable-next-line @typescript-eslint/ban-types |
| 801 | export function definePlugin< |
| 802 | TId extends string, |
| 803 | TExtension extends object, |
| 804 | TStore, |
| 805 | TOptions extends object = {}, |
| 806 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 807 | TExtensionService extends Context.Service<any, any> | undefined = undefined, |
| 808 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 809 | THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>, |
| 810 | TGroup extends HttpApiGroup.Any = HttpApiGroup.Any, |
| 811 | >( |
| 812 | authorFactory: ( |
| 813 | options?: TOptions, |
| 814 | ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>, |
| 815 | ): ConfiguredPlugin<TId, TExtension, TStore, TOptions, TExtensionService, THandlersLayer, TGroup> { |
| 816 | return (options) => { |
| 817 | const { |
| 818 | storage: storageOverride, |
| 819 | ...rest |
| 820 | }: { |
| 821 | storage?: (deps: StorageDeps) => TStore; |
| 822 | [key: string]: unknown; |
| 823 | } = options ?? {}; |
| 824 | |
| 825 | const hasAuthorOptions = Object.keys(rest).length > 0; |
| 826 | const spec = authorFactory(hasAuthorOptions ? (rest as TOptions) : undefined); |
| 827 | |
| 828 | return { |
| 829 | ...spec, |
| 830 | storage: storageOverride ?? spec.storage, |
| 831 | }; |
| 832 | }; |
| 833 | } |
| 834 | |
| 835 | // --------------------------------------------------------------------------- |
| 836 | // AnyPlugin / PluginExtensions — type-level glue for the Executor surface. |
no outgoing calls