using System.Linq.Expressions; using AIStudio.Settings.DataModel; using Lua; namespace AIStudio.Tools.PluginSystem; /// /// Describes a type of configuration object which derives from ConfigurationBaseObject. /// /// The type of the configuration objects. /// The Lua table in which a configuration plugin defines these objects. /// Where the settings keep these objects. /// The number which the next of these objects gets. /// Reads one of these objects from its Lua table. /// Where the API keys of these objects are kept, or null for objects without one. /// The class of the configuration objects. public sealed class ConfigurationBaseObjectDescriptor(PluginConfigurationObjectType type, string luaTableName, Expression>> selection, Expression> nextNumSelection, ConfigurationObjectParser parser, SecretStoreType? secretStoreType = null) : PluginConfigurationObjectDescriptor where TClass : ConfigurationBaseObject { /// public override PluginConfigurationObjectType Type => type; /// /// The Lua table in which a configuration plugin defines these objects. /// public string LuaTableName => luaTableName; /// /// Where the settings keep these objects. /// public Expression>> Selection => selection; /// /// The number which the next of these objects gets. /// public Expression> NextNumSelection => nextNumSelection; /// /// Reads one of these objects from its Lua table. /// public ConfigurationObjectParser Parser => parser; /// public override bool TryParse(LuaTable mainTable, Guid configPluginId, List configObjects, bool dryRun, string pluginPath) => PluginConfigurationObject.TryParse(this, mainTable, configPluginId, configObjects, dryRun, pluginPath); /// public override Task CleanLeftOverAsync(IList availablePlugins, IReadOnlySet deployedEnterpriseConfigPluginIds, IReadOnlySet notStartedConfigPluginIds, IList configObjectList) => PluginConfigurationObject.CleanLeftOverConfigurationObjects(type, selection, availablePlugins, deployedEnterpriseConfigPluginIds, notStartedConfigPluginIds, configObjectList, secretStoreType); /// public override int RemovePluginObjects(Data settings) => selection.Compile()(settings).RemoveAll(configObject => configObject.IsEnterpriseConfiguration); }