refactor: unify anilist module contracts

This commit is contained in:
jxxghp
2026-08-24 01:45:49 +08:00
parent 903d1d3c4d
commit 488b3667bb
3 changed files with 159 additions and 76 deletions
@@ -153,6 +153,14 @@ _METHOD_CONTRACTS = {
"bangumi_person_credits": ModuleMethodContract(family="bangumi", input_contract="BangumiPersonRequest", result_contract="list[MediaInfo]", result_shape=ModuleResultShape.LIST, aggregation=ModuleResultAggregation.ORDERED_LIST_MERGE, required_parameters=("person_id",)),
"bangumi_person_detail": ModuleMethodContract(family="bangumi", input_contract="BangumiPersonRequest", result_contract="MediaPerson | None", aggregation=ModuleResultAggregation.FIRST_NON_EMPTY, required_parameters=("person_id",)),
"bangumi_recommend": ModuleMethodContract(family="bangumi", input_contract="BangumiMediaRequest", result_contract="list[MediaInfo]", result_shape=ModuleResultShape.LIST, aggregation=ModuleResultAggregation.ORDERED_LIST_MERGE, required_parameters=("bangumiid",)),
"anilist_credits": ModuleMethodContract(family="anilist", input_contract="AniListMediaPageRequest", result_contract="list[MediaPerson]", result_shape=ModuleResultShape.LIST, aggregation=ModuleResultAggregation.ORDERED_LIST_MERGE, required_parameters=("anilist_id", "page", "count")),
"anilist_discover": ModuleMethodContract(family="anilist", input_contract="AniListDiscoverArguments", result_contract="list[MediaInfo]", result_shape=ModuleResultShape.LIST, aggregation=ModuleResultAggregation.ORDERED_LIST_MERGE),
"anilist_info": ModuleMethodContract(family="anilist", input_contract="AniListMediaRequest", result_contract="dict | None", result_shape=ModuleResultShape.MAPPING, aggregation=ModuleResultAggregation.FIRST_NON_EMPTY, required_parameters=("anilist_id",)),
"anilist_person_credits": ModuleMethodContract(family="anilist", input_contract="AniListPersonPageRequest", result_contract="list[MediaInfo]", result_shape=ModuleResultShape.LIST, aggregation=ModuleResultAggregation.ORDERED_LIST_MERGE, required_parameters=("person_id", "page", "count")),
"anilist_person_detail": ModuleMethodContract(family="anilist", input_contract="AniListPersonRequest", result_contract="MediaPerson | None", aggregation=ModuleResultAggregation.FIRST_NON_EMPTY, required_parameters=("person_id",)),
"anilist_popular_this_season": ModuleMethodContract(family="anilist", input_contract="AniListPageRequest", result_contract="list[MediaInfo]", result_shape=ModuleResultShape.LIST, aggregation=ModuleResultAggregation.ORDERED_LIST_MERGE, required_parameters=("page", "count")),
"anilist_recommendations": ModuleMethodContract(family="anilist", input_contract="AniListMediaPageRequest", result_contract="list[MediaInfo]", result_shape=ModuleResultShape.LIST, aggregation=ModuleResultAggregation.ORDERED_LIST_MERGE, required_parameters=("anilist_id", "page", "count")),
"anilist_trending": ModuleMethodContract(family="anilist", input_contract="AniListPageRequest", result_contract="list[MediaInfo]", result_shape=ModuleResultShape.LIST, aggregation=ModuleResultAggregation.ORDERED_LIST_MERGE, required_parameters=("page", "count")),
"send_message": ModuleMethodContract(family="messaging", input_contract="MessageSendRequest", result_contract="Message | None", aggregation=ModuleResultAggregation.FIRST_NON_EMPTY),
"finalize_message": ModuleMethodContract(family="messaging", input_contract="MessageFinalizeRequest", result_contract="Message | None", aggregation=ModuleResultAggregation.FIRST_NON_EMPTY, required_parameters=("response",)),
"register_commands": ModuleMethodContract(family="messaging", input_contract="CommandRegistrationRequest", result_contract="None", required_parameters=("commands",)),
@@ -214,6 +222,14 @@ _METHOD_CONTRACTS.update({
"async_bangumi_person_credits": _METHOD_CONTRACTS["bangumi_person_credits"],
"async_bangumi_person_detail": _METHOD_CONTRACTS["bangumi_person_detail"],
"async_bangumi_recommend": _METHOD_CONTRACTS["bangumi_recommend"],
"async_anilist_credits": _METHOD_CONTRACTS["anilist_credits"],
"async_anilist_discover": _METHOD_CONTRACTS["anilist_discover"],
"async_anilist_info": _METHOD_CONTRACTS["anilist_info"],
"async_anilist_person_credits": _METHOD_CONTRACTS["anilist_person_credits"],
"async_anilist_person_detail": _METHOD_CONTRACTS["anilist_person_detail"],
"async_anilist_popular_this_season": _METHOD_CONTRACTS["anilist_popular_this_season"],
"async_anilist_recommendations": _METHOD_CONTRACTS["anilist_recommendations"],
"async_anilist_trending": _METHOD_CONTRACTS["anilist_trending"],
})
_PREFIX_CONTRACTS = (