This is an automated email from the ASF dual-hosted git repository. EnxDev pushed a commit to branch test/chatbot-local in repository https://gitbox.apache.org/repos/asf/superset.git
commit c4b9f7b6e549d67133b295224e9302860ab1aff7 Author: Enzo Martellucci <[email protected]> AuthorDate: Thu May 28 09:29:33 2026 +0200 fix(extensions): fully remove dataset namespace — SDK contract and orphaned host impl The host removed dataset from window.superset but the SDK still exported the typed contract. An extension importing dataset from @apache-superset/core would get a fully typed namespace whose runtime calls throw at access time, which is worse than not shipping it. Removes: - packages/superset-core/src/dataset/index.ts (SDK type declarations) - export * as dataset from './dataset' in superset-core/src/index.ts - "./dataset" subpath from superset-core/package.json exports - src/core/dataset/index.ts (orphaned host implementation) The namespace will be re-introduced once a producer (DatasetCreation or equivalent) calls setCurrentDataset to back the contract at runtime. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --- .../packages/superset-core/package.json | 4 -- .../packages/superset-core/src/dataset/index.ts | 73 ---------------------- .../packages/superset-core/src/index.ts | 1 - superset-frontend/src/core/dataset/index.ts | 62 ------------------ 4 files changed, 140 deletions(-) diff --git a/superset-frontend/packages/superset-core/package.json b/superset-frontend/packages/superset-core/package.json index 0fd06f79a62..42112829336 100644 --- a/superset-frontend/packages/superset-core/package.json +++ b/superset-frontend/packages/superset-core/package.json @@ -22,10 +22,6 @@ "types": "./lib/dashboard/index.d.ts", "default": "./lib/dashboard/index.js" }, - "./dataset": { - "types": "./lib/dataset/index.d.ts", - "default": "./lib/dataset/index.js" - }, "./explore": { "types": "./lib/explore/index.d.ts", "default": "./lib/explore/index.js" diff --git a/superset-frontend/packages/superset-core/src/dataset/index.ts b/superset-frontend/packages/superset-core/src/dataset/index.ts deleted file mode 100644 index ea3fafa4fdb..00000000000 --- a/superset-frontend/packages/superset-core/src/dataset/index.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * 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. - */ - -/** - * @fileoverview Dataset namespace for Superset extensions (P3). - * - * Exposes the dataset currently being viewed as a stable semantic API. - * Aligned with backend-enforced dataset visibility and column-access semantics. - */ - -import { Event } from '../common'; - -/** - * Normalized dataset context exposed to extensions on the Dataset page. - */ -export interface DatasetContext { - /** Numeric dataset id. */ - datasetId: number; - /** Display name (table name or virtual dataset name). */ - datasetName: string; - /** Schema the dataset belongs to, if applicable. */ - schema: string | null; - /** Catalog the dataset belongs to, if applicable. */ - catalog: string | null; - /** Database name backing this dataset. */ - databaseName: string | null; - /** Whether this is a virtual (SQL-defined) dataset. */ - isVirtual: boolean; -} - -/** - * Returns the normalized dataset context for the page currently being viewed, - * or `undefined` when the user is not on a Dataset page. - * - * @example - * ```typescript - * const ds = dataset.getCurrentDataset(); - * if (ds) { - * console.log(ds.datasetName, ds.schema); - * } - * ``` - */ -export declare function getCurrentDataset(): DatasetContext | undefined; - -/** - * Event fired when the focused dataset changes (e.g. the user navigates to a - * different dataset detail page). - * - * @example - * ```typescript - * const sub = dataset.onDidChangeDataset(ds => { - * chatbot.updateContext({ dataset: ds }); - * }); - * sub.dispose(); - * ``` - */ -export declare const onDidChangeDataset: Event<DatasetContext>; diff --git a/superset-frontend/packages/superset-core/src/index.ts b/superset-frontend/packages/superset-core/src/index.ts index 79c699caff4..1ac169a9ad5 100644 --- a/superset-frontend/packages/superset-core/src/index.ts +++ b/superset-frontend/packages/superset-core/src/index.ts @@ -20,7 +20,6 @@ export * as common from './common'; export * as authentication from './authentication'; export * as commands from './commands'; export * as dashboard from './dashboard'; -export * as dataset from './dataset'; export * as editors from './editors'; export * as explore from './explore'; export * as extensions from './extensions'; diff --git a/superset-frontend/src/core/dataset/index.ts b/superset-frontend/src/core/dataset/index.ts deleted file mode 100644 index 3c98d79454b..00000000000 --- a/superset-frontend/src/core/dataset/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * 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. - */ - -/** - * Host-internal implementation of the `dataset` namespace. - * - * Dataset page components call `setCurrentDataset` to publish context as they - * load. Extensions consume the stable `DatasetContext` contract; they are - * isolated from the page's internal data-fetching implementation. - */ - -import type { dataset as datasetApi } from '@apache-superset/core'; -import { Disposable } from '../models'; - -type DatasetContext = datasetApi.DatasetContext; - -let currentDataset: DatasetContext | undefined; -const listeners = new Set<(ctx: DatasetContext) => void>(); - -/** - * Host-internal: called by the Dataset page when its entity loads or changes. - * Not part of the public `@apache-superset/core` API. - */ -export const setCurrentDataset = (ctx: DatasetContext | undefined): void => { - currentDataset = ctx; - if (ctx) { - listeners.forEach(fn => fn(ctx)); - } -}; - -const getCurrentDataset: typeof datasetApi.getCurrentDataset = () => - currentDataset ? { ...currentDataset } : undefined; - -const onDidChangeDataset: typeof datasetApi.onDidChangeDataset = ( - listener: (ctx: DatasetContext) => void, - thisArgs?: any, -): Disposable => { - const bound = thisArgs ? listener.bind(thisArgs) : listener; - listeners.add(bound); - return new Disposable(() => listeners.delete(bound)); -}; - -export const dataset: typeof datasetApi = { - getCurrentDataset, - onDidChangeDataset, -};
