config.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. import {discoverCharts} from './discover';
  10. import {metricAlertCharts} from './metricAlert';
  11. import {performanceCharts} from './performance';
  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. performanceCharts.forEach(register);
  37. export default config;