feat(plugins): add plugin functionality to support importing
A plugin harness, permitting kotahi to load and run plugins. Only import plugins are supported so far. Documentation is here.
I have also created a worked example of a simple plugin for importing manuscripts, based on the existing NCRC import from pubmed. This can be viewed at https://gitlab.coko.foundation/kotahi/ncrc-import-from-pubmed
This current import harness will need extending in future to support other features such as export and wax services.
Main concepts
-
app.js
callsregisterPlugins()
on startup. - This reads from
config/plugins/plugins_manifest.json
and imports each of the named plugins, as configured for each group. An example manifest is included in the repo, but the actual manifest and plugins are gitignored. - For each plugin,
registerPlugins
calls the default function in itsindex.js
, passing a plugin broker. The plugin's default function can use that broker however it likes. The broker is a group-specific object that provides access to a bunch of functions that will allow the plugin to interact with that group in Kotahi. - In the NCRC import example, the plugin uses the broker's
addManuscriptImporter
function to register a callback for performing imports. - When scheduled imports are run for a group or the import button is pressed, Kotahi calls each registered importer callback, passing lists of dois and uris already encountered during this import (to allow avoidance of duplicates), plus the date of the last import by this plugin. The callback should return an array of new manuscript objects to add to the DB.