Compare commits

...

8 Commits

Author SHA1 Message Date
-LAN-
864878e689 Merge branch 'main' into wife 2025-09-29 18:18:55 +08:00
-LAN-
3f7abc7407 Merge branch 'main' into wife 2025-09-28 17:50:11 +08:00
-LAN-
bff909279a Merge branch 'main' into wife 2025-09-13 01:27:20 +08:00
-LAN-
7d95eeae43 Merge branch 'main' into wife 2025-09-10 12:28:11 +08:00
-LAN-
d7dd6aa57a Merge branch 'main' into wife 2025-09-10 03:22:10 +08:00
-LAN-
e48d5f78e9 Merge branch 'main' into wife 2025-09-09 13:33:07 +08:00
-LAN-
d5509faf48 feat: simplify marketplace plugin identifier format in DSL export 2025-09-04 01:09:55 +08:00
-LAN-
e5ad372df9 feat: simplify marketplace plugin identifier format
- Drop checksum from marketplace_plugin_unique_identifier
- Use simpler org/name:version format instead of org/name:version@checksum
- Update download endpoint to /api/v1/plugins/{org}/{name}/{version}/download
- Maintain backward compatibility by stripping checksums when present
2025-09-04 01:09:55 +08:00
5 changed files with 56 additions and 16 deletions

View File

@@ -11,6 +11,20 @@ marketplace_api_url = URL(str(dify_config.MARKETPLACE_API_URL))
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))

View File

@@ -182,6 +182,9 @@ class PluginDependency(BaseModel):
@property
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
class Package(BaseModel):

View File

@@ -600,12 +600,18 @@ class AppDslService:
export_data["workflow"] = workflow_dict
dependencies = cls._extract_dependencies_from_workflow(workflow)
export_data["dependencies"] = [
jsonable_encoder(d.model_dump())
for d in DependenciesAnalysisService.generate_dependencies(
tenant_id=app_model.tenant_id, dependencies=dependencies
)
]
dependencies_list = 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
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
dependencies = cls._extract_dependencies_from_model_config(app_model_config.to_dict())
export_data["dependencies"] = [
jsonable_encoder(d.model_dump())
for d in DependenciesAnalysisService.generate_dependencies(
tenant_id=app_model.tenant_id, dependencies=dependencies
)
]
dependencies_list = 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
def _extract_dependencies_from_workflow(cls, workflow: Workflow) -> list[str]:

View File

@@ -42,9 +42,11 @@ const InstallByDSLList = ({
// 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 dependecy = (d as GitHubItemAndMarketPlaceDependency).value
// split org, name, version by / and :
// and remove @ and its suffix
const [orgPart, nameAndVersionPart] = dependecy.marketplace_plugin_unique_identifier!.split('@')[0].split('/')
// Parse org/name:version format (checksum already removed by backend)
const identifier = dependecy.marketplace_plugin_unique_identifier!
// 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(':')
return {
organization: orgPart,
@@ -110,7 +112,13 @@ const InstallByDSLList = ({
if (!isFetchingMarketplaceDataById && infoGetById?.data.list) {
const sortedList = allPlugins.filter(d => d.type === 'marketplace').map((d) => {
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
return { ...retPluginInfo, from: d.type } as Plugin
})

View File

@@ -288,6 +288,9 @@ export const useInstallOrUpdate = ({
if (item.type === 'marketplace') {
const data = item as GitHubItemAndMarketPlaceDependency
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) {
return {
success: true,