diff --git a/src/api/models.ts b/src/api/models.ts index 448cb4c4..03e7dbbb 100644 --- a/src/api/models.ts +++ b/src/api/models.ts @@ -23,8 +23,9 @@ export interface PreviewRequest { } export interface Reference { - content?: string - location?: string + content: string + location: string + name?: string } export interface VersionRequest { @@ -82,6 +83,10 @@ export interface DiffItem { export interface WorkflowVersionRequest { definition: string // workflowDefinition + // List of API references attached to the + // workflow (source descriptions in Arazzo + // vocabulary) + references?: Reference[] } export interface WorkflowVersionResponse { diff --git a/src/core/workflow-deploy.ts b/src/core/workflow-deploy.ts index 9b19141f..10824eb7 100644 --- a/src/core/workflow-deploy.ts +++ b/src/core/workflow-deploy.ts @@ -50,9 +50,9 @@ export class WorkflowDeploy { ): Promise { let version: WorkflowVersionResponse | undefined - const request: WorkflowVersionRequest = { - definition: workflowDefinition.rawDefinition, - } + const [definition, references] = await workflowDefinition.extractDefinition() + + const request: WorkflowVersionRequest = {definition, references} // eslint-disable-next-line prefer-const version = await this.createWorkflowVersion(mcpServer, request, token) diff --git a/test/commands/deploy.test.ts b/test/commands/deploy.test.ts index e8ae5db0..fd31229c 100644 --- a/test/commands/deploy.test.ts +++ b/test/commands/deploy.test.ts @@ -3,6 +3,8 @@ import {expect} from 'chai' import nock from 'nock' import {stub} from 'sinon' +import {API} from '../../src/definition' + nock.disableNetConnect() process.env.BUMP_TOKEN = process.env.BUMP_TOKEN || 'BAR' @@ -110,7 +112,7 @@ describe('deploy subcommand', () => { }) describe('Successful runs with MCP server', () => { - it('sends new workflow definition to Bump', async () => { + it('sends new workflow definition (flower) to Bump', async () => { nock('https://bump.sh').post('/api/v1/mcp_servers/crab/deploy').reply(201, {}) const {stderr, stdout} = await runCommand( @@ -123,6 +125,33 @@ describe('deploy subcommand', () => { ) }) + it('sends new workflow definition with openapi sources (arazzo) to Bump', async () => { + const [definition, references] = await ( + await API.load('examples/valid/arazzo/wikimedia.json') + ).extractDefinition() + nock('https://bump.sh') + .post('/api/v1/mcp_servers/crab/deploy', (body) => { + const {content: expectedContent, location: expectedLocation, name: expectedName} = references[0] + const {content: actualContent, location: actualLocation, name: actualName} = body.references[0] + return ( + body.definition === definition && + expectedContent === actualContent && + expectedName === actualName && + expectedLocation === actualLocation + ) + }) + .reply(201, {}) + + const {stderr, stdout} = await runCommand( + ['deploy', 'examples/valid/arazzo/wikimedia.json', '--mcp-server', 'crab'].join(' '), + ) + + expect(stderr).to.contain("Let's deploy on Bump.sh... done\n") + expect(stdout).to.contain( + 'Your crab MCP server...has received a new workflow definition which will soon be ready.', + ) + }) + it('sends unchanged workflow definition to Bump', async () => { nock('https://bump.sh').post('/api/v1/mcp_servers/crab/deploy').reply(204)