guards.ts 1006 B

12345678910111213141516
  1. import { AnnotationQuery } from '@grafana/data';
  2. import { CloudWatchAnnotationQuery, CloudWatchLogsQuery, CloudWatchMetricsQuery, CloudWatchQuery } from './types';
  3. export const isCloudWatchLogsQuery = (cloudwatchQuery: CloudWatchQuery): cloudwatchQuery is CloudWatchLogsQuery =>
  4. cloudwatchQuery.queryMode === 'Logs';
  5. export const isCloudWatchMetricsQuery = (cloudwatchQuery: CloudWatchQuery): cloudwatchQuery is CloudWatchMetricsQuery =>
  6. cloudwatchQuery.queryMode === 'Metrics' || !cloudwatchQuery.hasOwnProperty('queryMode'); // in early versions of this plugin, queryMode wasn't defined in a CloudWatchMetricsQuery
  7. export const isCloudWatchAnnotationQuery = (
  8. cloudwatchQuery: CloudWatchQuery
  9. ): cloudwatchQuery is CloudWatchAnnotationQuery => cloudwatchQuery.queryMode === 'Annotations';
  10. export const isCloudWatchAnnotation = (query: unknown): query is AnnotationQuery<CloudWatchAnnotationQuery> =>
  11. (query as AnnotationQuery<CloudWatchAnnotationQuery>).target?.queryMode === 'Annotations';