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

Function definePlugin

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

Source from the content-addressed store, hash-verified

799
800// eslint-disable-next-line @typescript-eslint/ban-types
801export function definePlugin<
802 TId extends string,
803 TExtension extends object,
804 TStore,
805 TOptions extends object = {},
806 // eslint-disable-next-line @typescript-eslint/no-explicit-any
807 TExtensionService extends Context.Service<any, any> | undefined = undefined,
808 // eslint-disable-next-line @typescript-eslint/no-explicit-any
809 THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>,
810 TGroup extends HttpApiGroup.Any = HttpApiGroup.Any,
811>(
812 authorFactory: (
813 options?: TOptions,
814 ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
815): ConfiguredPlugin<TId, TExtension, TStore, TOptions, TExtensionService, THandlersLayer, TGroup> {
816 return (options) => {
817 const {
818 storage: storageOverride,
819 ...rest
820 }: {
821 storage?: (deps: StorageDeps) => TStore;
822 [key: string]: unknown;
823 } = options ?? {};
824
825 const hasAuthorOptions = Object.keys(rest).length > 0;
826 const spec = authorFactory(hasAuthorOptions ? (rest as TOptions) : undefined);
827
828 return {
829 ...spec,
830 storage: storageOverride ?? spec.storage,
831 };
832 };
833}
834
835// ---------------------------------------------------------------------------
836// 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