config.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* global process */
  2. /**
  3. * This module is used to define the look and feels for charts rendered via the
  4. * backend chart rendering service Chartcuterie.
  5. *
  6. * Be careful what you import into this file, as it will end up being bundled
  7. * into the configuration file loaded by the service.
  8. */
  9. // eslint-disable-next-line import/no-named-default
  10. import {discoverCharts} from './discover';
  11. import {metricAlertCharts} from './metricAlert';
  12. import type {
  13. ChartcuterieConfig,
  14. ChartType,
  15. RenderConfig,
  16. RenderDescriptor,
  17. } from './types';
  18. /**
  19. * All registered style descriptors
  20. */
  21. const renderConfig: RenderConfig<ChartType> = new Map();
  22. /**
  23. * Chartcuterie configuration object
  24. */
  25. const config: ChartcuterieConfig = {
  26. version: process.env.COMMIT_SHA!,
  27. renderConfig,
  28. };
  29. /**
  30. * Register a style descriptor
  31. */
  32. const register = (renderDescriptor: RenderDescriptor<ChartType>) =>
  33. renderConfig.set(renderDescriptor.key, renderDescriptor);
  34. discoverCharts.forEach(register);
  35. metricAlertCharts.forEach(register);
  36. export default config;