tree: ecb577efd5cffc00a075d7c3ae0cb541a585f5e4 [path history] [tgz]
  1. src/
  2. .babelrc.json
  3. CHANGELOG.md
  4. package.json
  5. README.md
  6. tsconfig.json
superset-frontend/packages/superset-core/README.md

@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

🏗️ Architecture

The package is organized into logical namespaces, each providing specific functionality:

  • authentication - User authentication and authorization APIs
  • commands - Command registration and execution system
  • contributions - UI contribution points and customization APIs
  • core - Fundamental types, utilities, and lifecycle management
  • environment - Environment detection and configuration APIs
  • extensions - Extension management and metadata APIs
  • sqlLab - SQL Lab integration and event handling

🚀 Quick Start

Basic Extension Structure

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

export function activate(context: core.ExtensionContext) {
  // Register a command to save current query
  const commandDisposable = commands.registerCommand(
    'my_extension.save_query',
    async () => {
      const currentTab = sqlLab.getCurrentTab();
      if (currentTab?.editor.content) {
        const token = await authentication.getCSRFToken();
        // Use token for secure API calls
        console.log('Saving query with CSRF token:', token);
      }
    },
  );

  // Listen for query execution events
  const eventDisposable = sqlLab.onDidQueryRun(editor => {
    console.log('Query executed:', editor.content.substring(0, 50) + '...');
  });

  // Register a simple view
  const viewDisposable = core.registerViewProvider(
    'my_extension.panel',
    () => (
      <div>
        <h3>My Extension</h3>
        <button onClick={() => commands.executeCommand('my_extension.save_query')}>
          Save Query
        </button>
      </div>
    )
  );

  // Cleanup registration
  context.subscriptions.push(commandDisposable, eventDisposable, viewDisposable);
}

export function deactivate() {
  // Cleanup handled automatically via disposables
}

🤝 Contributing

We welcome contributions! Please see the Contributing Guide for details.

📄 License

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

🔗 Links


Note: This package is currently in release candidate status. APIs may change before the 1.0.0 release. Please check the changelog for breaking changes between versions.