config.tsx 1.0 KB

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