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

Function definePlugin

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

Source from the content-addressed store, hash-verified

856
857// eslint-disable-next-line @typescript-eslint/ban-types
858export function definePlugin<
859 TId extends string,
860 TExtension extends object,
861 TStore,
862 TOptions extends object = {},
863 // eslint-disable-next-line @typescript-eslint/no-explicit-any
864 TExtensionService extends Context.Service<any, any> | undefined = undefined,
865 // eslint-disable-next-line @typescript-eslint/no-explicit-any
866 THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>,
867 TGroup extends HttpApiGroup.Any = HttpApiGroup.Any,
868>(
869 authorFactory: (
870 options?: TOptions,
871 ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
872): ConfiguredPlugin<TId, TExtension, TStore, TOptions, TExtensionService, THandlersLayer, TGroup> {
873 return (options) => {
874 const {
875 storage: storageOverride,
876 ...rest
877 }: {
878 storage?: (deps: StorageDeps) => TStore;
879 [key: string]: unknown;
880 } = options ?? {};
881
882 const hasAuthorOptions = Object.keys(rest).length > 0;
883 const spec = authorFactory(hasAuthorOptions ? (rest as TOptions) : undefined);
884
885 return {
886 ...spec,
887 storage: storageOverride ?? spec.storage,
888 };
889 };
890}
891
892// ---------------------------------------------------------------------------
893// 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 11

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