2024-07-15 20:06:22 +00:00
|
|
|
namespace BotSharp.Plugin.SqlDriver.Hooks;
|
|
|
|
|
|
2024-09-24 15:45:57 +00:00
|
|
|
public class SqlUtilityHook : IAgentUtilityHook
|
2024-07-15 20:06:22 +00:00
|
|
|
{
|
2024-12-04 22:12:02 +00:00
|
|
|
private const string PREFIX = "util-db-";
|
|
|
|
|
private const string SQL_TABLE_DEFINITION_FN = $"{PREFIX}sql_table_definition";
|
|
|
|
|
private const string VERIFY_DICTIONARY_TERM_FN = $"{PREFIX}verify_dictionary_term";
|
|
|
|
|
private const string SQL_SELECT_FN = $"{PREFIX}sql_select";
|
|
|
|
|
private const string SQL_EXECUTOR_FN = $"{PREFIX}sql_executor";
|
2024-11-21 06:50:55 +00:00
|
|
|
|
|
|
|
|
public void AddUtilities(List<AgentUtility> utilities)
|
2024-07-15 20:06:22 +00:00
|
|
|
{
|
2024-11-21 06:50:55 +00:00
|
|
|
var items = new List<AgentUtility>
|
|
|
|
|
{
|
|
|
|
|
new AgentUtility
|
|
|
|
|
{
|
|
|
|
|
Name = UtilityName.SqlTableDefinition,
|
|
|
|
|
Functions = [new(SQL_TABLE_DEFINITION_FN)],
|
|
|
|
|
Templates = [new($"{SQL_TABLE_DEFINITION_FN}.fn")]
|
|
|
|
|
},
|
|
|
|
|
new AgentUtility
|
|
|
|
|
{
|
|
|
|
|
Name = UtilityName.SqlDictionaryLookup,
|
|
|
|
|
Functions = [new(VERIFY_DICTIONARY_TERM_FN)],
|
|
|
|
|
Templates = [new($"{VERIFY_DICTIONARY_TERM_FN}.fn")]
|
|
|
|
|
},
|
|
|
|
|
new AgentUtility
|
|
|
|
|
{
|
|
|
|
|
Name = UtilityName.SqlExecutor,
|
2024-11-22 01:37:56 +00:00
|
|
|
Functions = [new(SQL_SELECT_FN), new(SQL_TABLE_DEFINITION_FN)],
|
2024-12-04 22:12:02 +00:00
|
|
|
Templates = [new($"{SQL_EXECUTOR_FN}.fn")]
|
2024-11-21 06:50:55 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
utilities.AddRange(items);
|
2024-07-15 20:06:22 +00:00
|
|
|
}
|
|
|
|
|
}
|