refactor(core): reorganize superset-core packages into feature-based structure (#38448)

This commit is contained in:
Michael S. Molina
2026-03-05 17:41:15 -03:00
committed by GitHub
parent 5f0efd2be9
commit 357e35dc62
1182 changed files with 2468 additions and 2054 deletions

View File

@@ -23,7 +23,7 @@ sidebar_label: Alert
-->
import { StoryWithControls } from '../../../src/components/StorybookWrapper';
import { Alert } from '@apache-superset/core/ui';
import { Alert } from '@apache-superset/core/components';
# Alert
@@ -105,10 +105,10 @@ function Demo() {
## Usage in Extensions
This component is available in the `@apache-superset/core/ui` package, which is automatically available to Superset extensions.
This component is available in the `@apache-superset/core/components` package, which is automatically available to Superset extensions.
```tsx
import { Alert } from '@apache-superset/core/ui';
import { Alert } from '@apache-superset/core/components';
function MyExtension() {
return (

View File

@@ -25,7 +25,7 @@ sidebar_position: 1
# Extension Components
These UI components are available to Superset extension developers through the `@apache-superset/core/ui` package. They provide a consistent look and feel with the rest of Superset and are designed to be used in extension panels, views, and other UI elements.
These UI components are available to Superset extension developers through the `@apache-superset/core/components` package. They provide a consistent look and feel with the rest of Superset and are designed to be used in extension panels, views, and other UI elements.
## Available Components
@@ -33,10 +33,10 @@ These UI components are available to Superset extension developers through the `
## Usage
All components are exported from the `@apache-superset/core/ui` package:
All components are exported from the `@apache-superset/core/components` package:
```tsx
import { Alert } from '@apache-superset/core/ui';
import { Alert } from '@apache-superset/core/components';
export function MyExtensionPanel() {
return (
@@ -49,7 +49,7 @@ export function MyExtensionPanel() {
## Adding New Components
Components in `@apache-superset/core/ui` are automatically documented here. To add a new extension component:
Components in `@apache-superset/core/components` are automatically documented here. To add a new extension component:
1. Add the component to `superset-frontend/packages/superset-core/src/ui/components/`
2. Export it from `superset-frontend/packages/superset-core/src/ui/components/index.ts`

View File

@@ -118,7 +118,7 @@ Backend contribution types allow extensions to extend Superset's server-side cap
Extensions can register custom REST API endpoints under the `/extensions/` namespace. This dedicated namespace prevents conflicts with built-in endpoints and provides a clear separation between core and extension functionality.
```python
from superset_core.api.rest_api import RestApi, api
from superset_core.rest_api.api import RestApi, api
from flask_appbuilder.api import expose, protect
@api(

View File

@@ -70,8 +70,8 @@ import { someInternalFunction } from 'src/explore/components/SomeComponent';
```python
# ✅ Public API - stable
from superset_core.api.models import Database
from superset_core.api.daos import DatabaseDAO
from superset_core.common.models import Database
from superset_core.common.daos import DatabaseDAO
# ❌ Internal code - may break without notice
from superset.views.core import SomeInternalClass
@@ -117,7 +117,7 @@ Extension developers should depend on and use core libraries directly:
**Frontend (examples):**
- [React](https://react.dev/) - UI framework
- [Ant Design](https://ant.design/) - UI component library (prefer Superset components from `@apache-superset/core/ui` when available to preserve visual consistency)
- [Ant Design](https://ant.design/) - UI component library (prefer Superset components from `@apache-superset/core/components` when available to preserve visual consistency)
- [Emotion](https://emotion.sh/) - CSS-in-JS styling
- ...

View File

@@ -201,9 +201,9 @@ Backend APIs (via `apache-superset-core`) follow a similar pattern, providing ac
Extension endpoints are registered under a dedicated `/extensions` namespace to avoid conflicting with built-in endpoints and also because they don't share the same version constraints. By grouping all extension endpoints under `/extensions`, Superset establishes a clear boundary between core and extension functionality, making it easier to manage, document, and secure both types of APIs.
```python
from superset_core.api.models import Database, get_session
from superset_core.api.daos import DatabaseDAO
from superset_core.api.rest_api import RestApi, api
from superset_core.common.models import Database, get_session
from superset_core.common.daos import DatabaseDAO
from superset_core.rest_api.api import RestApi, api
from flask_appbuilder.api import expose, protect
@api(

View File

@@ -61,7 +61,7 @@ Prompts provide interactive guidance and context to AI agents. They help agents
The simplest way to create an MCP tool is using the `@tool` decorator:
```python
from superset_core.api.mcp import tool
from superset_core.mcp.decorators import tool
@tool
def hello_world() -> dict:
@@ -94,7 +94,7 @@ Here's a more comprehensive example showing best practices:
import random
from datetime import datetime, timezone
from pydantic import BaseModel, Field
from superset_core.api.mcp import tool
from superset_core.mcp.decorators import tool
class RandomNumberRequest(BaseModel):
"""Request schema for random number generation."""
@@ -253,7 +253,7 @@ The AI agent sees your tool's:
Create interactive prompts using the `@prompt` decorator:
```python
from superset_core.api.mcp import prompt
from superset_core.mcp.decorators import prompt
from fastmcp import Context
@prompt("my_extension.workflow_guide")

View File

@@ -43,7 +43,7 @@ Extensions can provide:
## UI Components for Extensions
Extension developers have access to pre-built UI components via `@apache-superset/core/ui`. Browse all available components on the [UI Components](/docs/components/) page and filter by **Extension Compatible** to see components available to extensions.
Extension developers have access to pre-built UI components via `@apache-superset/core/components`. Browse all available components on the [UI Components](/docs/components/) page and filter by **Extension Compatible** to see components available to extensions.
## Next Steps

View File

@@ -129,7 +129,7 @@ The CLI generated a basic `backend/src/superset_extensions/my_org/hello_world/en
```python
from flask import Response
from flask_appbuilder.api import expose, protect, safe
from superset_core.api.rest_api import RestApi, api
from superset_core.rest_api.api import RestApi, api
@api(
@@ -175,7 +175,7 @@ class HelloWorldAPI(RestApi):
**Key points:**
- Uses [`@api`](superset-core/src/superset_core/api/rest_api.py:59) decorator with automatic context detection
- Extends `RestApi` from `superset_core.api.rest_api`
- Extends `RestApi` from `superset_core.rest_api.api`
- Uses Flask-AppBuilder decorators (`@expose`, `@protect`, `@safe`)
- Returns responses using `self.response(status_code, result=data)`
- The endpoint will be accessible at `/extensions/my-org/hello-world/message` (automatic extension context)

View File

@@ -50,7 +50,7 @@ When GTF is considered stable, it will replace legacy Celery tasks for built-in
### Define a Task
```python
from superset_core.api.tasks import task, get_context
from superset_core.tasks.decorators import task, get_context
@task
def process_data(dataset_id: int) -> None:
@@ -245,7 +245,8 @@ Always implement an abort handler for long-running tasks. This allows users to c
Set a timeout to automatically abort tasks that run too long:
```python
from superset_core.api.tasks import task, get_context, TaskOptions
from superset_core.tasks.decorators import task, get_context
from superset_core.tasks.types import TaskOptions
# Set default timeout in decorator
@task(timeout=300) # 5 minutes
@@ -299,7 +300,7 @@ Timeouts require an abort handler to be effective. Without one, the timeout trig
Use `task_key` to prevent duplicate task execution:
```python
from superset_core.api.tasks import TaskOptions
from superset_core.tasks.types import TaskOptions
# Without key - creates new task each time (random UUID)
task1 = my_task.schedule(x=1)
@@ -331,7 +332,8 @@ print(task2.status) # "success" (terminal status)
## Task Scopes
```python
from superset_core.api.tasks import task, TaskScope
from superset_core.tasks.decorators import task
from superset_core.tasks.types import TaskScope
@task # Private by default
def private_task(): ...