@grafana/runtime
Version:
Grafana Runtime Library
1 lines • 3.54 kB
Source Map (JSON)
{"version":3,"file":"CorrelationsService.mjs","sources":["../../../src/services/CorrelationsService.ts"],"sourcesContent":["import {\n DataFrame,\n DataLinkPostProcessor,\n DataLinkTransformationConfig,\n DataSourceInstanceSettings,\n TimeRange,\n} from '@grafana/data';\n\nexport type CorrelationConfigQuery = {\n field: string;\n target: object; // for queries, this contains anything that would go in the query editor, so any extension off DataQuery a datasource would have, and needs to be generic.\n transformations?: DataLinkTransformationConfig[];\n};\n\nexport type CorrelationConfigExternal = {\n field: string;\n target: {\n url: string; // For external, this simply contains a URL\n };\n transformations?: DataLinkTransformationConfig[];\n};\n\ntype CorrelationBase = {\n uid: string;\n sourceUID: string;\n label?: string;\n description?: string;\n provisioned: boolean;\n orgId?: number;\n};\n\n/**\n * @alpha\n */\nexport type CorrelationExternal = CorrelationBase & {\n type: 'external';\n config: CorrelationConfigExternal;\n};\n\n/**\n * @alpha\n */\nexport type CorrelationQuery = CorrelationBase & {\n type: 'query';\n config: CorrelationConfigQuery;\n targetUID: string;\n};\n\n/**\n * @alpha\n */\nexport type CorrelationData =\n | (Omit<CorrelationExternal, 'sourceUID'> & {\n source: DataSourceInstanceSettings;\n })\n | (Omit<CorrelationQuery, 'sourceUID' | 'targetUID'> & {\n source: DataSourceInstanceSettings;\n target: DataSourceInstanceSettings;\n });\n\n/**\n * @alpha\n */\nexport interface CorrelationsData {\n correlations: CorrelationData[];\n page: number;\n limit: number;\n totalCount: number;\n}\n\n/**\n * Used to work with user defined correlations.\n * Should be accessed via {@link getCorrelationsService} function.\n *\n * @alpha\n */\nexport interface CorrelationsService {\n /**\n * Creates data links in data frames from provided correlations\n *\n * @param dataFrames list of data frames to be processed\n * @param correlations list of of possible correlations that can be applied\n * @param dataFrameRefIdToDataSourceUid a map that for provided refId references corresponding data source ui\n */\n attachCorrelationsToDataFrames: (\n dataFrames: DataFrame[],\n correlations: CorrelationData[],\n dataFrameRefIdToDataSourceUid: Record<string, string>\n ) => DataFrame[];\n\n /**\n * Creates a link post processor function that handles correlation transformations\n *\n * @param timeRange The current time range\n */\n correlationsDataLinkPostProcessorFactory: (timeRange: TimeRange) => DataLinkPostProcessor;\n\n /**\n * Loads all the correlations defined for the given data sources.\n *\n * @param sourceUIDs Data source UIDs\n */\n getCorrelationsBySourceUIDs: (sourceUIDs: string[]) => Promise<CorrelationsData>;\n}\n\nlet singletonInstance: CorrelationsService;\n\n/**\n * Used during startup by Grafana to set the CorrelationsService so it is available\n * via {@link getCorrelationsService} to the rest of the application.\n *\n * @internal\n */\nexport function setCorrelationsService(instance: CorrelationsService) {\n singletonInstance = instance;\n}\n\n/**\n * Used to retrieve the {@link CorrelationsService}.\n *\n * @alpha\n */\nexport function getCorrelationsService(): CorrelationsService {\n return singletonInstance;\n}\n"],"names":[],"mappings":"AAyGA,IAAI,iBAAA;AAQG,SAAS,uBAAuB,QAA+B,EAAA;AACpE,EAAoB,iBAAA,GAAA,QAAA;AACtB;AAOO,SAAS,sBAA8C,GAAA;AAC5D,EAAO,OAAA,iBAAA;AACT;;;;"}