mirror of
https://github.com/langgenius/dify.git
synced 2025-12-22 23:37:26 +00:00
Compare commits
8 Commits
refactor/u
...
wife
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
864878e689 | ||
|
|
3f7abc7407 | ||
|
|
bff909279a | ||
|
|
7d95eeae43 | ||
|
|
d7dd6aa57a | ||
|
|
e48d5f78e9 | ||
|
|
d5509faf48 | ||
|
|
e5ad372df9 |
@@ -11,6 +11,20 @@ marketplace_api_url = URL(str(dify_config.MARKETPLACE_API_URL))
|
|||||||
|
|
||||||
|
|
||||||
def get_plugin_pkg_url(plugin_unique_identifier: str) -> str:
|
def get_plugin_pkg_url(plugin_unique_identifier: str) -> str:
|
||||||
|
# Parse org/name:version format (without checksum)
|
||||||
|
if "/" in plugin_unique_identifier and ":" in plugin_unique_identifier:
|
||||||
|
# Remove checksum if present (format: org/name:version@checksum)
|
||||||
|
if "@" in plugin_unique_identifier:
|
||||||
|
plugin_unique_identifier = plugin_unique_identifier.split("@")[0]
|
||||||
|
|
||||||
|
# Parse org/name:version
|
||||||
|
org_and_name, version = plugin_unique_identifier.rsplit(":", 1)
|
||||||
|
org, name = org_and_name.split("/", 1)
|
||||||
|
|
||||||
|
# Use new endpoint format
|
||||||
|
return str(marketplace_api_url / f"api/v1/plugins/{org}/{name}/{version}/download")
|
||||||
|
|
||||||
|
# Fallback to old format with query param
|
||||||
return str((marketplace_api_url / "api/v1/plugins/download").with_query(unique_identifier=plugin_unique_identifier))
|
return str((marketplace_api_url / "api/v1/plugins/download").with_query(unique_identifier=plugin_unique_identifier))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -182,6 +182,9 @@ class PluginDependency(BaseModel):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def plugin_unique_identifier(self) -> str:
|
def plugin_unique_identifier(self) -> str:
|
||||||
|
# Strip checksum if present (format: org/name:version@checksum -> org/name:version)
|
||||||
|
if "@" in self.marketplace_plugin_unique_identifier:
|
||||||
|
return self.marketplace_plugin_unique_identifier.split("@")[0]
|
||||||
return self.marketplace_plugin_unique_identifier
|
return self.marketplace_plugin_unique_identifier
|
||||||
|
|
||||||
class Package(BaseModel):
|
class Package(BaseModel):
|
||||||
|
|||||||
@@ -600,12 +600,18 @@ class AppDslService:
|
|||||||
|
|
||||||
export_data["workflow"] = workflow_dict
|
export_data["workflow"] = workflow_dict
|
||||||
dependencies = cls._extract_dependencies_from_workflow(workflow)
|
dependencies = cls._extract_dependencies_from_workflow(workflow)
|
||||||
export_data["dependencies"] = [
|
dependencies_list = DependenciesAnalysisService.generate_dependencies(
|
||||||
jsonable_encoder(d.model_dump())
|
tenant_id=app_model.tenant_id, dependencies=dependencies
|
||||||
for d in DependenciesAnalysisService.generate_dependencies(
|
)
|
||||||
tenant_id=app_model.tenant_id, dependencies=dependencies
|
# Clean marketplace plugin identifiers by removing checksums
|
||||||
)
|
export_dependencies = []
|
||||||
]
|
for d in dependencies_list:
|
||||||
|
dep_dict = d.model_dump()
|
||||||
|
if d.type == PluginDependency.Type.Marketplace:
|
||||||
|
# Use the property that strips checksum instead of raw value
|
||||||
|
dep_dict["value"]["marketplace_plugin_unique_identifier"] = d.value.plugin_unique_identifier
|
||||||
|
export_dependencies.append(jsonable_encoder(dep_dict))
|
||||||
|
export_data["dependencies"] = export_dependencies
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _append_model_config_export_data(cls, export_data: dict, app_model: App):
|
def _append_model_config_export_data(cls, export_data: dict, app_model: App):
|
||||||
@@ -628,12 +634,18 @@ class AppDslService:
|
|||||||
export_data["model_config"] = model_config
|
export_data["model_config"] = model_config
|
||||||
|
|
||||||
dependencies = cls._extract_dependencies_from_model_config(app_model_config.to_dict())
|
dependencies = cls._extract_dependencies_from_model_config(app_model_config.to_dict())
|
||||||
export_data["dependencies"] = [
|
dependencies_list = DependenciesAnalysisService.generate_dependencies(
|
||||||
jsonable_encoder(d.model_dump())
|
tenant_id=app_model.tenant_id, dependencies=dependencies
|
||||||
for d in DependenciesAnalysisService.generate_dependencies(
|
)
|
||||||
tenant_id=app_model.tenant_id, dependencies=dependencies
|
# Clean marketplace plugin identifiers by removing checksums
|
||||||
)
|
export_dependencies = []
|
||||||
]
|
for d in dependencies_list:
|
||||||
|
dep_dict = d.model_dump()
|
||||||
|
if d.type == PluginDependency.Type.Marketplace:
|
||||||
|
# Use the property that strips checksum instead of raw value
|
||||||
|
dep_dict["value"]["marketplace_plugin_unique_identifier"] = d.value.plugin_unique_identifier
|
||||||
|
export_dependencies.append(jsonable_encoder(dep_dict))
|
||||||
|
export_data["dependencies"] = export_dependencies
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _extract_dependencies_from_workflow(cls, workflow: Workflow) -> list[str]:
|
def _extract_dependencies_from_workflow(cls, workflow: Workflow) -> list[str]:
|
||||||
|
|||||||
@@ -42,9 +42,11 @@ const InstallByDSLList = ({
|
|||||||
// DSL has id, to get plugin info to show more info
|
// DSL has id, to get plugin info to show more info
|
||||||
const { isLoading: isFetchingMarketplaceDataById, data: infoGetById, error: infoByIdError } = useFetchPluginsInMarketPlaceByInfo(allPlugins.filter(d => d.type === 'marketplace').map((d) => {
|
const { isLoading: isFetchingMarketplaceDataById, data: infoGetById, error: infoByIdError } = useFetchPluginsInMarketPlaceByInfo(allPlugins.filter(d => d.type === 'marketplace').map((d) => {
|
||||||
const dependecy = (d as GitHubItemAndMarketPlaceDependency).value
|
const dependecy = (d as GitHubItemAndMarketPlaceDependency).value
|
||||||
// split org, name, version by / and :
|
// Parse org/name:version format (checksum already removed by backend)
|
||||||
// and remove @ and its suffix
|
const identifier = dependecy.marketplace_plugin_unique_identifier!
|
||||||
const [orgPart, nameAndVersionPart] = dependecy.marketplace_plugin_unique_identifier!.split('@')[0].split('/')
|
// Remove checksum if still present (for backward compatibility)
|
||||||
|
const cleanIdentifier = identifier.includes('@') ? identifier.split('@')[0] : identifier
|
||||||
|
const [orgPart, nameAndVersionPart] = cleanIdentifier.split('/')
|
||||||
const [name, version] = nameAndVersionPart.split(':')
|
const [name, version] = nameAndVersionPart.split(':')
|
||||||
return {
|
return {
|
||||||
organization: orgPart,
|
organization: orgPart,
|
||||||
@@ -110,7 +112,13 @@ const InstallByDSLList = ({
|
|||||||
if (!isFetchingMarketplaceDataById && infoGetById?.data.list) {
|
if (!isFetchingMarketplaceDataById && infoGetById?.data.list) {
|
||||||
const sortedList = allPlugins.filter(d => d.type === 'marketplace').map((d) => {
|
const sortedList = allPlugins.filter(d => d.type === 'marketplace').map((d) => {
|
||||||
const p = d as GitHubItemAndMarketPlaceDependency
|
const p = d as GitHubItemAndMarketPlaceDependency
|
||||||
const id = p.value.marketplace_plugin_unique_identifier?.split(':')[0]
|
// Parse org/name from org/name:version format
|
||||||
|
let identifier = p.value.marketplace_plugin_unique_identifier || ''
|
||||||
|
// Remove checksum if present
|
||||||
|
if (identifier.includes('@'))
|
||||||
|
identifier = identifier.split('@')[0]
|
||||||
|
// Get org/name part (without version)
|
||||||
|
const id = identifier.split(':')[0]
|
||||||
const retPluginInfo = infoGetById.data.list.find(item => item.plugin.plugin_id === id)?.plugin
|
const retPluginInfo = infoGetById.data.list.find(item => item.plugin.plugin_id === id)?.plugin
|
||||||
return { ...retPluginInfo, from: d.type } as Plugin
|
return { ...retPluginInfo, from: d.type } as Plugin
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -288,6 +288,9 @@ export const useInstallOrUpdate = ({
|
|||||||
if (item.type === 'marketplace') {
|
if (item.type === 'marketplace') {
|
||||||
const data = item as GitHubItemAndMarketPlaceDependency
|
const data = item as GitHubItemAndMarketPlaceDependency
|
||||||
uniqueIdentifier = data.value.marketplace_plugin_unique_identifier! || plugin[i]?.plugin_id
|
uniqueIdentifier = data.value.marketplace_plugin_unique_identifier! || plugin[i]?.plugin_id
|
||||||
|
// Strip checksum if present (for backward compatibility)
|
||||||
|
if (uniqueIdentifier.includes('@'))
|
||||||
|
uniqueIdentifier = uniqueIdentifier.split('@')[0]
|
||||||
if (uniqueIdentifier === installedPayload?.uniqueIdentifier) {
|
if (uniqueIdentifier === installedPayload?.uniqueIdentifier) {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user