feat(flows): create flow with content and publish in one call - #1194
Open
realcodesiman wants to merge 1 commit into
Open
realcodesiman wants to merge 1 commit into
realcodesiman wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /v1/flows(flows.create) now accepts an optionalspec(flow-spec DSL) or rawnodes/edgesgraph to seed the draft's content in the same call, instead of requiring a separateflows.updateDraft/flows.publishround trip.publish: trueto validate the supplied graph exactly likeflows.publishand create the flow's first immutable version in the same call.position/measured, node ids, and edgeid/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):normalizeAuthoredGraphlays out positionless nodes with the existing BFSlayoutNodes, remaps every caller-authored node id to an internalcreateId()id (persisted node ids must be numeric perbaseNodeSchema/zodBigintAsString, so an arbitrary caller id like"n1"would otherwise failpublishFlowSchema), and rewrites edge ids/handles to match.apps/builder/src/features/flows/lib/resolve-flow-graph-input.ts(new): resolvesflows.create's{ spec }or{ nodes, edges }content into the graphflowService.createDraftpersists, runningpublishFlowSchemavalidation only whenpublish: trueis requested.packages/business/src/flow/service.ts:flowService.createDraftaccepts an optional pre-resolvedgraph, falling back to today's single default "Send Message" start node when omitted.apps/builder/src/features/flows/schema/action.ts: newcreateFlowRequestschema (.extend()+.superRefine()) rejectingspeccombined withnodes/edges,edgeswithoutnodes, andpublish: truewithout content.apps/builder/src/features/flows/api/public.ts: wiresflows.createto resolve content, create the draft, and optionally publish;flows.validatehandler updated for the newcompileAndValidateSpecreturn shape.docs/flows.md,apps/builder/src/features/capabilities/api/public.tsdescriptions,apps/mcp-server/SKILL.md.Test plan
pnpm lintpnpm --filter @chatbotx.io/flow-config check-typespnpm --filter @chatbotx.io/business check-typespnpm --filter builder check-typespnpm --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)normalizeAuthoredGraphend-to-end (positions, id remap, edge handles,startNodeId)