Files
superset2/superset-frontend/packages/superset-core/README.md

3.5 KiB

@apache-superset/core

npm version License

The official core package for building Apache Superset extensions and integrations. This package provides essential building blocks including shared UI components, utility functions, APIs, and type definitions for both the host application and extensions.

📦 Installation

npm install @apache-superset/core

🏗️ Package Structure

The source is organized into focused namespaces, each in its own directory:

src/
├── authentication/
├── commands/
├── common/
├── components/
├── contributions/
├── editors/
├── extensions/
├── menus/
├── sqlLab/
├── theme/
├── translation/
├── utils/
├── views/
└── index.ts

🚀 Quick Start

Frontend contributions are registered as module-level side effects from your extension's entry point.

Views

Add custom panels or UI components at specific locations in the application:

import { views } from '@apache-superset/core';
import MyPanel from './MyPanel';

views.registerView(
  { id: 'my-extension.main', name: 'My Panel Name' },
  'sqllab.panels',
  () => <MyPanel />,
);

Commands

Define named actions that can be triggered from menus, keyboard shortcuts, or code:

import { commands } from '@apache-superset/core';

commands.registerCommand(
  {
    id: 'my-extension.copy-query',
    title: 'Copy Query',
    icon: 'CopyOutlined',
    description: 'Copy the current query to clipboard',
  },
  () => {
    /* implementation */
  },
);

Menus

Attach commands to primary, secondary, or context menus at a given location:

import { menus } from '@apache-superset/core';

menus.registerMenuItem(
  { view: 'sqllab.editor', command: 'my-extension.copy-query' },
  'sqllab.editor',
  'primary',
);

Editors

Replace the default text editor for one or more languages:

import { editors } from '@apache-superset/core';
import MonacoSQLEditor from './MonacoSQLEditor';

editors.registerEditor(
  {
    id: 'my-extension.monaco-sql',
    name: 'Monaco SQL Editor',
    languages: ['sql'],
  },
  MonacoSQLEditor,
);

📄 License

Licensed under the Apache License, Version 2.0. See LICENSE for details.