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
registeris idempotent. clearis fire-and-forget: errors fromplugin.destroy()are caught and logged but not re-thrown. A plugin that fails to tear down cleanly will leave resources open silently.
Constructors
Constructor
new PluginRegistry(): PluginRegistry;Returns
PluginRegistry
Methods
clear()
clear(): void;Defined in: packages/plugins/registry/src/registry.ts:191
Clear all plugins
Returns
void
count()
count(): number;Defined in: packages/plugins/registry/src/registry.ts:184
Get plugin count
Returns
number
discover()
discover(): string[];Defined in: packages/plugins/registry/src/registry.ts:177
Discover and list available access methods
Returns
string[]
get()
get(accessMethod): Plugin | undefined;Defined in: packages/plugins/registry/src/registry.ts:156
Get a plugin by access method
Parameters
| Parameter | Type |
|---|---|
accessMethod | string |
Returns
Plugin | undefined
has()
has(accessMethod): boolean;Defined in: packages/plugins/registry/src/registry.ts:163
Check if a plugin is registered
Parameters
| Parameter | Type |
|---|---|
accessMethod | string |
Returns
boolean
list()
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()
register(plugin): void;Defined in: packages/plugins/registry/src/registry.ts:132
Register a plugin
Parameters
| Parameter | Type |
|---|---|
plugin | Plugin |
Returns
void
unregister()
unregister(accessMethod): Promise<boolean>;Defined in: packages/plugins/registry/src/registry.ts:145
Unregister a plugin
Parameters
| Parameter | Type |
|---|---|
accessMethod | string |
Returns
Promise<boolean>