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

Function definePlugin

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

Source from the content-addressed store, hash-verified

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