diff --git a/bitmovin-analytics-datasource/src/components/ConfigEditor.tsx b/bitmovin-analytics-datasource/src/components/ConfigEditor.tsx index cdae81c..13b3104 100644 --- a/bitmovin-analytics-datasource/src/components/ConfigEditor.tsx +++ b/bitmovin-analytics-datasource/src/components/ConfigEditor.tsx @@ -1,7 +1,7 @@ import React, { ChangeEvent, useEffect } from 'react'; import { DataSourceHttpSettings, FieldSet, InlineField, InlineSwitch, Input } from '@grafana/ui'; import { DataSourcePluginOptionsEditorProps } from '@grafana/data'; -import { BitmovinDataSourceOptions } from '../types'; +import { BitmovinDataSourceOptions } from '../types/grafanaTypes'; interface Props extends DataSourcePluginOptionsEditorProps {} diff --git a/bitmovin-analytics-datasource/src/components/QueryEditor.tsx b/bitmovin-analytics-datasource/src/components/QueryEditor.tsx index b44ac5d..5630f73 100644 --- a/bitmovin-analytics-datasource/src/components/QueryEditor.tsx +++ b/bitmovin-analytics-datasource/src/components/QueryEditor.tsx @@ -4,7 +4,7 @@ import { QueryEditorProps, SelectableValue } from '@grafana/data'; import { defaults } from 'lodash'; import { DataSource } from '../datasource'; -import { BitmovinDataSourceOptions, BitmovinAnalyticsDataQuery, DEFAULT_QUERY } from '../types'; +import { BitmovinDataSourceOptions, BitmovinAnalyticsDataQuery, DEFAULT_QUERY } from '../types/grafanaTypes'; import { fetchLicenses } from '../utils/licenses'; import { DEFAULT_SELECTABLE_QUERY_INTERVAL, SELECTABLE_QUERY_INTERVALS } from '../utils/intervalUtils'; import { SELECTABLE_AGGREGATIONS } from '../types/aggregations'; diff --git a/bitmovin-analytics-datasource/src/datasource.ts b/bitmovin-analytics-datasource/src/datasource.ts index b0a97fd..0d384b2 100644 --- a/bitmovin-analytics-datasource/src/datasource.ts +++ b/bitmovin-analytics-datasource/src/datasource.ts @@ -8,21 +8,37 @@ import { Field, } from '@grafana/data'; import { getBackendSrv } from '@grafana/runtime'; +import { filter } from 'lodash'; import { catchError, lastValueFrom, map, Observable, of } from 'rxjs'; +import { BitmovinDataSourceOptions, BitmovinAnalyticsDataQuery, DEFAULT_QUERY } from './types/grafanaTypes'; import { MixedDataRowList, - BitmovinDataSourceOptions, - BitmovinAnalyticsDataQuery, NumberDataRowList, - BitmovinAnalyticsRequestQuery, - DEFAULT_QUERY, -} from './types'; -import { transformGroupedTimeSeriesData, transformSimpleTimeSeries, transformTableData } from './utils/dataUtils'; -import { calculateQueryInterval } from './utils/intervalUtils'; + transformGroupedTimeSeriesData, + transformSimpleTimeSeries, + transformTableData, +} from './utils/dataUtils'; +import { calculateQueryInterval, QueryInterval } from './utils/intervalUtils'; import { Metric } from './types/metric'; import { Aggregation } from './types/aggregations'; -import { filter } from 'lodash'; +import { QueryFilter } from './types/queryFilter'; +import { QueryAttribute } from './types/queryAttributes'; +import { QueryAdAttribute } from './types/queryAdAttributes'; +import { QueryOrderBy } from './types/queryOrderBy'; + +type BitmovinAnalyticsRequestQuery = { + licenseKey: string; + start: Date; + end: Date; + filters: QueryFilter[]; + groupBy: QueryAttribute[] | QueryAdAttribute[]; + orderBy: QueryOrderBy[]; + dimension?: QueryAttribute | QueryAdAttribute; + metric?: Metric; + interval?: QueryInterval; + limit?: number; +}; export class DataSource extends DataSourceApi { baseUrl: string; diff --git a/bitmovin-analytics-datasource/src/module.ts b/bitmovin-analytics-datasource/src/module.ts index def023a..917913c 100644 --- a/bitmovin-analytics-datasource/src/module.ts +++ b/bitmovin-analytics-datasource/src/module.ts @@ -2,7 +2,7 @@ import { DataSourcePlugin } from '@grafana/data'; import { DataSource } from './datasource'; import { ConfigEditor } from './components/ConfigEditor'; import { QueryEditor } from './components/QueryEditor'; -import { BitmovinAnalyticsDataQuery, BitmovinDataSourceOptions } from './types'; +import { BitmovinAnalyticsDataQuery, BitmovinDataSourceOptions } from './types/grafanaTypes'; export const plugin = new DataSourcePlugin( DataSource diff --git a/bitmovin-analytics-datasource/src/types.ts b/bitmovin-analytics-datasource/src/types/grafanaTypes.ts similarity index 50% rename from bitmovin-analytics-datasource/src/types.ts rename to bitmovin-analytics-datasource/src/types/grafanaTypes.ts index 5d21a81..e5d3f2b 100644 --- a/bitmovin-analytics-datasource/src/types.ts +++ b/bitmovin-analytics-datasource/src/types/grafanaTypes.ts @@ -1,12 +1,12 @@ import { DataSourceJsonData } from '@grafana/data'; import { DataQuery } from '@grafana/schema'; -import { QueryInterval } from './utils/intervalUtils'; -import { Aggregation } from './types/aggregations'; -import { QueryAttribute } from './types/queryAttributes'; -import { QueryAdAttribute } from './types/queryAdAttributes'; -import { Metric } from './types/metric'; -import { QueryOrderBy } from './types/queryOrderBy'; -import { QueryFilter } from './types/queryFilter'; +import { QueryInterval } from '../utils/intervalUtils'; +import { Aggregation } from './aggregations'; +import { QueryAttribute } from './queryAttributes'; +import { QueryAdAttribute } from './queryAdAttributes'; +import { Metric } from './metric'; +import { QueryOrderBy } from './queryOrderBy'; +import { QueryFilter } from './queryFilter'; /** * These are the options configurable via the QueryEditor @@ -40,22 +40,3 @@ export interface BitmovinDataSourceOptions extends DataSourceJsonData { tenantOrgId?: string; adAnalytics?: boolean; } - -export type BitmovinAnalyticsRequestQuery = { - licenseKey: string; - start: Date; - end: Date; - filters: QueryFilter[]; - groupBy: QueryAttribute[] | QueryAdAttribute[]; - orderBy: QueryOrderBy[]; - dimension?: QueryAttribute | QueryAdAttribute; - metric?: Metric; - interval?: QueryInterval; - limit?: number; -}; - -export type MixedDataRow = Array; -export type MixedDataRowList = MixedDataRow[]; - -export type NumberDataRow = number[]; -export type NumberDataRowList = NumberDataRow[]; diff --git a/bitmovin-analytics-datasource/src/utils/dataUtils.ts b/bitmovin-analytics-datasource/src/utils/dataUtils.ts index 0ce63b7..2f88ed5 100644 --- a/bitmovin-analytics-datasource/src/utils/dataUtils.ts +++ b/bitmovin-analytics-datasource/src/utils/dataUtils.ts @@ -1,7 +1,12 @@ import { differenceWith, sortBy, zip } from 'lodash'; import { ceilTimestampAccordingToQueryInterval, intervalToMilliseconds, QueryInterval } from './intervalUtils'; import { Field, FieldType } from '@grafana/data'; -import { MixedDataRow, MixedDataRowList, NumberDataRow, NumberDataRowList } from '../types'; + +export type MixedDataRow = Array; +export type MixedDataRowList = MixedDataRow[]; + +export type NumberDataRow = number[]; +export type NumberDataRowList = NumberDataRow[]; /** * Adds padding to a given time series to fill in any missing timestamps for a given interval.