diff --git a/x-pack/plugins/integration_assistant/common/api/model/common_attributes.schema.yaml b/x-pack/plugins/integration_assistant/common/api/model/common_attributes.schema.yaml index d876e72bef5b7..899a5f32a1db2 100644 --- a/x-pack/plugins/integration_assistant/common/api/model/common_attributes.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/model/common_attributes.schema.yaml @@ -142,15 +142,3 @@ components: logo: type: string description: The logo of the integration. - - PipelineResults: - type: array - description: An array of pipeline results. - items: - type: object - - Errors: - type: array - description: An array of errors. - items: - type: object diff --git a/x-pack/plugins/integration_assistant/common/api/model/common_attributes.ts b/x-pack/plugins/integration_assistant/common/api/model/common_attributes.ts index d64c53ee388d9..2f446aa3a94e0 100644 --- a/x-pack/plugins/integration_assistant/common/api/model/common_attributes.ts +++ b/x-pack/plugins/integration_assistant/common/api/model/common_attributes.ts @@ -155,15 +155,3 @@ export const Integration = z.object({ */ logo: z.string().optional(), }); - -/** - * An array of pipeline results. - */ -export type PipelineResults = z.infer; -export const PipelineResults = z.array(z.object({})); - -/** - * An array of errors. - */ -export type Errors = z.infer; -export const Errors = z.array(z.object({})); diff --git a/x-pack/plugins/integration_assistant/common/api/model/response_schemas.schema.yaml b/x-pack/plugins/integration_assistant/common/api/model/response_schemas.schema.yaml index 100581cd21ceb..8afbab533a6d3 100644 --- a/x-pack/plugins/integration_assistant/common/api/model/response_schemas.schema.yaml +++ b/x-pack/plugins/integration_assistant/common/api/model/response_schemas.schema.yaml @@ -57,9 +57,12 @@ components: CheckPipelineAPIResponse: type: object required: - - pipelineResults + - results properties: - pipelineResults: - $ref: "./common_attributes.schema.yaml#/components/schemas/PipelineResults" - errors: - $ref: "./common_attributes.schema.yaml#/components/schemas/Errors" + results: + type: object + required: + - docs + properties: + docs: + $ref: "./common_attributes.schema.yaml#/components/schemas/Docs" diff --git a/x-pack/plugins/integration_assistant/common/api/model/response_schemas.ts b/x-pack/plugins/integration_assistant/common/api/model/response_schemas.ts index f8a42d2081488..7e6eee10576f8 100644 --- a/x-pack/plugins/integration_assistant/common/api/model/response_schemas.ts +++ b/x-pack/plugins/integration_assistant/common/api/model/response_schemas.ts @@ -16,7 +16,7 @@ import { z } from 'zod'; -import { Docs, Errors, Mapping, Pipeline, PipelineResults } from './common_attributes'; +import { Docs, Mapping, Pipeline } from './common_attributes'; export type EcsMappingAPIResponse = z.infer; export const EcsMappingAPIResponse = z.object({ @@ -44,6 +44,7 @@ export const RelatedAPIResponse = z.object({ export type CheckPipelineAPIResponse = z.infer; export const CheckPipelineAPIResponse = z.object({ - pipelineResults: PipelineResults, - errors: Errors.optional(), + results: z.object({ + docs: Docs, + }), }); diff --git a/x-pack/plugins/integration_assistant/public/components/create_integration/create_integration_assistant/steps/review_step/use_check_pipeline.ts b/x-pack/plugins/integration_assistant/public/components/create_integration/create_integration_assistant/steps/review_step/use_check_pipeline.ts index 6facf05b2da1f..0bc74f5a287e3 100644 --- a/x-pack/plugins/integration_assistant/public/components/create_integration/create_integration_assistant/steps/review_step/use_check_pipeline.ts +++ b/x-pack/plugins/integration_assistant/public/components/create_integration/create_integration_assistant/steps/review_step/use_check_pipeline.ts @@ -49,17 +49,17 @@ export const useCheckPipeline = ({ const ecsGraphResult = await runCheckPipelineResults(parameters, deps); if (abortController.signal.aborted) return; - if (isEmpty(ecsGraphResult?.pipelineResults) || ecsGraphResult?.errors?.length) { + if (isEmpty(ecsGraphResult?.results.docs)) { setError('No results for the pipeline'); return; } setResult({ pipeline: customPipeline, - docs: ecsGraphResult.pipelineResults, + docs: ecsGraphResult.results.docs, }); } catch (e) { if (abortController.signal.aborted) return; - setError(`Error: ${e.body.message}`); + setError(`Error: ${e.body.message ?? e.message}`); } finally { setIsGenerating(false); } diff --git a/x-pack/plugins/integration_assistant/server/routes/pipeline_routes.ts b/x-pack/plugins/integration_assistant/server/routes/pipeline_routes.ts index 531822b313112..0bf04e566c649 100644 --- a/x-pack/plugins/integration_assistant/server/routes/pipeline_routes.ts +++ b/x-pack/plugins/integration_assistant/server/routes/pipeline_routes.ts @@ -37,11 +37,13 @@ export function registerPipelineRoutes(router: IRouter 0) { - return res.badRequest({ body: JSON.stringify(results.errors) }); + const { errors, pipelineResults } = await testPipeline(rawSamples, pipeline, client); + if (errors?.length) { + return res.badRequest({ body: JSON.stringify(errors) }); } - return res.ok({ body: CheckPipelineResponse.parse(results) }); + return res.ok({ + body: CheckPipelineResponse.parse({ results: { docs: pipelineResults } }), + }); } catch (e) { return res.badRequest({ body: e }); }