Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

2.4 KB
Raw Blame
interface MetabaseLocalization {
  headers: {
    language: string;
    "plural-forms"?: string;
  };
  translations: Record<
    string,
    Record<string, { msgid?: string; msgstr: string[] }>
  >;
}

interface Window {
  MetabaseBootstrap: any;
  MetabaseRoot?: string;
  /**
   * @deprecated - use getCspNonce() from metabase/utils/csp instead
   */
  MetabaseNonce?: string;
  MetabaseUserColorScheme?: string;
  MetabaseSiteLocalization?: MetabaseLocalization;
  MetabaseUserLocalization?: MetabaseLocalization;
  /** The locales the document loaded catalogues for, set by index_bootstrap.js. */
  MetabaseLocales?: { user: string; site: string };

  overrideIsWithinIframe?: boolean; // Mock that we're embedding, so we could test embed components
  METABASE?: boolean; // Add a global so we can check if the parent iframe is Metabase

  Metabase?: {
    // Set by the inline asset_loading_error script, before the bundle runs
    AssetErrorLoad?: (tag: HTMLScriptElement) => void;
    // Console debugging handles, set on app boot
    store?: unknown;
    settings?: unknown;
  };

  // Dev-only helpers for inspecting the current query from CLJS REPLs
  __lib_metadata?: unknown;
  __lib_query?: unknown;
  Lib?: unknown;

  // Make iFrameResizer available so that embed users can
  // have their embeds autosize to their content
  iFrameResizer?: {
    autoResize?: boolean;
    heightCalculationMethod?: string;
    onReady?: () => void;
  };

  MetabaseSiteLocalization?: {
    headers: {
      language: string;
      "plural-forms"?: string;
      "content-type"?: string;
    };
    translations: Record<string, unknown>;
  };
  MetabaseUserLocalization?: {
    headers: {
      language: string;
      "plural-forms"?: string;
      "content-type"?: string;
    };
    translations: Record<string, unknown>;
  };
}

// This allows importing static SVGs from TypeScript files
declare module "*.svg" {
  const content: any;
  // Default-importing this is the deprecated pattern.
  export default content;
}

// This allows importing CSS from TypeScript files
declare module "*.css" {
  const classes: { [key: string]: string };
  // Default-importing this is the deprecated pattern.
  export default classes;
}

declare module "iframe-resizer/js/iframeResizer.contentWindow.js";

declare module "simple-statistics" {
  const ss: {
    ckmeans: (data: number[], nClusters: number) => number[][];
  };
  export default ss;
}

type Nullable<T> = T | null;