mirror of
https://github.com/langgenius/dify.git
synced 2026-09-24 23:22:26 +08:00
refactor(web): migrate plugin console contracts (#38252)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
autofix-ci[bot]
parent
6eb9928df7
commit
37bcb60c26
@@ -319,7 +319,7 @@ class PluginInstallationItemResponse(ResponseModel):
|
||||
plugin_unique_identifier: str
|
||||
version: str
|
||||
checksum: str
|
||||
declaration: Mapping[str, Any]
|
||||
declaration: PluginDeclarationResponse
|
||||
|
||||
|
||||
class PluginInstallationsResponse(ResponseModel):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any
|
||||
from typing import Any, Literal
|
||||
|
||||
from pydantic import BaseModel, Field, computed_field, model_validator
|
||||
|
||||
@@ -32,7 +32,9 @@ class MarketplacePluginDeclaration(BaseModel):
|
||||
latest_package_identifier: str = Field(
|
||||
..., description="Unique identifier for the latest package release of the plugin"
|
||||
)
|
||||
status: str = Field(..., description="Indicate the status of marketplace plugin, enum from `active` `deleted`")
|
||||
status: Literal["active", "deleted"] = Field(
|
||||
..., description="Indicate the status of marketplace plugin, enum from `active` `deleted`"
|
||||
)
|
||||
deprecated_reason: str = Field(
|
||||
..., description="Not empty when status='deleted', indicates the reason why this plugin is deleted(deprecated)"
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ import logging
|
||||
import time
|
||||
from collections.abc import Mapping, Sequence
|
||||
from mimetypes import guess_type
|
||||
from typing import Any, ClassVar
|
||||
from typing import Any, ClassVar, Literal
|
||||
|
||||
from pydantic import BaseModel, TypeAdapter, ValidationError
|
||||
from redis import RedisError
|
||||
@@ -75,7 +75,7 @@ class PluginService:
|
||||
plugin_id: str
|
||||
version: str
|
||||
unique_identifier: str
|
||||
status: str
|
||||
status: Literal["active", "deleted"]
|
||||
deprecated_reason: str
|
||||
alternative_plugin_id: str
|
||||
|
||||
|
||||
@@ -18093,7 +18093,7 @@ Enum class for large language model mode.
|
||||
| alternative_plugin_id | string | | Yes |
|
||||
| deprecated_reason | string | | Yes |
|
||||
| plugin_id | string | | Yes |
|
||||
| status | string | | Yes |
|
||||
| status | string, <br>**Available values:** "active", "deleted" | *Enum:* `"active"`, `"deleted"` | Yes |
|
||||
| unique_identifier | string | | Yes |
|
||||
| version | string | | Yes |
|
||||
|
||||
@@ -19590,7 +19590,7 @@ Shared permission levels for resources (datasets, credentials, etc.)
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| checksum | string | | Yes |
|
||||
| created_at | dateTime | | Yes |
|
||||
| declaration | object | | Yes |
|
||||
| declaration | [PluginDeclarationResponse](#plugindeclarationresponse) | | Yes |
|
||||
| endpoints_active | integer | | Yes |
|
||||
| endpoints_setups | integer | | Yes |
|
||||
| id | string | | Yes |
|
||||
|
||||
@@ -42,6 +42,7 @@ from controllers.console.workspace.plugin import (
|
||||
PluginUploadFromGithubApi,
|
||||
PluginUploadFromPkgApi,
|
||||
)
|
||||
from core.plugin.entities.plugin import PluginInstallation
|
||||
from core.plugin.impl.exc import PluginDaemonClientSideError
|
||||
from models.account import Account, TenantAccountRole, TenantPluginAutoUpgradeStrategy, TenantPluginPermission
|
||||
|
||||
@@ -478,12 +479,23 @@ class TestPluginListInstallationsFromIdsApi:
|
||||
app.test_request_context("/", json=payload),
|
||||
patch(
|
||||
"controllers.console.workspace.plugin.PluginService.list_installations_from_ids",
|
||||
return_value=[{"id": "p1"}],
|
||||
return_value=[PluginInstallation.model_validate(_plugin_category_list_item())],
|
||||
),
|
||||
):
|
||||
result = method(api, "t1")
|
||||
|
||||
assert "plugins" in result
|
||||
assert result["plugins"][0]["id"] == "entity-1"
|
||||
assert result["plugins"][0]["plugin_id"] == "test-author/test-plugin"
|
||||
assert result["plugins"][0]["plugin_unique_identifier"] == "test-author/test-plugin:1.0.0@checksum"
|
||||
assert result["plugins"][0]["version"] == "1.0.0"
|
||||
assert result["plugins"][0]["declaration"]["name"] == "test-plugin"
|
||||
assert "name" not in result["plugins"][0]
|
||||
assert "installation_id" not in result["plugins"][0]
|
||||
assert "latest_version" not in result["plugins"][0]
|
||||
assert "latest_unique_identifier" not in result["plugins"][0]
|
||||
assert "status" not in result["plugins"][0]
|
||||
assert "deprecated_reason" not in result["plugins"][0]
|
||||
assert "alternative_plugin_id" not in result["plugins"][0]
|
||||
|
||||
def test_daemon_error(self, app: Flask):
|
||||
api = PluginListInstallationsFromIdsApi()
|
||||
|
||||
Reference in New Issue
Block a user