Skip to main content

Interface: SearchablePlugin

Defined in: src/types/interfaces/plugin.interface.ts:1342

Plugin that supports on-demand search of external sources.

Remarks

Extends IChivePlugin with search capabilities. Plugins implementing this interface can query external APIs directly when users search, rather than requiring bulk pre-import.

This approach:

  • Reduces storage requirements (only import claimed papers)
  • Ensures fresh data (real-time from source)
  • Minimizes API load on external services

Example

class ArxivPlugin implements SearchablePlugin {
readonly supportsSearch = true;

async search(query: ExternalSearchQuery): Promise<ExternalPreprint[]> {
const url = buildArxivQuery(query);
const response = await fetch(url);
return parseAtomFeed(response);
}
}

Since

0.1.0

Extends

Properties

id

readonly id: string

Defined in: src/types/interfaces/plugin.interface.ts:378

Unique plugin identifier.

Remarks

Must match manifest.id.

Inherited from

IChivePlugin.id


manifest

readonly manifest: IPluginManifest

Defined in: src/types/interfaces/plugin.interface.ts:383

Plugin manifest.

Inherited from

IChivePlugin.manifest


supportsSearch

readonly supportsSearch: true

Defined in: src/types/interfaces/plugin.interface.ts:1350

Discriminator to identify searchable plugins.

Remarks

Used in type guards to distinguish from non-searchable plugins. Always set to true for SearchablePlugin implementations.

Methods

getState()

getState(): PluginState

Defined in: src/types/interfaces/plugin.interface.ts:453

Gets current plugin state.

Returns

PluginState

Current lifecycle state

Example

getState(): PluginState {
return this.state;
}

Inherited from

IChivePlugin.getState


initialize()

initialize(context): Promise<void>

Defined in: src/types/interfaces/plugin.interface.ts:413

Initializes the plugin.

Parameters

context

IPluginContext

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');
}

Inherited from

IChivePlugin.initialize


search(query): Promise<readonly ExternalPreprint[]>

Defined in: src/types/interfaces/plugin.interface.ts:1366

Searches the external source for preprints matching the query.

Parameters

query

ExternalSearchQuery

Search parameters

Returns

Promise<readonly ExternalPreprint[]>

Matching preprints from the external source

Throws

If the search request fails

Remarks

Implementations must:

  • Respect rate limits of the external API
  • Handle network errors gracefully
  • Return empty array (not throw) for no results

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();
}

Inherited from

IChivePlugin.shutdown