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

Function definePlugin

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

Source from the content-addressed store, hash-verified

696
697// eslint-disable-next-line @typescript-eslint/ban-types
698export function definePlugin<
699 TId extends string,
700 TExtension extends object,
701 TStore,
702 TOptions extends object = {},
703 // eslint-disable-next-line @typescript-eslint/no-explicit-any
704 TExtensionService extends Context.Service<any, any> | undefined = undefined,
705 // eslint-disable-next-line @typescript-eslint/no-explicit-any
706 THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>,
707 TGroup extends HttpApiGroup.Any = HttpApiGroup.Any,
708>(
709 authorFactory: (
710 options?: TOptions,
711 ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
712): ConfiguredPlugin<TId, TExtension, TStore, TOptions, TExtensionService, THandlersLayer, TGroup> {
713 return (options) => {
714 const {
715 storage: storageOverride,
716 ...rest
717 }: {
718 storage?: (deps: StorageDeps) => TStore;
719 [key: string]: unknown;
720 } = options ?? {};
721
722 const hasAuthorOptions = Object.keys(rest).length > 0;
723 const spec = authorFactory(hasAuthorOptions ? (rest as TOptions) : undefined);
724
725 return {
726 ...spec,
727 storage: storageOverride ?? spec.storage,
728 };
729 };
730}
731
732// ---------------------------------------------------------------------------
733// AnyPlugin / PluginExtensions — type-level glue for the Executor surface.

Callers 15

makeScopePluginWithIdFunction · 0.90
promise.test.tsFile · 0.90
core-tools.tsFile · 0.90
executor.test.tsFile · 0.90
detectorFunction · 0.90
test-config.tsFile · 0.90
oauth-flow.test.tsFile · 0.90
policies.test.tsFile · 0.90

Calls

no outgoing calls

Tested by 3

makeScopePluginWithIdFunction · 0.72
detectorFunction · 0.72
makeTestPluginFunction · 0.72