(
authorFactory: (
options?: TOptions,
) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
)
| 856 | |
| 857 | // eslint-disable-next-line @typescript-eslint/ban-types |
| 858 | export function definePlugin< |
| 859 | TId extends string, |
| 860 | TExtension extends object, |
| 861 | TStore, |
| 862 | TOptions extends object = {}, |
| 863 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 864 | TExtensionService extends Context.Service<any, any> | undefined = undefined, |
| 865 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 866 | THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>, |
| 867 | TGroup extends HttpApiGroup.Any = HttpApiGroup.Any, |
| 868 | >( |
| 869 | authorFactory: ( |
| 870 | options?: TOptions, |
| 871 | ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>, |
| 872 | ): ConfiguredPlugin<TId, TExtension, TStore, TOptions, TExtensionService, THandlersLayer, TGroup> { |
| 873 | return (options) => { |
| 874 | const { |
| 875 | storage: storageOverride, |
| 876 | ...rest |
| 877 | }: { |
| 878 | storage?: (deps: StorageDeps) => TStore; |
| 879 | [key: string]: unknown; |
| 880 | } = options ?? {}; |
| 881 | |
| 882 | const hasAuthorOptions = Object.keys(rest).length > 0; |
| 883 | const spec = authorFactory(hasAuthorOptions ? (rest as TOptions) : undefined); |
| 884 | |
| 885 | return { |
| 886 | ...spec, |
| 887 | storage: storageOverride ?? spec.storage, |
| 888 | }; |
| 889 | }; |
| 890 | } |
| 891 | |
| 892 | // --------------------------------------------------------------------------- |
| 893 | // AnyPlugin / PluginExtensions — type-level glue for the Executor surface. |
no outgoing calls