Interface: IChivePlugin
Defined in: src/types/interfaces/plugin.interface.ts:371
Base plugin interface.
Remarks
All Chive plugins must implement this interface.
Since
0.1.0
Extended by
Properties
id
readonlyid:string
Defined in: src/types/interfaces/plugin.interface.ts:378
Unique plugin identifier.
Remarks
Must match manifest.id.
manifest
readonlymanifest:IPluginManifest
Defined in: src/types/interfaces/plugin.interface.ts:383
Plugin manifest.
Methods
getState()
getState():
PluginState
Defined in: src/types/interfaces/plugin.interface.ts:453
Gets current plugin state.
Returns
Current lifecycle state
Example
getState(): PluginState {
return this.state;
}
initialize()
initialize(
context):Promise<void>
Defined in: src/types/interfaces/plugin.interface.ts:413
Initializes the plugin.
Parameters
context
Plugin context with injected dependencies
Returns
Promise<void>
Promise resolving when initialization complete
Remarks
Called once when plugin is loaded. Use this to:
- Subscribe to event hooks
- Initialize plugin state
- Validate configuration
If initialization fails, throw an error to prevent plugin from loading.
Example
async initialize(context: IPluginContext): Promise<void> {
this.logger = context.logger;
this.cache = context.cache;
context.eventBus.on('preprint.indexed', this.handleIndexed.bind(this));
this.logger.info('Plugin initialized');
}
shutdown()
shutdown():
Promise<void>
Defined in: src/types/interfaces/plugin.interface.ts:437
Shuts down the plugin.
Returns
Promise<void>
Promise resolving when shutdown complete
Remarks
Called when Chive is shutting down or plugin is being unloaded. Use this to:
- Unsubscribe from event hooks
- Close connections
- Save state
Example
async shutdown(): Promise<void> {
this.logger.info('Plugin shutting down');
await this.saveState();
}