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

Function definePlugin

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

Source from the content-addressed store, hash-verified

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