(
authorFactory: (
options?: TOptions,
) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
)
| 879 | |
| 880 | // eslint-disable-next-line @typescript-eslint/ban-types |
| 881 | export function definePlugin< |
| 882 | TId extends string, |
| 883 | TExtension extends object, |
| 884 | TStore, |
| 885 | TOptions extends object = {}, |
| 886 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 887 | TExtensionService extends Context.Service<any, any> | undefined = undefined, |
| 888 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 889 | THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>, |
| 890 | TGroup extends HttpApiGroup.Any = HttpApiGroup.Any, |
| 891 | >( |
| 892 | authorFactory: ( |
| 893 | options?: TOptions, |
| 894 | ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>, |
| 895 | ): ConfiguredPlugin<TId, TExtension, TStore, TOptions, TExtensionService, THandlersLayer, TGroup> { |
| 896 | return (options) => { |
| 897 | const { |
| 898 | storage: storageOverride, |
| 899 | ...rest |
| 900 | }: { |
| 901 | storage?: (deps: StorageDeps) => TStore; |
| 902 | [key: string]: unknown; |
| 903 | } = options ?? {}; |
| 904 | |
| 905 | const hasAuthorOptions = Object.keys(rest).length > 0; |
| 906 | const spec = authorFactory(hasAuthorOptions ? (rest as TOptions) : undefined); |
| 907 | |
| 908 | return { |
| 909 | ...spec, |
| 910 | storage: storageOverride ?? spec.storage, |
| 911 | }; |
| 912 | }; |
| 913 | } |
| 914 | |
| 915 | // --------------------------------------------------------------------------- |
| 916 | // AnyPlugin / PluginExtensions — type-level glue for the Executor surface. |
no outgoing calls