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
Inherited from
Properties
cache
protectedcache:ICacheProvider
Defined in: src/plugins/builtin/base-plugin.ts:88
Cache provider (available after initialization).
Inherited from
context
protectedcontext:IPluginContext
Defined in: src/plugins/builtin/base-plugin.ts:78
Plugin context (available after initialization).
Inherited from
id
readonlyid:"pub.chive.plugin.psyarxiv"='pub.chive.plugin.psyarxiv'
Defined in: src/plugins/builtin/psyarxiv.ts:213
Plugin ID.
Implementation of
Overrides
importService
protectedimportService:IImportService
Defined in: src/plugins/core/importing-plugin.ts:83
Import service instance.
Remarks
Set during initialization via dependency injection from context.
Inherited from
logger
protectedlogger:ILogger
Defined in: src/plugins/builtin/base-plugin.ts:83
Logger instance (available after initialization).
Inherited from
manifest
readonlymanifest:IPluginManifest
Defined in: src/plugins/builtin/psyarxiv.ts:228
Plugin manifest.
Implementation of
Overrides
metrics
protectedmetrics:IMetrics
Defined in: src/plugins/builtin/base-plugin.ts:93
Metrics provider (available after initialization).
Inherited from
rateLimitDelayMs
protectedrateLimitDelayMs: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
readonlysource:"psyarxiv"
Defined in: src/plugins/builtin/psyarxiv.ts:218
Import source identifier.
Overrides
supportsSearch
readonlysupportsSearch: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
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?
Fetch options (limit, cursor)
Returns
AsyncIterable<ExternalPreprint>
Async iterable of external preprints
Overrides
ImportingPlugin.fetchPreprints
getConfig()
protectedgetConfig<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
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()
protectedgetRequiredConfig<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
Current lifecycle state
Implementation of
Inherited from
importPreprint()
importPreprint(
preprint):Promise<ImportedPreprint>
Defined in: src/plugins/core/importing-plugin.ts:185
Imports a preprint into the AppView cache.
Parameters
preprint
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
Plugin context with injected dependencies
Returns
Promise<void>
Remarks
Retrieves import service from context and calls onInitialize().
Implementation of
Inherited from
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
onInitialize()
protectedonInitialize():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
onShutdown()
protectedonShutdown():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
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()
protectedrateLimit():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
recordCounter()
protectedrecordCounter(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
recordGauge()
protectedrecordGauge(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
runImportCycle()
runImportCycle(
options?):Promise<ImportCycleResult>
Defined in: src/plugins/core/importing-plugin.ts:285
Runs a full import cycle.
Parameters
options?
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()
search(
query):Promise<readonlyExternalPreprint[]>
Defined in: src/plugins/builtin/psyarxiv.ts:618
Searches PsyArXiv for preprints matching the query.
Parameters
query
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
searchPreprints()
searchPreprints(
query,options?):Promise<readonlyPsyArxivPaper[]>
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
Inherited from
startTimer()
protectedstartTimer(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
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