MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / definePlugin

Function definePlugin

packages/core/sdk/src/plugin.ts:837–869  ·  view source on GitHub ↗
(
  authorFactory: (
    options?: TOptions,
  ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
)

Source from the content-addressed store, hash-verified

835
836// eslint-disable-next-line @typescript-eslint/ban-types
837export 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.

Callers 15

makeScopePluginWithIdFunction · 0.90
promise.test.tsFile · 0.90
pluginFunction · 0.90
core-tools.tsFile · 0.90
pluginWithFunction · 0.90
revokingPluginFunction · 0.90
txPluginFunction · 0.90

Calls

no outgoing calls

Tested by 9

makeScopePluginWithIdFunction · 0.72
pluginFunction · 0.72
pluginWithFunction · 0.72
revokingPluginFunction · 0.72
txPluginFunction · 0.72
detectorFunction · 0.72
makeRejectingPluginFunction · 0.72
makeTestPluginFunction · 0.72
inventoryPluginFunction · 0.72