Skip to content

feat(plugins): add plugin functionality to support importing

Ben Whitmore requested to merge plugins-20230226 into main

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

  1. app.js calls registerPlugins() on startup.
  2. 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.
  3. For each plugin, registerPlugins calls the default function in its index.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.
  4. In the NCRC import example, the plugin uses the broker's addManuscriptImporter function to register a callback for performing imports.
  5. 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.
Edited by Ben Whitmore

Merge request reports