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

Function definePlugin

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

Source from the content-addressed store, hash-verified

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

Calls

no outgoing calls

Tested by 7

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