Skip to content

dependabit / plugins/registry/src / PluginRegistry

Class: PluginRegistry

Defined in: packages/plugins/registry/src/registry.ts:126

Registry that maps access method identifiers to plugin instances.

Remarks

Each access method can have at most one registered plugin at a time. Attempting to register a second plugin for the same accessMethod without first unregistering the existing one throws an Error.

Use When

  • Managing a set of plugins across the lifetime of an application.
  • Isolating plugins in a test suite (via createPluginRegistry).

Avoid When

Using the globalRegistry singleton directly in tests that run in parallel — mutations to the global registry leak between test cases.

Pitfalls

  • Silent collision override is intentional by design in the old API; the current implementation throws on collision. Do not assume register is idempotent.
  • clear is fire-and-forget: errors from plugin.destroy() are caught and logged but not re-thrown. A plugin that fails to tear down cleanly will leave resources open silently.

Constructors

Constructor

ts
new PluginRegistry(): PluginRegistry;

Returns

PluginRegistry

Methods

clear()

ts
clear(): void;

Defined in: packages/plugins/registry/src/registry.ts:191

Clear all plugins

Returns

void


count()

ts
count(): number;

Defined in: packages/plugins/registry/src/registry.ts:184

Get plugin count

Returns

number


discover()

ts
discover(): string[];

Defined in: packages/plugins/registry/src/registry.ts:177

Discover and list available access methods

Returns

string[]


get()

ts
get(accessMethod): Plugin | undefined;

Defined in: packages/plugins/registry/src/registry.ts:156

Get a plugin by access method

Parameters

ParameterType
accessMethodstring

Returns

Plugin | undefined


has()

ts
has(accessMethod): boolean;

Defined in: packages/plugins/registry/src/registry.ts:163

Check if a plugin is registered

Parameters

ParameterType
accessMethodstring

Returns

boolean


list()

ts
list(): {
  accessMethod: string;
  apiVersion?: string;
  description?: string;
  name: string;
  supportedTypes?: string[];
  version: string;
}[];

Defined in: packages/plugins/registry/src/registry.ts:170

List all registered plugins

Returns

{ accessMethod: string; apiVersion?: string; description?: string; name: string; supportedTypes?: string[]; version: string; }[]


register()

ts
register(plugin): void;

Defined in: packages/plugins/registry/src/registry.ts:132

Register a plugin

Parameters

ParameterType
pluginPlugin

Returns

void


unregister()

ts
unregister(accessMethod): Promise<boolean>;

Defined in: packages/plugins/registry/src/registry.ts:145

Unregister a plugin

Parameters

ParameterType
accessMethodstring

Returns

Promise<boolean>

Released under the MIT License.