All files / features / pipelines usePipelineConfigSchema.ts

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

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              90x     8x 8x     90x        
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 }
}