- 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>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""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,
|
|
})
|