UNPKG

@grafana/alerting

Version:

Grafana Alerting Library – Build vertical integrations on top of the industry-leading alerting solution

1 lines 1.95 kB
{"version":3,"file":"useRoutingTrees.mjs","sources":["../../../../../src/grafana/notificationPolicies/hooks/useRoutingTrees.ts"],"sourcesContent":["import { type TypedUseQueryHookResult, type fetchBaseQuery } from '@reduxjs/toolkit/query/react';\n\nimport {\n type ListRoutingTreeApiArg,\n type ListRoutingTreeApiResponse,\n generatedAPI as notificationsAPIv0alpha1,\n} from '@grafana/api-clients/rtkq/notifications.alerting/v0alpha1';\n\ntype ListRoutingTreesHookResult = TypedUseQueryHookResult<\n ListRoutingTreeApiResponse,\n ListRoutingTreeApiArg,\n ReturnType<typeof fetchBaseQuery>\n>;\n\ntype ListRoutingTreesQueryArgs = Parameters<\n typeof notificationsAPIv0alpha1.endpoints.listRoutingTree.useQuery<ListRoutingTreesHookResult>\n>[0];\n\ntype ListRoutingTreesQueryOptions = Parameters<\n typeof notificationsAPIv0alpha1.endpoints.listRoutingTree.useQuery<ListRoutingTreesHookResult>\n>[1];\n\n/**\n * useListRoutingTrees is a hook that fetches a list of routing trees (notification policy trees).\n *\n * This function wraps the notificationsAPIv0alpha1.useListRoutingTreeQuery with proper typing.\n *\n * When the `alertingMultiplePolicies` feature toggle is enabled on the backend, this returns all\n * available routing trees. Otherwise, it returns only the default \"user-defined\" tree.\n *\n * @param queryArgs - Optional query arguments for filtering, pagination, etc.\n * @param queryOptions - Optional query options (refetchOnFocus, skip, etc.)\n */\nexport function useListRoutingTrees(\n queryArgs: ListRoutingTreesQueryArgs = {},\n queryOptions: ListRoutingTreesQueryOptions = {}\n): ListRoutingTreesHookResult {\n return notificationsAPIv0alpha1.useListRoutingTreeQuery<ListRoutingTreesHookResult>(queryArgs, queryOptions);\n}\n"],"names":["notificationsAPIv0alpha1"],"mappings":";;;AAiCO,SAAS,oBACd,SAAA,GAAuC,EAAC,EACxC,YAAA,GAA6C,EAAC,EAClB;AAC5B,EAAA,OAAOA,YAAA,CAAyB,uBAAA,CAAoD,SAAA,EAAW,YAAY,CAAA;AAC7G;;;;"}