The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/alerting/unified/api/timeIntervalsApi.ts

32 lines
1.3 KiB

// Overriding the response types when enhancing endpoints is currently fiddly.
// The below approach is taken from/related to the below:
// https://github.com/reduxjs/redux-toolkit/issues/3901#issuecomment-1820995408
// https://github.com/reduxjs/redux-toolkit/issues/3443#issue-1709588268
//
// At the time of writing there is an open PR changing the API of `enhanceEndpoints`,
// which may help alleviate this when it lands:
// https://github.com/reduxjs/redux-toolkit/pull/3485
import { DefinitionsFromApi, OverrideResultType } from '@reduxjs/toolkit/dist/query/endpointDefinitions';
import {
ListTimeIntervalForAllNamespacesApiResponse,
generatedTimeIntervalsApi,
} from '../openapi/timeIntervalsApi.gen';
type Definitions = DefinitionsFromApi<typeof generatedTimeIntervalsApi>;
type UpdatedDefinitions = Omit<Definitions, 'listTimeIntervalForAllNamespaces'> & {
listTimeIntervalForAllNamespaces: OverrideResultType<
Definitions['listTimeIntervalForAllNamespaces'],
Array<ListTimeIntervalForAllNamespacesApiResponse['items'][0]['spec']>
>;
};
export const timeIntervalsApi = generatedTimeIntervalsApi.enhanceEndpoints<never, UpdatedDefinitions>({
endpoints: {
listTimeIntervalForAllNamespaces: {
transformResponse: (response: ListTimeIntervalForAllNamespacesApiResponse) =>
response.items.map((item) => item.spec),
},
},
});