Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export interface PreviewRequest {
}

export interface Reference {
content?: string
location?: string
content: string
location: string
name?: string
}

export interface VersionRequest {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/core/workflow-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export class WorkflowDeploy {
): Promise<WorkflowVersionResponse | undefined> {
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)
Expand Down
31 changes: 30 additions & 1 deletion test/commands/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import nock from 'nock'
import {stub} from 'sinon'

import {API} from '../../src/definition'

nock.disableNetConnect()

Check warning on line 8 in test/commands/deploy.test.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on macos-latest

Caution: `nock` also has a named export `disableNetConnect`. Check if you meant to write `import {disableNetConnect} from 'nock'` instead

process.env.BUMP_TOKEN = process.env.BUMP_TOKEN || 'BAR'

Expand Down Expand Up @@ -90,7 +92,7 @@

it("doesn't try to auto create a documentation", async () => {
nock('https://bump.sh')
.post('/api/v1/validations', (body) => !body.auto_create_documentation)

Check warning on line 95 in test/commands/deploy.test.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on macos-latest

Too many nested callbacks (5). Maximum allowed is 4
.reply(200)

await runCommand(
Expand All @@ -110,7 +112,7 @@
})

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(
Expand All @@ -123,6 +125,33 @@
)
})

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)

Expand Down
Loading