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