mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
refactor: type host lookup contracts
This commit is contained in:
+101
-64
@@ -4190,15 +4190,18 @@
|
||||
"version": 1
|
||||
},
|
||||
"get_search_page_size": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "site",
|
||||
"input_contract": "SiteKeywordArguments",
|
||||
"input_contract": "SiteSearchPageSizeRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "SiteProviderResult",
|
||||
"required_parameters": [
|
||||
"keyword",
|
||||
"site"
|
||||
],
|
||||
"result_contract": "int | None",
|
||||
"result_shape": "any",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
@@ -4281,15 +4284,15 @@
|
||||
"version": 1
|
||||
},
|
||||
"load_category_config": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "category",
|
||||
"input_contract": "CategoryKeywordArguments",
|
||||
"input_contract": "CategoryConfigReadRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "CategoryProviderResult",
|
||||
"result_contract": "CategoryConfig | None",
|
||||
"result_shape": "any",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
@@ -4377,7 +4380,7 @@
|
||||
"version": 1
|
||||
},
|
||||
"media_category": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "media-recognition",
|
||||
@@ -4385,8 +4388,8 @@
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "CategoryConfig | None",
|
||||
"result_shape": "any",
|
||||
"result_contract": "dict[str, list] | None",
|
||||
"result_shape": "mapping",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
"timeout_policy": "caller_budget",
|
||||
@@ -4682,32 +4685,41 @@
|
||||
"version": 1
|
||||
},
|
||||
"metadata_img": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "metadata",
|
||||
"input_contract": "MetadataKeywordArguments",
|
||||
"input_contract": "MetadataImageRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "MetadataProviderResult",
|
||||
"result_shape": "any",
|
||||
"required_parameters": [
|
||||
"episode",
|
||||
"mediainfo",
|
||||
"season"
|
||||
],
|
||||
"result_contract": "dict[str, str] | None",
|
||||
"result_shape": "mapping",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
"timeout_policy": "caller_budget",
|
||||
"version": 1
|
||||
},
|
||||
"metadata_nfo": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "metadata",
|
||||
"input_contract": "MetadataKeywordArguments",
|
||||
"input_contract": "MetadataNfoRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "MetadataProviderResult",
|
||||
"result_shape": "any",
|
||||
"required_parameters": [
|
||||
"episode",
|
||||
"mediainfo",
|
||||
"meta",
|
||||
"season"
|
||||
],
|
||||
"result_contract": "str | None",
|
||||
"result_shape": "string",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
"timeout_policy": "caller_budget",
|
||||
@@ -4972,16 +4984,23 @@
|
||||
"version": 1
|
||||
},
|
||||
"obtain_specific_image": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "metadata",
|
||||
"input_contract": "MetadataKeywordArguments",
|
||||
"input_contract": "SpecificImageRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "MetadataProviderResult",
|
||||
"result_shape": "any",
|
||||
"required_parameters": [
|
||||
"episode",
|
||||
"image_prefix",
|
||||
"image_type",
|
||||
"mediaid",
|
||||
"mtype",
|
||||
"season"
|
||||
],
|
||||
"result_contract": "str | None",
|
||||
"result_shape": "string",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
"timeout_policy": "caller_budget",
|
||||
@@ -5011,16 +5030,20 @@
|
||||
"version": 1
|
||||
},
|
||||
"recommend_name": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "metadata",
|
||||
"input_contract": "MetadataKeywordArguments",
|
||||
"input_contract": "RecommendNameRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "MetadataProviderResult",
|
||||
"result_shape": "any",
|
||||
"required_parameters": [
|
||||
"episodes_info",
|
||||
"mediainfo",
|
||||
"meta"
|
||||
],
|
||||
"result_contract": "str | None",
|
||||
"result_shape": "string",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
"timeout_policy": "caller_budget",
|
||||
@@ -5043,15 +5066,17 @@
|
||||
"version": 1
|
||||
},
|
||||
"refresh_userdata": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "site",
|
||||
"input_contract": "SiteKeywordArguments",
|
||||
"input_contract": "SiteUserDataRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "SiteProviderResult",
|
||||
"required_parameters": [
|
||||
"site"
|
||||
],
|
||||
"result_contract": "SiteUserData | None",
|
||||
"result_shape": "any",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
@@ -5116,16 +5141,18 @@
|
||||
"version": 1
|
||||
},
|
||||
"save_category_config": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "category",
|
||||
"input_contract": "CategoryKeywordArguments",
|
||||
"input_contract": "CategoryConfigWriteRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "CategoryProviderResult",
|
||||
"result_shape": "any",
|
||||
"required_parameters": [
|
||||
"config"
|
||||
],
|
||||
"result_contract": "bool | None",
|
||||
"result_shape": "boolean",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
"timeout_policy": "caller_budget",
|
||||
@@ -5247,16 +5274,18 @@
|
||||
"version": 1
|
||||
},
|
||||
"search_tvdb": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "ordered_list_merge",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "integration",
|
||||
"input_contract": "IntegrationKeywordArguments",
|
||||
"family": "tvdb",
|
||||
"input_contract": "TvdbSearchRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "IntegrationProviderResult",
|
||||
"result_shape": "any",
|
||||
"required_parameters": [
|
||||
"title"
|
||||
],
|
||||
"result_contract": "list[dict]",
|
||||
"result_shape": "list",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
"timeout_policy": "caller_budget",
|
||||
@@ -5315,16 +5344,18 @@
|
||||
"version": 1
|
||||
},
|
||||
"site_subtitle_links": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "ordered_list_merge",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "site",
|
||||
"input_contract": "SiteKeywordArguments",
|
||||
"input_contract": "SiteSubtitleLinksRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "SiteProviderResult",
|
||||
"result_shape": "any",
|
||||
"required_parameters": [
|
||||
"context"
|
||||
],
|
||||
"result_contract": "list[str]",
|
||||
"result_shape": "list",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
"timeout_policy": "caller_budget",
|
||||
@@ -5828,32 +5859,36 @@
|
||||
"version": 1
|
||||
},
|
||||
"tvdb_info": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "tvdb",
|
||||
"input_contract": "TvdbKeywordArguments",
|
||||
"input_contract": "TvdbInfoRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "TvdbProviderResult",
|
||||
"result_shape": "any",
|
||||
"required_parameters": [
|
||||
"tvdbid"
|
||||
],
|
||||
"result_contract": "dict | None",
|
||||
"result_shape": "mapping",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
"timeout_policy": "caller_budget",
|
||||
"version": 1
|
||||
},
|
||||
"tvdb_slug": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "tvdb",
|
||||
"input_contract": "TvdbKeywordArguments",
|
||||
"input_contract": "TvdbInfoRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "TvdbProviderResult",
|
||||
"result_shape": "any",
|
||||
"required_parameters": [
|
||||
"tvdbid"
|
||||
],
|
||||
"result_contract": "str | None",
|
||||
"result_shape": "string",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
"timeout_policy": "caller_budget",
|
||||
@@ -5922,15 +5957,17 @@
|
||||
"version": 1
|
||||
},
|
||||
"user_authenticate": {
|
||||
"aggregation": "legacy",
|
||||
"aggregation": "first_non_empty",
|
||||
"error_policy": "isolate_provider",
|
||||
"execution": "sync_or_async",
|
||||
"family": "authentication",
|
||||
"input_contract": "AuthenticationKeywordArguments",
|
||||
"input_contract": "UserAuthenticationRequest",
|
||||
"plugin_short_circuit": true,
|
||||
"public_to_plugins": true,
|
||||
"required_parameters": [],
|
||||
"result_contract": "AuthenticationResult",
|
||||
"required_parameters": [
|
||||
"credentials"
|
||||
],
|
||||
"result_contract": "AuthCredentials | None",
|
||||
"result_shape": "any",
|
||||
"supports_async": true,
|
||||
"supports_sync": true,
|
||||
|
||||
@@ -203,6 +203,34 @@ def test_storage_value_contracts_use_explicit_provider_semantics() -> None:
|
||||
assert media_files.required_parameters == ("mediainfo",)
|
||||
|
||||
|
||||
def test_lookup_contracts_separate_value_routes_from_list_aggregation() -> None:
|
||||
"""分类、站点、元数据、认证与 TVDB 查询应声明真实的值或列表语义。"""
|
||||
list_methods = {"site_subtitle_links", "search_tvdb"}
|
||||
value_methods = {
|
||||
"media_category",
|
||||
"load_category_config",
|
||||
"save_category_config",
|
||||
"get_search_page_size",
|
||||
"refresh_userdata",
|
||||
"metadata_img",
|
||||
"metadata_nfo",
|
||||
"obtain_specific_image",
|
||||
"recommend_name",
|
||||
"user_authenticate",
|
||||
"tvdb_info",
|
||||
"tvdb_slug",
|
||||
}
|
||||
|
||||
for method in list_methods:
|
||||
contract = get_module_method_contract(method)
|
||||
assert contract.aggregation is ModuleResultAggregation.ORDERED_LIST_MERGE
|
||||
assert contract.result_shape is ModuleResultShape.LIST
|
||||
for method in value_methods:
|
||||
contract = get_module_method_contract(method)
|
||||
assert contract.aggregation is ModuleResultAggregation.FIRST_NON_EMPTY
|
||||
assert contract.result_contract
|
||||
|
||||
|
||||
def test_heterogeneous_torrent_files_result_remains_legacy_compatible() -> None:
|
||||
"""下载器文件集合尚未归一前不得声明虚假的列表聚合语义。"""
|
||||
contract = get_module_method_contract("torrent_files")
|
||||
|
||||
Reference in New Issue
Block a user