config.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 {performanceCharts} from './performance';
  13. import type {
  14. ChartcuterieConfig,
  15. ChartType,
  16. RenderConfig,
  17. RenderDescriptor,
  18. } from './types';
  19. /**
  20. * All registered style descriptors
  21. */
  22. const renderConfig: RenderConfig<ChartType> = new Map();
  23. /**
  24. * Chartcuterie configuration object
  25. */
  26. const config: ChartcuterieConfig = {
  27. version: process.env.COMMIT_SHA!,
  28. renderConfig,
  29. };
  30. /**
  31. * Register a style descriptor
  32. */
  33. const register = (renderDescriptor: RenderDescriptor<ChartType>) =>
  34. renderConfig.set(renderDescriptor.key, renderDescriptor);
  35. discoverCharts.forEach(register);
  36. metricAlertCharts.forEach(register);
  37. performanceCharts.forEach(register);
  38. export default config;