Skip to content

feat(flows): create flow with content and publish in one call - #1194

Open
realcodesiman wants to merge 1 commit into
mainfrom
realcodesiman/create-flow-included-steps
Open

realcodesiman wants to merge 1 commit into
mainfrom
realcodesiman/create-flow-included-steps

Conversation

@realcodesiman

Copy link
Copy Markdown
Contributor

Summary

  • POST /v1/flows (flows.create) now accepts an optional spec (flow-spec DSL) or raw nodes/edges graph to seed the draft's content in the same call, instead of requiring a separate flows.updateDraft/flows.publish round trip.
  • Adds publish: true to validate the supplied graph exactly like flows.publish and create the flow's first immutable version in the same call.
  • For the raw graph shape, node position/measured, node ids, and edge id/handles are all optional/caller-arbitrary — generated or remapped server-side, so only the flow's actual content needs to be sent.

Changes

  • packages/flow-config/src/authoring/normalize-graph.ts (new): normalizeAuthoredGraph lays out positionless nodes with the existing BFS layoutNodes, remaps every caller-authored node id to an internal createId() id (persisted node ids must be numeric per baseNodeSchema/zodBigintAsString, so an arbitrary caller id like "n1" would otherwise fail publishFlowSchema), and rewrites edge ids/handles to match.
  • apps/builder/src/features/flows/lib/resolve-flow-graph-input.ts (new): resolves flows.create's { spec } or { nodes, edges } content into the graph flowService.createDraft persists, running publishFlowSchema validation only when publish: true is requested.
  • packages/business/src/flow/service.ts: flowService.createDraft accepts an optional pre-resolved graph, falling back to today's single default "Send Message" start node when omitted.
  • apps/builder/src/features/flows/schema/action.ts: new createFlowRequest schema (.extend() + .superRefine()) rejecting spec combined with nodes/edges, edges without nodes, and publish: true without content.
  • apps/builder/src/features/flows/api/public.ts: wires flows.create to resolve content, create the draft, and optionally publish; flows.validate handler updated for the new compileAndValidateSpec return shape.
  • Docs updated: docs/flows.md, apps/builder/src/features/capabilities/api/public.ts descriptions, apps/mcp-server/SKILL.md.

Test plan

  • pnpm lint
  • pnpm --filter @chatbotx.io/flow-config check-types
  • pnpm --filter @chatbotx.io/business check-types
  • pnpm --filter builder check-types
  • pnpm --filter @chatbotx.io/flow-config test (555/555)
  • pnpm --filter @chatbotx.io/business test (2631/2631)
  • pnpm --filter builder test (3997/3997, 2 pre-existing skips)
  • Throwaway script verifying normalizeAuthoredGraph end-to-end (positions, id remap, edge handles, startNodeId)
  • Manual verification against a running dev stack (Postgres/Redis/seeded workspace/API token) — not performed; substituted the throwaway script above per project convention

POST /v1/flows now accepts an optional `spec` (flow-spec DSL) or raw
`nodes`/`edges` graph to seed the draft in the same call, plus a
`publish: true` flag to validate and publish it immediately.

- normalizeAuthoredGraph (flow-config): lays out positionless nodes
  with the existing BFS layoutNodes, remaps caller-authored node ids
  to internal createId() ids (baseNodeSchema requires digit-only ids,
  so an arbitrary caller id would fail publishFlowSchema), and
  defaults edge ids/handles to the addHandleEdge convention.
- resolveFlowGraphInput: resolves flows.create's spec/nodes content
  into the graph flowService.createDraft persists, validating via
  publishFlowSchema only when publish is requested.
- flowService.createDraft accepts an optional pre-resolved graph,
  falling back to today's single default start node.
- Docs (docs/flows.md, capabilities API descriptions, MCP SKILL.md)
  updated to describe the new create-with-content workflow.
@github-actions github-actions Bot added the feature New feature or request label Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant