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

Function definePlugin

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

Source from the content-addressed store, hash-verified

879
880// eslint-disable-next-line @typescript-eslint/ban-types
881export function definePlugin<
882 TId extends string,
883 TExtension extends object,
884 TStore,
885 TOptions extends object = {},
886 // eslint-disable-next-line @typescript-eslint/no-explicit-any
887 TExtensionService extends Context.Service<any, any> | undefined = undefined,
888 // eslint-disable-next-line @typescript-eslint/no-explicit-any
889 THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>,
890 TGroup extends HttpApiGroup.Any = HttpApiGroup.Any,
891>(
892 authorFactory: (
893 options?: TOptions,
894 ) => PluginSpec<TId, TExtension, TStore, TExtensionService, THandlersLayer, TGroup>,
895): ConfiguredPlugin<TId, TExtension, TStore, TOptions, TExtensionService, THandlersLayer, TGroup> {
896 return (options) => {
897 const {
898 storage: storageOverride,
899 ...rest
900 }: {
901 storage?: (deps: StorageDeps) => TStore;
902 [key: string]: unknown;
903 } = options ?? {};
904
905 const hasAuthorOptions = Object.keys(rest).length > 0;
906 const spec = authorFactory(hasAuthorOptions ? (rest as TOptions) : undefined);
907
908 return {
909 ...spec,
910 storage: storageOverride ?? spec.storage,
911 };
912 };
913}
914
915// ---------------------------------------------------------------------------
916// 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 12

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
makeTestPluginFunction · 0.72
inventoryPluginFunction · 0.72