All files / features / pipelines usePipelineConfigSchema.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19              116x     10x 10x     116x        
import { useQuery } from '@tanstack/react-query'
import { apiClient } from '@/lib/axios'
import { schemaToHelp } from '@/shared/utils/schemaHelp'
import type { ConfigSchemaHelpNode } from '@/layers/interfaces'
 
// Server data (GET /api/v1/config-schemas/pipeline, Phase 4b/4b2): the help
// tree is derived from the fetched JSON Schema document. Loading or error
// simply leaves help absent — the yaml editor works without it.
export function usePipelineConfigSchema(): { help: ConfigSchemaHelpNode[] | undefined } {
  const query = useQuery({
    queryKey: ['config-schema', 'pipeline'],
    queryFn: async () => {
      const { data } = await apiClient.get('/config-schemas/pipeline')
      return schemaToHelp(data)
    },
  })
  return { help: query.data }
}