Allow different recipes to be called via the INK component
The existing INK components (frontend and backend) were built to handle conversion of DOCX files to HTML; this change allows any INK recipe to be called in the same way.
- Adds a "recipe" parameter (fixes #54)
- Adds an "outputFile" parameter (so the backend knows which file to download at the end of the process)
- Refactor to improve promise handling
The changes to the backend component are backwards-compatible (tested in Editoria) - finding the recipe id works as follows:
- Read the "recipe" parameter.
- If there's a matching key (e.g. 'editoria-typescript') in
config['pubsweet-component-ink-backend']['recipes']
use that value as the recipe ID. This is the ideal situation, where the app configuration maps keys used in the frontend to recipe IDs in the configured INK instance. - If there's no key, use "Editoria Typescript" as the default (for backwards compatibility). Fetch the list of recipes from the INK API and find the recipe with title that matches this key (this is how it used to work, but is inefficient as it has to fetch and filter that list for every conversion).
Merge request reports
Activity
added 46 commits
-
ecc2475a...ca4b3265 - 45 commits from branch
master
- fc4bc326 - Merge branch 'master' into ink-backend-recipe-parameter
-
ecc2475a...ca4b3265 - 45 commits from branch
mentioned in issue INK/ink-issues#3 (moved)
Cool, this looks good! Authorization happening on app boot up in particular, was an issue for several users of the component. Now it's happening on request, which makes a lot more sense
I had to look twice at !113 (diffs) as it uses
options.recipe
twice, but then it made sense. Containing a map ofrecipeKey
torecipeId
in the config makes sense, since it's human readable then. One source of confusion though might be, that the user configures options.recipe to be 'editoria-typescript', and theoptions.recipes
map points to say id 7. To the user that all seems OK, but the options.recipe is of course not linked in any way to how INK itself is configured, so its id might be e.g. 12. So, what I'm saying is, that usingoptions.recipe
withoutoptions.recipes
is more intuitive, but worse in a performance sense. Not really something that can be addressed in this MR, but we should add config docs in a separate MR.LGTM
mentioned in commit a0176b98
This will be a patch release, due to the backwards compatibility. Thanks @alf!