Plugin system: fix PluginMeta core_version default + add /api/plugins
- PluginMeta.core_version defaulted to >=1.0.0, which would reject the current 0.2.0 framework for any plugin relying on the default. Set to >=0.2.0,<1.0.0. - Add GET /api/plugins introspection: lists loaded plugins (name, version, core_version, api_prefix, dependencies) + the framework contract version. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -80,6 +80,7 @@ CORE_BLUEPRINT_NAMES = (
|
|||||||
'auth',
|
'auth',
|
||||||
'assets',
|
'assets',
|
||||||
'machinetypes',
|
'machinetypes',
|
||||||
|
'plugins',
|
||||||
'vendors',
|
'vendors',
|
||||||
'models',
|
'models',
|
||||||
'businessunits',
|
'businessunits',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
from .auth import auth_bp
|
from .auth import auth_bp
|
||||||
from .assets import assets_bp
|
from .assets import assets_bp
|
||||||
from .machinetypes import machinetypes_bp
|
from .machinetypes import machinetypes_bp
|
||||||
|
from .plugins import plugins_bp
|
||||||
from .vendors import vendors_bp
|
from .vendors import vendors_bp
|
||||||
from .models import models_bp
|
from .models import models_bp
|
||||||
from .businessunits import businessunits_bp
|
from .businessunits import businessunits_bp
|
||||||
@@ -24,6 +25,7 @@ __all__ = [
|
|||||||
'auth_bp',
|
'auth_bp',
|
||||||
'assets_bp',
|
'assets_bp',
|
||||||
'machinetypes_bp',
|
'machinetypes_bp',
|
||||||
|
'plugins_bp',
|
||||||
'vendors_bp',
|
'vendors_bp',
|
||||||
'models_bp',
|
'models_bp',
|
||||||
'businessunits_bp',
|
'businessunits_bp',
|
||||||
|
|||||||
37
shopdb/core/api/plugins.py
Normal file
37
shopdb/core/api/plugins.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
"""Plugin introspection API - what plugins are loaded and their contracts."""
|
||||||
|
|
||||||
|
from flask import Blueprint, current_app
|
||||||
|
from flask_jwt_extended import jwt_required
|
||||||
|
|
||||||
|
from shopdb.utils.responses import success_response
|
||||||
|
|
||||||
|
plugins_bp = Blueprint('plugins', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@plugins_bp.route('', methods=['GET'])
|
||||||
|
@jwt_required(optional=True)
|
||||||
|
def list_plugins():
|
||||||
|
"""List loaded plugins with their manifest metadata + the framework
|
||||||
|
contract version they were checked against."""
|
||||||
|
from shopdb import __contract_version__
|
||||||
|
pm = current_app.extensions.get('plugin_manager')
|
||||||
|
plugins = []
|
||||||
|
if pm:
|
||||||
|
for name, plugin in pm.get_all_plugins().items():
|
||||||
|
meta = plugin.meta
|
||||||
|
plugins.append({
|
||||||
|
'name': meta.name,
|
||||||
|
'version': meta.version,
|
||||||
|
'description': meta.description,
|
||||||
|
'author': meta.author,
|
||||||
|
'core_version': meta.core_version,
|
||||||
|
'api_prefix': meta.api_prefix,
|
||||||
|
'dependencies': meta.dependencies,
|
||||||
|
})
|
||||||
|
plugins.sort(key=lambda p: p['name'])
|
||||||
|
|
||||||
|
return success_response({
|
||||||
|
'contract_version': __contract_version__,
|
||||||
|
'count': len(plugins),
|
||||||
|
'plugins': plugins,
|
||||||
|
})
|
||||||
@@ -15,7 +15,8 @@ class PluginMeta:
|
|||||||
description: str
|
description: str
|
||||||
author: str = ""
|
author: str = ""
|
||||||
dependencies: List[str] = field(default_factory=list)
|
dependencies: List[str] = field(default_factory=list)
|
||||||
core_version: str = ">=1.0.0"
|
# Default to the current pre-1.0 contract range; tighten when 1.0 lands
|
||||||
|
core_version: str = ">=0.2.0,<1.0.0"
|
||||||
api_prefix: str = None
|
api_prefix: str = None
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user