Back to Superset

@apache-superset/core

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

2021.41.03.5 KB
Original Source
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->

@apache-superset/core

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

bash
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:

tsx
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:

typescript
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 */
  },
);

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

typescript
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:

typescript
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.