You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rusackas (via GitHub)" <gi...@apache.org> on 2026/04/09 17:17:32 UTC

[PR] feat(extensions): expose Superset categorical color schemes to extensions [superset]

rusackas opened a new pull request, #39226:
URL: https://github.com/apache/superset/pull/39226

   ## Summary
   
   - Adds a `colors` module to `@apache-superset/core` exposing the host app's registered categorical color palettes to extensions
   - `ExtensionsStartup` injects the live `CategoricalSchemeRegistry` singleton at startup via `registerCategoricalSchemeRegistry()`
   - Extensions call `colors.getCategoricalSchemeNames()` / `colors.getSchemeColors(name)` through the federated module — same singleton, so all palettes registered by the host (Superset defaults, custom themes) are visible
   
   This is a prerequisite for the Notebook extension's Mermaid palette selector, which lets users pick any Superset color scheme to drive Mermaid pie/diagram fills instead of a hardcoded fallback palette.
   
   **Note:** This PR is intended to merge after apache/superset#39171 (Tier 1+2 storage) lands, since both touch `ExtensionsStartup.tsx` and `superset-core/src/index.ts`.
   
   ## Before/After
   
   **Before:** Extensions had no way to access Superset's color palettes; the notebook extension used a hardcoded 8-color AntD palette for Mermaid diagrams.
   
   **After:** Extensions can enumerate and read any registered Superset categorical color scheme. The Notebook extension shows a palette selector in the Mermaid cell header.
   
   ## Test plan
   
   - [ ] `superset-core` builds cleanly (`npm run build` in `packages/superset-core`)
   - [ ] Pre-commit passes on changed files
   - [ ] `colors.getCategoricalSchemeNames()` returns an array of scheme names from within an extension
   - [ ] `colors.getSchemeColors('supersetColors')` returns the expected hex array
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "sha174n (via GitHub)" <gi...@apache.org>.
sha174n commented on PR #39226:
URL: https://github.com/apache/superset/pull/39226#issuecomment-5281444040

   Clean federated-module boundary, and keeping palette data single-sourced in @superset-ui/core is the right call (follows the established declare-in-contract + host-provides-runtime pattern). One note: the title says "single source of truth for color palettes" but the surface currently only bridges categorical schemes (getCategoricalSchemeNames / getSchemeColors) — sequential/diverging registries aren't exposed yet, despite SequentialSchemeConfig being exported. Either narrow the title or note it as follow-up. Minor: CategoricalSchemeRegistryLike is a hand-mirrored subset cast via `as`, which would hide drift if the upstream registry surface changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3492473406


##########
superset-frontend/packages/superset-core/src/theme/index.tsx:
##########
@@ -88,3 +88,17 @@ export type {
 // Export theme utility functions
 export * from './utils/themeUtils';
 export * from './utils';
+
+// Color scheme API — types, enum, and declare-function bridge for extensions.
+// The host app provides the runtime implementations on window.superset.theme.
+export type {

Review Comment:
   We can use the `export *` approach as the above code.



##########
superset-frontend/packages/superset-core/src/theme/colors.ts:
##########
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+/**
+ * Grouping/tier for a color scheme — controls how it appears in the
+ * scheme picker UI (e.g. Featured palettes are shown first).
+ *
+ * Mirrors @superset-ui/core's ColorSchemeGroup; kept here so
+ * palette configs have no dependency on @superset-ui/core.
+ */
+export enum ColorSchemeGroup {
+  Custom = 'custom',
+  Featured = 'featured',
+  Other = 'other',
+}
+
+/** Plain configuration object for a categorical color scheme. */
+export interface ColorSchemeConfig {

Review Comment:
   Should this be named `CategoricalScheme` based on its comment? Then we could remove the `CategoricalScheme` below.



##########
superset-frontend/packages/superset-core/src/theme/colors.ts:
##########
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+/**
+ * Grouping/tier for a color scheme — controls how it appears in the
+ * scheme picker UI (e.g. Featured palettes are shown first).
+ *
+ * Mirrors @superset-ui/core's ColorSchemeGroup; kept here so
+ * palette configs have no dependency on @superset-ui/core.
+ */
+export enum ColorSchemeGroup {
+  Custom = 'custom',
+  Featured = 'featured',
+  Other = 'other',
+}
+
+/** Plain configuration object for a categorical color scheme. */
+export interface ColorSchemeConfig {
+  id: string;
+  label?: string;
+  colors: string[];
+  description?: string;
+  isDefault?: boolean;
+  group?: ColorSchemeGroup;
+}
+
+/** Extension of ColorSchemeConfig for sequential / diverging schemes. */
+export interface SequentialSchemeConfig extends ColorSchemeConfig {
+  isDiverging?: boolean;
+}
+
+/**
+ * Minimal interface for the categorical color scheme registry.
+ * Mirrors the public surface of @superset-ui/core's ColorSchemeRegistry.
+ */
+export interface CategoricalScheme {
+  id: string;
+  label?: string;
+  colors: string[];
+}
+
+export interface CategoricalSchemeRegistryLike {
+  keys(): string[];
+  get(name: string): CategoricalScheme | null | undefined;
+}
+
+/**
+ * Returns an alphabetically sorted list of all registered categorical color
+ * scheme names. The host app provides the implementation via
+ * window.superset.theme.
+ */
+export declare function getCategoricalSchemeNames(): string[];

Review Comment:
   Where are the methods to register a scheme? 



##########
superset-frontend/packages/superset-core/src/theme/colors.ts:
##########
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+/**
+ * Grouping/tier for a color scheme — controls how it appears in the
+ * scheme picker UI (e.g. Featured palettes are shown first).
+ *
+ * Mirrors @superset-ui/core's ColorSchemeGroup; kept here so
+ * palette configs have no dependency on @superset-ui/core.
+ */
+export enum ColorSchemeGroup {
+  Custom = 'custom',
+  Featured = 'featured',
+  Other = 'other',
+}
+
+/** Plain configuration object for a categorical color scheme. */
+export interface ColorSchemeConfig {
+  id: string;
+  label?: string;
+  colors: string[];
+  description?: string;
+  isDefault?: boolean;
+  group?: ColorSchemeGroup;
+}
+
+/** Extension of ColorSchemeConfig for sequential / diverging schemes. */
+export interface SequentialSchemeConfig extends ColorSchemeConfig {
+  isDiverging?: boolean;
+}
+
+/**
+ * Minimal interface for the categorical color scheme registry.
+ * Mirrors the public surface of @superset-ui/core's ColorSchemeRegistry.
+ */
+export interface CategoricalScheme {
+  id: string;
+  label?: string;
+  colors: string[];
+}
+
+export interface CategoricalSchemeRegistryLike {
+  keys(): string[];
+  get(name: string): CategoricalScheme | null | undefined;
+}
+
+/**
+ * Returns an alphabetically sorted list of all registered categorical color
+ * scheme names. The host app provides the implementation via
+ * window.superset.theme.
+ */
+export declare function getCategoricalSchemeNames(): string[];

Review Comment:
   Maybe have a getCategoricalSchemes function? Extracting the names seems like a implementation detail.



##########
superset-frontend/packages/superset-core/src/theme/colors.ts:
##########
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+/**
+ * Grouping/tier for a color scheme — controls how it appears in the
+ * scheme picker UI (e.g. Featured palettes are shown first).
+ *
+ * Mirrors @superset-ui/core's ColorSchemeGroup; kept here so
+ * palette configs have no dependency on @superset-ui/core.
+ */
+export enum ColorSchemeGroup {
+  Custom = 'custom',
+  Featured = 'featured',
+  Other = 'other',
+}
+
+/** Plain configuration object for a categorical color scheme. */
+export interface ColorSchemeConfig {
+  id: string;
+  label?: string;
+  colors: string[];
+  description?: string;
+  isDefault?: boolean;
+  group?: ColorSchemeGroup;
+}
+
+/** Extension of ColorSchemeConfig for sequential / diverging schemes. */
+export interface SequentialSchemeConfig extends ColorSchemeConfig {
+  isDiverging?: boolean;

Review Comment:
   Is this the only difference between a categorical and sequential schemes? Should we also rename it to SequentialScheme?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): expose Superset categorical color schemes via @apache-superset/core/theme [superset]

Posted by "sha174n (via GitHub)" <gi...@apache.org>.
sha174n commented on PR #39226:
URL: https://github.com/apache/superset/pull/39226#issuecomment-5368859956

   Clean read-only bridge for the palette metadata. Two things to tidy before it leaves draft: codecov flags a few uncovered lines in the host colors.ts wiring, and CategoricalSchemeRegistryLike is a hand-mirrored type via an as cast that can silently drift from the real registry type if that changes; a shared type or a structural check would keep them in sync.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3095807302


##########
superset-frontend/packages/superset-core/src/colors/categorical/airbnb.ts:
##########
@@ -17,19 +17,27 @@
  * under the License.
  */
 
-export function getMapboxApiKey(): string {
-  if (typeof document === 'undefined') {
-    return '';
-  }
-  try {
-    const appContainer = document.getElementById('app');
-    const dataBootstrap = appContainer?.getAttribute('data-bootstrap');
-    if (dataBootstrap) {
-      const bootstrapData = JSON.parse(dataBootstrap);
-      return bootstrapData?.common?.conf?.MAPBOX_API_KEY || '';
-    }
-  } catch {
-    // If bootstrap data is unavailable or malformed, return empty string
-  }
-  return '';
-}
+import { ColorSchemeConfig } from '../types';
+
+// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
+export const categoricalAirbnb: ColorSchemeConfig[] = [

Review Comment:
   I think it's important that the @apache-superset/core package to have the correct organization. You can still keep the implementation in @superset-ui/core and host the way they are. I'm just proposing to move the APIs to the correct package.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #39226:
URL: https://github.com/apache/superset/pull/39226#issuecomment-4825338923

   @michael-s-molina thanks for the patience, finally circled back on this.
   
   Rebased onto current `master` (which had since moved the `window.superset` types out into `Namespaces` and added a couple namespaces), and squashed the add-then-revert palette churn down to a single commit.
   
   Took your last two notes: dropped the `@apache-superset/core/colors` subpath and its re-export shim entirely since nothing imports it yet, so the API only lives under `@apache-superset/core/theme` now. And the host side follows the `src/core` pattern instead of the inline block, there's a `src/core/theme/colors.ts` that wires up `getCategoricalSchemeRegistry()`, registered as a `theme` namespace like `authentication`/`navigation`. Palette data still stays in `@superset-ui/core`.
   
   Running CI 🤞
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): expose Superset categorical color schemes via @apache-superset/core/theme [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #39226:
URL: https://github.com/apache/superset/pull/39226#issuecomment-5371266003

   @sha174n added a unit test for the host `colors.ts` wiring so the coverage gap's closed now.
   
   On the structural check, I actually tried writing one: a compile-time `extends` assertion between the real registry type and `CategoricalSchemeRegistryLike` fails to compile even today, because TS treats the two `ColorSchemeGroup` enums as nominally distinct despite matching string values. Making it pass would mean carving `group` out of the check somehow, which feels like more machinery than the `as` cast tradeoff is worth.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): expose Superset categorical color schemes to extensions [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed pull request #39226: feat(extensions): expose Superset categorical color schemes to extensions
URL: https://github.com/apache/superset/pull/39226


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3095776236


##########
superset-frontend/packages/superset-core/src/colors/categorical/airbnb.ts:
##########
@@ -17,19 +17,27 @@
  * under the License.
  */
 
-export function getMapboxApiKey(): string {
-  if (typeof document === 'undefined') {
-    return '';
-  }
-  try {
-    const appContainer = document.getElementById('app');
-    const dataBootstrap = appContainer?.getAttribute('data-bootstrap');
-    if (dataBootstrap) {
-      const bootstrapData = JSON.parse(dataBootstrap);
-      return bootstrapData?.common?.conf?.MAPBOX_API_KEY || '';
-    }
-  } catch {
-    // If bootstrap data is unavailable or malformed, return empty string
-  }
-  return '';
-}
+import { ColorSchemeConfig } from '../types';
+
+// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
+export const categoricalAirbnb: ColorSchemeConfig[] = [

Review Comment:
   Done — PR description updated to reflect the current design.



##########
superset-frontend/packages/superset-core/src/colors/categorical/airbnb.ts:
##########
@@ -17,19 +17,27 @@
  * under the License.
  */
 
-export function getMapboxApiKey(): string {
-  if (typeof document === 'undefined') {
-    return '';
-  }
-  try {
-    const appContainer = document.getElementById('app');
-    const dataBootstrap = appContainer?.getAttribute('data-bootstrap');
-    if (dataBootstrap) {
-      const bootstrapData = JSON.parse(dataBootstrap);
-      return bootstrapData?.common?.conf?.MAPBOX_API_KEY || '';
-    }
-  } catch {
-    // If bootstrap data is unavailable or malformed, return empty string
-  }
-  return '';
-}
+import { ColorSchemeConfig } from '../types';
+
+// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
+export const categoricalAirbnb: ColorSchemeConfig[] = [

Review Comment:
   Good suggestion. The palette data files under `colors/categorical/` have a TODO comment referencing SIP-20159 (`// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159`), so moving them under `src/theme` aligns with that intent. That said, with the approach now settled on (declare-only bridge, no palette data duplication), the actual palette hex arrays will stay in `@superset-ui/core` and these files become less relevant. I'd rather keep the scope of this PR small and leave any reorganization under `src/theme` for when SIP-20159 is worked on. Does that work for you?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3100840201


##########
superset-frontend/src/extensions/ExtensionsStartup.tsx:
##########
@@ -80,6 +85,12 @@ const ExtensionsStartup: React.FC<{ children?: React.ReactNode }> = ({
       views,
     };
 
+    // Inject the categorical color scheme registry so extensions can access
+    // Superset's registered palettes without depending on @superset-ui/core.
+    supersetCore.colors.registerCategoricalSchemeRegistry(

Review Comment:
   You can follow the existing patterns in `superset-frontend/src/core` and create a `theme` folder with a colors.ts which will be the implementation. Then, you can register the folder above like the others.



##########
superset-frontend/src/extensions/ExtensionsStartup.tsx:
##########
@@ -80,6 +85,12 @@ const ExtensionsStartup: React.FC<{ children?: React.ReactNode }> = ({
       views,
     };
 
+    // Inject the categorical color scheme registry so extensions can access
+    // Superset's registered palettes without depending on @superset-ui/core.
+    supersetCore.colors.registerCategoricalSchemeRegistry(

Review Comment:
   You can follow the existing patterns in `superset-frontend/src/core` and create a `theme` folder with a colors.ts which will be the implementation. Then, you can register the folder above like the other modules.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3092969639


##########
superset-frontend/packages/superset-core/src/colors/categorical/airbnb.ts:
##########
@@ -17,19 +17,27 @@
  * under the License.
  */
 
-export function getMapboxApiKey(): string {
-  if (typeof document === 'undefined') {
-    return '';
-  }
-  try {
-    const appContainer = document.getElementById('app');
-    const dataBootstrap = appContainer?.getAttribute('data-bootstrap');
-    if (dataBootstrap) {
-      const bootstrapData = JSON.parse(dataBootstrap);
-      return bootstrapData?.common?.conf?.MAPBOX_API_KEY || '';
-    }
-  } catch {
-    // If bootstrap data is unavailable or malformed, return empty string
-  }
-  return '';
-}
+import { ColorSchemeConfig } from '../types';
+
+// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
+export const categoricalAirbnb: ColorSchemeConfig[] = [

Review Comment:
   It might be good to update the PR description to reflect latest changes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3074260501


##########
superset-frontend/packages/superset-core/src/colors/categorical/airbnb.ts:
##########
@@ -17,19 +17,27 @@
  * under the License.
  */
 
-export function getMapboxApiKey(): string {
-  if (typeof document === 'undefined') {
-    return '';
-  }
-  try {
-    const appContainer = document.getElementById('app');
-    const dataBootstrap = appContainer?.getAttribute('data-bootstrap');
-    if (dataBootstrap) {
-      const bootstrapData = JSON.parse(dataBootstrap);
-      return bootstrapData?.common?.conf?.MAPBOX_API_KEY || '';
-    }
-  } catch {
-    // If bootstrap data is unavailable or malformed, return empty string
-  }
-  return '';
-}
+import { ColorSchemeConfig } from '../types';
+
+// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
+export const categoricalAirbnb: ColorSchemeConfig[] = [

Review Comment:
   Good call — updated. @apache-superset/core/colors now only exposes the interface: `ColorSchemeGroup`, `ColorSchemeConfig`/`SequentialSchemeConfig` types, and the registry bridge functions (`registerCategoricalSchemeRegistry`, `getCategoricalSchemeNames`, `getSchemeColors`). The palette hex data is back in `@superset-ui/core` where it belongs as a host implementation detail.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): expose Superset categorical color schemes via @apache-superset/core/theme [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #39226:
URL: https://github.com/apache/superset/pull/39226#issuecomment-5351340124

   @sha174n good catch on the title, narrowed it since sequential/diverging schemes aren't bridged yet (just categorical for now). On `CategoricalSchemeRegistryLike`, the `as` cast is deliberate: it's a minimal duck-typed contract so `@apache-superset/core` doesn't pull in `@superset-ui/core`'s actual registry class. Agreed it means an incompatible upstream change wouldn't get caught by the type system, but that's the same tradeoff the rest of this declare-in-contract API makes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3100840201


##########
superset-frontend/src/extensions/ExtensionsStartup.tsx:
##########
@@ -80,6 +85,12 @@ const ExtensionsStartup: React.FC<{ children?: React.ReactNode }> = ({
       views,
     };
 
+    // Inject the categorical color scheme registry so extensions can access
+    // Superset's registered palettes without depending on @superset-ui/core.
+    supersetCore.colors.registerCategoricalSchemeRegistry(

Review Comment:
   You can follow the existing patterns in `superset-frontend/src/core` and create a `theme` folder with a `colors.ts` which will be the implementation. Then, you can register the folder above like the other modules.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3095777008


##########
superset-frontend/packages/superset-core/src/colors/categorical/airbnb.ts:
##########
@@ -17,19 +17,27 @@
  * under the License.
  */
 
-export function getMapboxApiKey(): string {
-  if (typeof document === 'undefined') {
-    return '';
-  }
-  try {
-    const appContainer = document.getElementById('app');
-    const dataBootstrap = appContainer?.getAttribute('data-bootstrap');
-    if (dataBootstrap) {
-      const bootstrapData = JSON.parse(dataBootstrap);
-      return bootstrapData?.common?.conf?.MAPBOX_API_KEY || '';
-    }
-  } catch {
-    // If bootstrap data is unavailable or malformed, return empty string
-  }
-  return '';
-}
+import { ColorSchemeConfig } from '../types';
+
+// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
+export const categoricalAirbnb: ColorSchemeConfig[] = [

Review Comment:
   Good suggestion. The palette data files under `colors/categorical/` have a TODO comment referencing SIP-82 (`// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159`), so moving them under `src/theme` aligns with that intent. That said, with the approach now settled on (declare-only bridge, no palette data duplication), the actual palette hex arrays will stay in `@superset-ui/core` and these files become less relevant. I'd rather keep the scope of this PR small and leave any reorganization under `src/theme` for when SIP-82 is worked on. Does that work for you?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3092989613


##########
superset-frontend/packages/superset-core/src/colors/index.ts:
##########
@@ -0,0 +1,79 @@
+/**
+ * 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.
+ */
+
+// Types & enums for color scheme configuration — usable by extensions and host alike
+export type { ColorSchemeConfig, SequentialSchemeConfig } from './types';
+export { ColorSchemeGroup } from './types';
+
+// ─── Registry bridge for extensions ──────────────────────────────────────────
+//
+// The host app (ExtensionsStartup) calls `registerCategoricalSchemeRegistry()`
+// to inject @superset-ui/core's live singleton.  Extensions then call
+// `getCategoricalSchemeNames()` / `getSchemeColors()` and receive the same
+// palettes that the host app registered (including any custom extra schemes).
+
+/**
+ * Minimal interface for the categorical color scheme registry.
+ * Mirrors the public surface of @superset-ui/core's ColorSchemeRegistry.
+ */
+export interface CategoricalScheme {
+  id: string;
+  label?: string;
+  colors: string[];
+}
+
+export interface CategoricalSchemeRegistryLike {
+  keys(): string[];
+  get(name: string): CategoricalScheme | null | undefined;
+}
+
+let _registry: CategoricalSchemeRegistryLike | null = null;

Review Comment:
   Here's you just need the APIs. Implementation is part of the core (no `_registry` property). Check other modules like `authentication`.



##########
superset-frontend/packages/superset-core/src/colors/index.ts:
##########
@@ -0,0 +1,79 @@
+/**
+ * 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.
+ */
+
+// Types & enums for color scheme configuration — usable by extensions and host alike
+export type { ColorSchemeConfig, SequentialSchemeConfig } from './types';
+export { ColorSchemeGroup } from './types';
+
+// ─── Registry bridge for extensions ──────────────────────────────────────────
+//
+// The host app (ExtensionsStartup) calls `registerCategoricalSchemeRegistry()`
+// to inject @superset-ui/core's live singleton.  Extensions then call
+// `getCategoricalSchemeNames()` / `getSchemeColors()` and receive the same
+// palettes that the host app registered (including any custom extra schemes).
+
+/**
+ * Minimal interface for the categorical color scheme registry.
+ * Mirrors the public surface of @superset-ui/core's ColorSchemeRegistry.
+ */
+export interface CategoricalScheme {
+  id: string;
+  label?: string;
+  colors: string[];
+}
+
+export interface CategoricalSchemeRegistryLike {
+  keys(): string[];
+  get(name: string): CategoricalScheme | null | undefined;
+}
+
+let _registry: CategoricalSchemeRegistryLike | null = null;
+
+/**
+ * Called by the Superset host app (ExtensionsStartup) to inject the
+ * categorical color scheme registry so extensions can access it without
+ * depending directly on @superset-ui/core.
+ */
+export function registerCategoricalSchemeRegistry(
+  registry: CategoricalSchemeRegistryLike,
+): void {
+  _registry = registry;
+}
+
+/**
+ * Returns the categorical color scheme registry registered by the host app,
+ * or null if not yet injected (e.g. in tests or isolated builds).
+ */
+export function getCategoricalSchemeRegistry(): CategoricalSchemeRegistryLike | null {
+  return _registry;
+}
+
+/**
+ * Returns an alphabetically sorted list of all registered scheme names.
+ */
+export function getCategoricalSchemeNames(): string[] {
+  return _registry?.keys().sort() ?? [];

Review Comment:
   Implementation should not be here.



##########
superset-frontend/src/extensions/ExtensionsStartup.tsx:
##########
@@ -80,6 +85,12 @@ const ExtensionsStartup: React.FC<{ children?: React.ReactNode }> = ({
       views,
     };
 
+    // Inject the categorical color scheme registry so extensions can access
+    // Superset's registered palettes without depending on @superset-ui/core.
+    supersetCore.colors.registerCategoricalSchemeRegistry(

Review Comment:
   This is already done above in 
   
   ```
   window.superset = {
         ...supersetCore,
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3095777477


##########
superset-frontend/packages/superset-core/src/colors/index.ts:
##########
@@ -0,0 +1,79 @@
+/**
+ * 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.
+ */
+
+// Types & enums for color scheme configuration — usable by extensions and host alike
+export type { ColorSchemeConfig, SequentialSchemeConfig } from './types';
+export { ColorSchemeGroup } from './types';
+
+// ─── Registry bridge for extensions ──────────────────────────────────────────
+//
+// The host app (ExtensionsStartup) calls `registerCategoricalSchemeRegistry()`
+// to inject @superset-ui/core's live singleton.  Extensions then call
+// `getCategoricalSchemeNames()` / `getSchemeColors()` and receive the same
+// palettes that the host app registered (including any custom extra schemes).
+
+/**
+ * Minimal interface for the categorical color scheme registry.
+ * Mirrors the public surface of @superset-ui/core's ColorSchemeRegistry.
+ */
+export interface CategoricalScheme {
+  id: string;
+  label?: string;
+  colors: string[];
+}
+
+export interface CategoricalSchemeRegistryLike {
+  keys(): string[];
+  get(name: string): CategoricalScheme | null | undefined;
+}
+
+let _registry: CategoricalSchemeRegistryLike | null = null;

Review Comment:
   Done — updated to use `declare function` signatures, matching the `authentication` module pattern. No `_registry` state, no implementation.



##########
superset-frontend/packages/superset-core/src/colors/index.ts:
##########
@@ -0,0 +1,79 @@
+/**
+ * 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.
+ */
+
+// Types & enums for color scheme configuration — usable by extensions and host alike
+export type { ColorSchemeConfig, SequentialSchemeConfig } from './types';
+export { ColorSchemeGroup } from './types';
+
+// ─── Registry bridge for extensions ──────────────────────────────────────────
+//
+// The host app (ExtensionsStartup) calls `registerCategoricalSchemeRegistry()`
+// to inject @superset-ui/core's live singleton.  Extensions then call
+// `getCategoricalSchemeNames()` / `getSchemeColors()` and receive the same
+// palettes that the host app registered (including any custom extra schemes).
+
+/**
+ * Minimal interface for the categorical color scheme registry.
+ * Mirrors the public surface of @superset-ui/core's ColorSchemeRegistry.
+ */
+export interface CategoricalScheme {
+  id: string;
+  label?: string;
+  colors: string[];
+}
+
+export interface CategoricalSchemeRegistryLike {
+  keys(): string[];
+  get(name: string): CategoricalScheme | null | undefined;
+}
+
+let _registry: CategoricalSchemeRegistryLike | null = null;
+
+/**
+ * Called by the Superset host app (ExtensionsStartup) to inject the
+ * categorical color scheme registry so extensions can access it without
+ * depending directly on @superset-ui/core.
+ */
+export function registerCategoricalSchemeRegistry(
+  registry: CategoricalSchemeRegistryLike,
+): void {
+  _registry = registry;
+}
+
+/**
+ * Returns the categorical color scheme registry registered by the host app,
+ * or null if not yet injected (e.g. in tests or isolated builds).
+ */
+export function getCategoricalSchemeRegistry(): CategoricalSchemeRegistryLike | null {
+  return _registry;
+}
+
+/**
+ * Returns an alphabetically sorted list of all registered scheme names.
+ */
+export function getCategoricalSchemeNames(): string[] {
+  return _registry?.keys().sort() ?? [];

Review Comment:
   Done — implementation removed. `colors/index.ts` now contains only types, interfaces, and `declare function` signatures.



##########
superset-frontend/src/extensions/ExtensionsStartup.tsx:
##########
@@ -80,6 +85,12 @@ const ExtensionsStartup: React.FC<{ children?: React.ReactNode }> = ({
       views,
     };
 
+    // Inject the categorical color scheme registry so extensions can access
+    // Superset's registered palettes without depending on @superset-ui/core.
+    supersetCore.colors.registerCategoricalSchemeRegistry(

Review Comment:
   With the updated design, `@apache-superset/core/colors` no longer has a runtime implementation for `getCategoricalSchemeNames` / `getSchemeColors` — they're `declare function` only. So spreading `...supersetCore` would leave those as `undefined` at runtime. This explicit `colors` block is what provides the real implementations, wiring up to `getCategoricalSchemeRegistry()` from `@superset-ui/core`. Without it, extensions calling `colors.getCategoricalSchemeNames()` would throw.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3072682296


##########
superset-frontend/packages/superset-core/src/colors/categorical/airbnb.ts:
##########
@@ -17,19 +17,27 @@
  * under the License.
  */
 
-export function getMapboxApiKey(): string {
-  if (typeof document === 'undefined') {
-    return '';
-  }
-  try {
-    const appContainer = document.getElementById('app');
-    const dataBootstrap = appContainer?.getAttribute('data-bootstrap');
-    if (dataBootstrap) {
-      const bootstrapData = JSON.parse(dataBootstrap);
-      return bootstrapData?.common?.conf?.MAPBOX_API_KEY || '';
-    }
-  } catch {
-    // If bootstrap data is unavailable or malformed, return empty string
-  }
-  return '';
-}
+import { ColorSchemeConfig } from '../types';
+
+// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
+export const categoricalAirbnb: ColorSchemeConfig[] = [

Review Comment:
   @rusackas Could we expose the interfaces to access color schemes and leave implementation details for the host?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): expose Superset categorical color schemes to extensions [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #39226:
URL: https://github.com/apache/superset/pull/39226#issuecomment-4216154203

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 477c06dbf05eab332832e84c7b2ff3c19aafbf2f |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69d7df2b5db8ad0007e44d55 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-39226--superset-docs-preview.netlify.app](https://deploy-preview-39226--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTM5MjI2LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.tlRuv_Y75QAs96vs6OnEDIbIxv71X76DyzsmAx29eYw)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-39226--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #39226:
URL: https://github.com/apache/superset/pull/39226#issuecomment-4256301436

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/39226?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 64.55%. Comparing base ([`b11d4f3`](https://app.codecov.io/gh/apache/superset/commit/b11d4f3ef098fc94560565891b948ee9e5a27e3d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`d8f2fb7`](https://app.codecov.io/gh/apache/superset/commit/d8f2fb7e6e14d12ccaa4de6b1a56ed431753f3fc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 12 commits behind head on master.
   
   :x: Your project check has failed because the head coverage (99.79%) is below the target coverage (100.00%). You can increase the head coverage or adjust the [target](https://docs.codecov.com/docs/commit-status#target) coverage.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #39226   +/-   ##
   =======================================
     Coverage   64.54%   64.55%           
   =======================================
     Files        2557     2558    +1     
     Lines      132981   132991   +10     
     Branches    30888    30890    +2     
   =======================================
   + Hits        85837    85847   +10     
     Misses      45653    45653           
     Partials     1491     1491           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/39226/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/39226/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.33% <100.00%> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/39226?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3092979821


##########
superset-frontend/packages/superset-core/src/colors/categorical/airbnb.ts:
##########
@@ -17,19 +17,27 @@
  * under the License.
  */
 
-export function getMapboxApiKey(): string {
-  if (typeof document === 'undefined') {
-    return '';
-  }
-  try {
-    const appContainer = document.getElementById('app');
-    const dataBootstrap = appContainer?.getAttribute('data-bootstrap');
-    if (dataBootstrap) {
-      const bootstrapData = JSON.parse(dataBootstrap);
-      return bootstrapData?.common?.conf?.MAPBOX_API_KEY || '';
-    }
-  } catch {
-    // If bootstrap data is unavailable or malformed, return empty string
-  }
-  return '';
-}
+import { ColorSchemeConfig } from '../types';
+
+// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
+export const categoricalAirbnb: ColorSchemeConfig[] = [

Review Comment:
   Also, I think this would be better organized under `src/theme`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): expose Superset categorical color schemes to extensions [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39226:
URL: https://github.com/apache/superset/pull/39226#issuecomment-4216126164

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3096723338


##########
superset-frontend/packages/superset-core/src/colors/categorical/airbnb.ts:
##########
@@ -17,19 +17,27 @@
  * under the License.
  */
 
-export function getMapboxApiKey(): string {
-  if (typeof document === 'undefined') {
-    return '';
-  }
-  try {
-    const appContainer = document.getElementById('app');
-    const dataBootstrap = appContainer?.getAttribute('data-bootstrap');
-    if (dataBootstrap) {
-      const bootstrapData = JSON.parse(dataBootstrap);
-      return bootstrapData?.common?.conf?.MAPBOX_API_KEY || '';
-    }
-  } catch {
-    // If bootstrap data is unavailable or malformed, return empty string
-  }
-  return '';
-}
+import { ColorSchemeConfig } from '../types';
+
+// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
+export const categoricalAirbnb: ColorSchemeConfig[] = [

Review Comment:
   Done — `ColorSchemeGroup`, `ColorSchemeConfig`, `SequentialSchemeConfig`, and the registry bridge interfaces/declare functions are now in `src/theme/colors.ts` and exported through `@apache-superset/core/theme`. `src/colors/index.ts` is kept as a thin re-export shim so the `@apache-superset/core/colors` subpath continues to work for any existing references.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3100816177


##########
superset-frontend/packages/superset-core/src/colors/index.ts:
##########
@@ -0,0 +1,32 @@
+/**
+ * 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.
+ */
+
+// Color scheme APIs live in @apache-superset/core/theme.
+// This re-export shim keeps the @apache-superset/core/colors subpath working.
+export type {

Review Comment:
   I don't think we need this as there's no imports of `@apache-superset/core/colors` yet.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(extensions): make @apache-superset/core/colors the single source of truth for color palettes [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #39226:
URL: https://github.com/apache/superset/pull/39226#discussion_r3818594687


##########
superset-frontend/packages/superset-core/src/theme/index.tsx:
##########
@@ -88,3 +88,17 @@ export type {
 // Export theme utility functions
 export * from './utils/themeUtils';
 export * from './utils';
+
+// Color scheme API — types, enum, and declare-function bridge for extensions.
+// The host app provides the runtime implementations on window.superset.theme.
+export type {

Review Comment:
   Done, swapped to `export * from './colors'` to match the pattern above.



##########
superset-frontend/packages/superset-core/src/theme/colors.ts:
##########
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+/**
+ * Grouping/tier for a color scheme — controls how it appears in the
+ * scheme picker UI (e.g. Featured palettes are shown first).
+ *
+ * Mirrors @superset-ui/core's ColorSchemeGroup; kept here so
+ * palette configs have no dependency on @superset-ui/core.
+ */
+export enum ColorSchemeGroup {
+  Custom = 'custom',
+  Featured = 'featured',
+  Other = 'other',
+}
+
+/** Plain configuration object for a categorical color scheme. */
+export interface ColorSchemeConfig {

Review Comment:
   Good call, renamed to `CategoricalScheme` and dropped the redundant one below.



##########
superset-frontend/packages/superset-core/src/theme/colors.ts:
##########
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+/**
+ * Grouping/tier for a color scheme — controls how it appears in the
+ * scheme picker UI (e.g. Featured palettes are shown first).
+ *
+ * Mirrors @superset-ui/core's ColorSchemeGroup; kept here so
+ * palette configs have no dependency on @superset-ui/core.
+ */
+export enum ColorSchemeGroup {
+  Custom = 'custom',
+  Featured = 'featured',
+  Other = 'other',
+}
+
+/** Plain configuration object for a categorical color scheme. */
+export interface ColorSchemeConfig {
+  id: string;
+  label?: string;
+  colors: string[];
+  description?: string;
+  isDefault?: boolean;
+  group?: ColorSchemeGroup;
+}
+
+/** Extension of ColorSchemeConfig for sequential / diverging schemes. */
+export interface SequentialSchemeConfig extends ColorSchemeConfig {
+  isDiverging?: boolean;

Review Comment:
   Yep, `isDiverging` is the only diff. Renamed to `SequentialScheme` to match.



##########
superset-frontend/packages/superset-core/src/theme/colors.ts:
##########
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+/**
+ * Grouping/tier for a color scheme — controls how it appears in the
+ * scheme picker UI (e.g. Featured palettes are shown first).
+ *
+ * Mirrors @superset-ui/core's ColorSchemeGroup; kept here so
+ * palette configs have no dependency on @superset-ui/core.
+ */
+export enum ColorSchemeGroup {
+  Custom = 'custom',
+  Featured = 'featured',
+  Other = 'other',
+}
+
+/** Plain configuration object for a categorical color scheme. */
+export interface ColorSchemeConfig {
+  id: string;
+  label?: string;
+  colors: string[];
+  description?: string;
+  isDefault?: boolean;
+  group?: ColorSchemeGroup;
+}
+
+/** Extension of ColorSchemeConfig for sequential / diverging schemes. */
+export interface SequentialSchemeConfig extends ColorSchemeConfig {
+  isDiverging?: boolean;
+}
+
+/**
+ * Minimal interface for the categorical color scheme registry.
+ * Mirrors the public surface of @superset-ui/core's ColorSchemeRegistry.
+ */
+export interface CategoricalScheme {
+  id: string;
+  label?: string;
+  colors: string[];
+}
+
+export interface CategoricalSchemeRegistryLike {
+  keys(): string[];
+  get(name: string): CategoricalScheme | null | undefined;
+}
+
+/**
+ * Returns an alphabetically sorted list of all registered categorical color
+ * scheme names. The host app provides the implementation via
+ * window.superset.theme.
+ */
+export declare function getCategoricalSchemeNames(): string[];

Review Comment:
   No register methods on purpose, this is read-only: extensions query Superset's registered schemes, they don't add their own.



##########
superset-frontend/packages/superset-core/src/theme/colors.ts:
##########
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+/**
+ * Grouping/tier for a color scheme — controls how it appears in the
+ * scheme picker UI (e.g. Featured palettes are shown first).
+ *
+ * Mirrors @superset-ui/core's ColorSchemeGroup; kept here so
+ * palette configs have no dependency on @superset-ui/core.
+ */
+export enum ColorSchemeGroup {
+  Custom = 'custom',
+  Featured = 'featured',
+  Other = 'other',
+}
+
+/** Plain configuration object for a categorical color scheme. */
+export interface ColorSchemeConfig {
+  id: string;
+  label?: string;
+  colors: string[];
+  description?: string;
+  isDefault?: boolean;
+  group?: ColorSchemeGroup;
+}
+
+/** Extension of ColorSchemeConfig for sequential / diverging schemes. */
+export interface SequentialSchemeConfig extends ColorSchemeConfig {
+  isDiverging?: boolean;
+}
+
+/**
+ * Minimal interface for the categorical color scheme registry.
+ * Mirrors the public surface of @superset-ui/core's ColorSchemeRegistry.
+ */
+export interface CategoricalScheme {
+  id: string;
+  label?: string;
+  colors: string[];
+}
+
+export interface CategoricalSchemeRegistryLike {
+  keys(): string[];
+  get(name: string): CategoricalScheme | null | undefined;
+}
+
+/**
+ * Returns an alphabetically sorted list of all registered categorical color
+ * scheme names. The host app provides the implementation via
+ * window.superset.theme.
+ */
+export declare function getCategoricalSchemeNames(): string[];

Review Comment:
   Added `getCategoricalSchemes()` so you get full scheme metadata without a second round-trip through `getSchemeColors`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org