JustArchiNET / ASF-ui

The official web interface for ASF
Apache License 2.0
259 stars 37 forks source link

Handle extra config properties provided by third-party plugins #1012

Open JustArchi opened 4 years ago

JustArchi commented 4 years ago

Purpose

ASF-ui should be aware of extra properties that are provided by third-party plugins, "added" to the bot and global configs, without existing in ASF's structure.

Solution

Up to discussion, for now I'm thinking of ASF API that could ask all currently loaded plugins to provide a map of ConfigType (ASF or Bot) and Class reference of the structure that it appends to the config. Then ASF-ui could read that and present user "extended" view as union of all of those.

Alternatives

I'm open for other ideas.

Additional information

This will be needed if ASF-ui wants to handle SteamTokenDumperPluginEnabled as described on https://github.com/JustArchiNET/ArchiSteamFarm/wiki/SteamTokenDumperPlugin

JustArchi commented 4 years ago

Initial idea of ASF API response:

Two Dictionary<string, Type> fields from each plugin, one for ASF config and one for Bot config. Each entry in a dictionary would be name of the property and Type the property expects. Type will be exactly the same like in existing /Type API endpoint, so System.Boolean etc.

MrBurrBurr commented 4 years ago

I also wanted to add a new view where every plugin is listed (i think abry suggested this on disc).

Maybe we should add those config properties there? Not sure if we want to extend default global config view. Or maybe that would be problematic since plugins can also add config properties for bots. Hm... I am sure you and Mole will think about it and come up with the best solution.

JustArchi commented 4 years ago

Good idea actually, there can be plugins view and in that view, optionally, each plugin can list its additional dependencies, like extra config properties. Much more robust than just dedicated view for config properties.

I'll start working on it and let you know once there is something you can code logic for.

MrBurrBurr commented 4 years ago

Can plugins extend bot config? If yes then we have to think about how we gonna handle that in the new plugin view.

Abrynos commented 4 years ago

i think abry suggested this on disc

yes. I did suggest that. The reason why I haven't already made a PR for this is, that I wanted to combine it with providing extra config properties to ASF-ui as well and I didn't have the time to think about the way to do it yet.

Can plugins extend bot config?

Yes. Plugins receive all additional configuration values when bot config is loaded. My thought would be to add a "section" (maybe use <hr> or something similar) below normal bot configuration properties for each plugin.

JustArchi commented 4 years ago

Our latest discussion with @Aareksio resulted in a bit different approach:

Instead of any additional API endpoint, plugins can tag schemas in swagger.json, and ASF-ui will know that it needs to merge those with the main configs.

JustArchi commented 4 years ago

(API endpoint for discovering currently-loaded plugins is still a fine idea, but something entirely different than what we're doing in this issue, and that one indeed needs a standalone API endpoint)