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

Function definePlugin

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

Source from the content-addressed store, hash-verified

892
893// eslint-disable-next-line @typescript-eslint/ban-types
894export function definePlugin<
895 TId extends string,
896 TExtension extends object,
897 TStore,
898 TOptions extends object = {},
899 // eslint-disable-next-line @typescript-eslint/no-explicit-any
900 TExtensionService extends Context.Service<any, any> | undefined = undefined,
901 // eslint-disable-next-line @typescript-eslint/no-explicit-any
902 THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>,
903 TGroup extends HttpApiGroup.Any = HttpApiGroup.Any,
904>(
905 authorFactory: (
906 options?: TOptions,
907 ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
908): ConfiguredPlugin<TId, TExtension, TStore, TOptions, TExtensionService, THandlersLayer, TGroup> {
909 return (options) => {
910 const {
911 storage: storageOverride,
912 ...rest
913 }: {
914 storage?: (deps: StorageDeps) => TStore;
915 [key: string]: unknown;
916 } = options ?? {};
917
918 const hasAuthorOptions = Object.keys(rest).length > 0;
919 const spec = authorFactory(hasAuthorOptions ? (rest as TOptions) : undefined);
920
921 return {
922 ...spec,
923 storage: storageOverride ?? spec.storage,
924 };
925 };
926}
927
928// ---------------------------------------------------------------------------
929// 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 13

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