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