Skip to main content

Class: PsyArxivPlugin

Defined in: src/plugins/builtin/psyarxiv.ts:209

PsyArXiv integration plugin.

Remarks

Fetches psychology preprints from PsyArXiv via OSF Preprints API and imports them into the Chive AppView cache. Users can claim preprints they authored.

Extends ImportingPlugin for standardized import/claiming workflow.

Example

const plugin = new PsyArxivPlugin();
await manager.loadBuiltinPlugin(plugin);

Extends

Implements

Constructors

new PsyArxivPlugin()

new PsyArxivPlugin(): PsyArxivPlugin

Returns

PsyArxivPlugin

Inherited from

ImportingPlugin.constructor

Properties

cache

protected cache: ICacheProvider

Defined in: src/plugins/builtin/base-plugin.ts:88

Cache provider (available after initialization).

Inherited from

ImportingPlugin.cache


context

protected context: IPluginContext

Defined in: src/plugins/builtin/base-plugin.ts:78

Plugin context (available after initialization).

Inherited from

ImportingPlugin.context


id

readonly id: "pub.chive.plugin.psyarxiv" = 'pub.chive.plugin.psyarxiv'

Defined in: src/plugins/builtin/psyarxiv.ts:213

Plugin ID.

Implementation of

SearchablePlugin.id

Overrides

ImportingPlugin.id


importService

protected importService: IImportService

Defined in: src/plugins/core/importing-plugin.ts:83

Import service instance.

Remarks

Set during initialization via dependency injection from context.

Inherited from

ImportingPlugin.importService


logger

protected logger: ILogger

Defined in: src/plugins/builtin/base-plugin.ts:83

Logger instance (available after initialization).

Inherited from

ImportingPlugin.logger


manifest

readonly manifest: IPluginManifest

Defined in: src/plugins/builtin/psyarxiv.ts:228

Plugin manifest.

Implementation of

SearchablePlugin.manifest

Overrides

ImportingPlugin.manifest


metrics

protected metrics: IMetrics

Defined in: src/plugins/builtin/base-plugin.ts:93

Metrics provider (available after initialization).

Inherited from

ImportingPlugin.metrics


rateLimitDelayMs

protected rateLimitDelayMs: number = 1000

Defined in: src/plugins/core/importing-plugin.ts:97

Minimum delay between requests in milliseconds.

Remarks

Override in subclass to set source-specific rate limit. Default: 1000ms (1 request per second)

Inherited from

ImportingPlugin.rateLimitDelayMs


source

readonly source: "psyarxiv"

Defined in: src/plugins/builtin/psyarxiv.ts:218

Import source identifier.

Overrides

ImportingPlugin.source


supportsSearch

readonly supportsSearch: true

Defined in: src/plugins/builtin/psyarxiv.ts:223

Indicates this plugin supports on-demand search.

Implementation of

SearchablePlugin.supportsSearch

Methods

buildPdfUrl()

buildPdfUrl(externalId): null | string

Defined in: src/plugins/builtin/psyarxiv.ts:351

Builds the PDF URL for a PsyArXiv preprint.

Parameters

externalId

string

Preprint ID

Returns

null | string

PDF download URL

Overrides

ImportingPlugin.buildPdfUrl


buildPreprintUrl()

buildPreprintUrl(externalId): string

Defined in: src/plugins/builtin/psyarxiv.ts:341

Builds the canonical URL for a PsyArXiv preprint.

Parameters

externalId

string

Preprint ID

Returns

string

Full URL to the preprint

Overrides

ImportingPlugin.buildPreprintUrl


fetchPreprintDetails()

fetchPreprintDetails(preprintId): Promise<null | PsyArxivPaper>

Defined in: src/plugins/builtin/psyarxiv.ts:490

Fetches details for a specific preprint.

Parameters

preprintId

string

PsyArXiv preprint ID

Returns

Promise<null | PsyArxivPaper>

Paper details or null


fetchPreprints()

fetchPreprints(options?): AsyncIterable<ExternalPreprint>

Defined in: src/plugins/builtin/psyarxiv.ts:287

Fetches preprints from PsyArXiv.

Parameters

options?

FetchOptions

Fetch options (limit, cursor)

Returns

AsyncIterable<ExternalPreprint>

Async iterable of external preprints

Overrides

ImportingPlugin.fetchPreprints


getConfig()

protected getConfig<T>(key): undefined | T

Defined in: src/plugins/builtin/base-plugin.ts:226

Gets a configuration value with type safety.

Type Parameters

T

Parameters

key

string

Configuration key

Returns

undefined | T

Configuration value or undefined

Example

const apiKey = this.getConfig<string>('apiKey');

Inherited from

ImportingPlugin.getConfig


getExistingImport()

getExistingImport(externalId): Promise<null | ImportedPreprint>

Defined in: src/plugins/core/importing-plugin.ts:167

Gets an existing import by external ID.

Parameters

externalId

string

Source-specific identifier

Returns

Promise<null | ImportedPreprint>

Imported preprint or null if not found

Inherited from

ImportingPlugin.getExistingImport


getPaper()

getPaper(id): Promise<null | PsyArxivPaper>

Defined in: src/plugins/builtin/psyarxiv.ts:478

Gets a cached paper by ID.

Parameters

id

string

Preprint ID

Returns

Promise<null | PsyArxivPaper>

Paper metadata or null


getRequiredConfig()

protected getRequiredConfig<T>(key): T

Defined in: src/plugins/builtin/base-plugin.ts:242

Gets a required configuration value.

Type Parameters

T

Parameters

key

string

Configuration key

Returns

T

Configuration value

Throws

Error if key not found

Example

const apiKey = this.getRequiredConfig<string>('apiKey');

Inherited from

ImportingPlugin.getRequiredConfig


getState()

getState(): PluginState

Defined in: src/plugins/builtin/base-plugin.ts:162

Gets current plugin state.

Returns

PluginState

Current lifecycle state

Implementation of

SearchablePlugin.getState

Inherited from

ImportingPlugin.getState


importPreprint()

importPreprint(preprint): Promise<ImportedPreprint>

Defined in: src/plugins/core/importing-plugin.ts:185

Imports a preprint into the AppView cache.

Parameters

preprint

ExternalPreprint

External preprint data

Returns

Promise<ImportedPreprint>

Created or existing imported preprint

Remarks

Performs deduplication and emits import.created event on success.

Throws

Error if import service unavailable

Inherited from

ImportingPlugin.importPreprint


initialize()

initialize(context): Promise<void>

Defined in: src/plugins/core/importing-plugin.ts:107

Initializes the importing plugin.

Parameters

context

IPluginContext

Plugin context with injected dependencies

Returns

Promise<void>

Remarks

Retrieves import service from context and calls onInitialize().

Implementation of

SearchablePlugin.initialize

Inherited from

ImportingPlugin.initialize


isImported()

isImported(externalId): Promise<boolean>

Defined in: src/plugins/core/importing-plugin.ts:153

Checks if a preprint has already been imported.

Parameters

externalId

string

Source-specific identifier

Returns

Promise<boolean>

True if already imported

Inherited from

ImportingPlugin.isImported


onInitialize()

protected onInitialize(): Promise<void>

Defined in: src/plugins/builtin/psyarxiv.ts:269

Initializes the plugin.

Returns

Promise<void>

Remarks

Sets up rate limiting. No startup bulk import since this plugin uses on-demand search via the search() method.

Overrides

ImportingPlugin.onInitialize


onShutdown()

protected onShutdown(): Promise<void>

Defined in: src/plugins/builtin/base-plugin.ts:211

Override in subclass for shutdown logic.

Returns

Promise<void>

Remarks

Called during shutdown(). Use this to:

  • Save state
  • Close connections
  • Clean up resources

Default implementation does nothing.

Example

protected async onShutdown(): Promise<void> {
await this.saveState();
this.connection?.close();
}

Inherited from

ImportingPlugin.onShutdown


parseExternalId()

parseExternalId(url): null | string

Defined in: src/plugins/builtin/psyarxiv.ts:361

Parses external ID from a PsyArXiv URL.

Parameters

url

string

PsyArXiv URL

Returns

null | string

Preprint ID or null

Overrides

ImportingPlugin.parseExternalId


rateLimit()

protected rateLimit(): Promise<void>

Defined in: src/plugins/core/importing-plugin.ts:342

Enforces rate limiting for external requests.

Returns

Promise<void>

Remarks

Call this before making external API/HTTP requests. Delays execution if needed to respect rate limit.

Inherited from

ImportingPlugin.rateLimit


recordCounter()

protected recordCounter(name, labels?, value?): void

Defined in: src/plugins/builtin/base-plugin.ts:257

Records a counter metric.

Parameters

name

string

Metric name

labels?

Record<string, string>

Optional labels

value?

number

Optional increment value (default 1)

Returns

void

Inherited from

ImportingPlugin.recordCounter


recordGauge()

protected recordGauge(name, value, labels?): void

Defined in: src/plugins/builtin/base-plugin.ts:268

Records a gauge metric.

Parameters

name

string

Metric name

value

number

Gauge value

labels?

Record<string, string>

Optional labels

Returns

void

Inherited from

ImportingPlugin.recordGauge


runImportCycle()

runImportCycle(options?): Promise<ImportCycleResult>

Defined in: src/plugins/core/importing-plugin.ts:285

Runs a full import cycle.

Parameters

options?

FetchOptions

Fetch options

Returns

Promise<ImportCycleResult>

Import statistics

Remarks

Fetches preprints and imports new ones, updating existing ones. Respects rate limits and handles errors gracefully.

Inherited from

ImportingPlugin.runImportCycle


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

Defined in: src/plugins/builtin/psyarxiv.ts:618

Searches PsyArXiv for preprints matching the query.

Parameters

query

ExternalSearchQuery

Search parameters (author, title, externalId)

Returns

Promise<readonly ExternalPreprint[]>

Matching preprints from PsyArXiv

Throws

If the search request fails

Remarks

Uses OSF Preprints API v2 for search queries. Supports searching by:

  • Title text (filter[title] parameter)
  • Preprint ID (exact match lookup)

Rate limiting: Enforces 600ms delay between requests.

Example

const results = await psyArxivPlugin.search({
title: 'cognitive psychology',
limit: 10,
});

Implementation of

SearchablePlugin.search


searchPreprints()

searchPreprints(query, options?): Promise<readonly PsyArxivPaper[]>

Defined in: src/plugins/builtin/psyarxiv.ts:541

Searches for preprints by query.

Parameters

query

string

Search query

options?

Search options

limit

number

Returns

Promise<readonly PsyArxivPaper[]>

Matching papers


shutdown()

shutdown(): Promise<void>

Defined in: src/plugins/builtin/base-plugin.ts:142

Shuts down the plugin.

Returns

Promise<void>

Remarks

Calls onShutdown() and updates state. Subclasses should override onShutdown() instead of this method.

Implementation of

SearchablePlugin.shutdown

Inherited from

ImportingPlugin.shutdown


startTimer()

protected startTimer(name, labels?): () => void

Defined in: src/plugins/builtin/base-plugin.ts:286

Starts a timer for histogram metrics.

Parameters

name

string

Metric name

labels?

Record<string, string>

Optional labels

Returns

Function

Function to call when operation completes

Returns

void

Example

const endTimer = this.startTimer('api_request');
await this.fetchData();
endTimer(); // Records duration

Inherited from

ImportingPlugin.startTimer


updateImport()

updateImport(id, preprint): Promise<ImportedPreprint>

Defined in: src/plugins/core/importing-plugin.ts:243

Updates an existing import with new data.

Parameters

id

number

Internal import ID

preprint

Partial<ExternalPreprint>

Updated preprint data

Returns

Promise<ImportedPreprint>

Updated imported preprint

Inherited from

ImportingPlugin.updateImport