(
authorFactory: (
options?: TOptions,
) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
)
| 835 | |
| 836 | // eslint-disable-next-line @typescript-eslint/ban-types |
| 837 | export function definePlugin< |
| 838 | TId extends string, |
| 839 | TExtension extends object, |
| 840 | TStore, |
| 841 | TOptions extends object = {}, |
| 842 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 843 | TExtensionService extends Context.Service<any, any> | undefined = undefined, |
| 844 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 845 | THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>, |
| 846 | TGroup extends HttpApiGroup.Any = HttpApiGroup.Any, |
| 847 | >( |
| 848 | authorFactory: ( |
| 849 | options?: TOptions, |
| 850 | ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>, |
| 851 | ): ConfiguredPlugin<TId, TExtension, TStore, TOptions, TExtensionService, THandlersLayer, TGroup> { |
| 852 | return (options) => { |
| 853 | const { |
| 854 | storage: storageOverride, |
| 855 | ...rest |
| 856 | }: { |
| 857 | storage?: (deps: StorageDeps) => TStore; |
| 858 | [key: string]: unknown; |
| 859 | } = options ?? {}; |
| 860 | |
| 861 | const hasAuthorOptions = Object.keys(rest).length > 0; |
| 862 | const spec = authorFactory(hasAuthorOptions ? (rest as TOptions) : undefined); |
| 863 | |
| 864 | return { |
| 865 | ...spec, |
| 866 | storage: storageOverride ?? spec.storage, |
| 867 | }; |
| 868 | }; |
| 869 | } |
| 870 | |
| 871 | // --------------------------------------------------------------------------- |
| 872 | // AnyPlugin / PluginExtensions — type-level glue for the Executor surface. |
no outgoing calls