File tree Expand file tree Collapse file tree 4 files changed +37
-3
lines changed Expand file tree Collapse file tree 4 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 1010
1111import type * as admin from "../admin.js" ;
1212import type * as example from "../example.js" ;
13+ import type * as nestedWorkflow from "../nestedWorkflow.js" ;
1314import type * as transcription from "../transcription.js" ;
1415import type * as userConfirmation_steps from "../userConfirmation/steps.js" ;
1516import type * as userConfirmation_workflow from "../userConfirmation/workflow.js" ;
@@ -31,6 +32,7 @@ import type {
3132declare const fullApi : ApiFromModules < {
3233 admin : typeof admin ;
3334 example : typeof example ;
35+ nestedWorkflow : typeof nestedWorkflow ;
3436 transcription : typeof transcription ;
3537 "userConfirmation/steps" : typeof userConfirmation_steps ;
3638 "userConfirmation/workflow" : typeof userConfirmation_workflow ;
Original file line number Diff line number Diff line change 1+ import { v } from "convex/values" ;
2+ import { workflow } from "./example" ;
3+ import { internal } from "./_generated/api" ;
4+
5+ export const parentWorkflow = workflow . define ( {
6+ args : { prompt : v . string ( ) } ,
7+ returns : v . null ( ) ,
8+ handler : async ( ctx , args ) => {
9+ console . log ( "Starting confirmation workflow" ) ;
10+ const length = await ctx . runWorkflow (
11+ internal . nestedWorkflow . nestedWorkflow ,
12+ { foo : args . prompt } ,
13+ ) ;
14+ console . log ( "Length:" , length ) ;
15+ } ,
16+ } ) ;
17+
18+ export const nestedWorkflow = workflow . define ( {
19+ args : { foo : v . string ( ) } ,
20+ returns : v . number ( ) ,
21+ handler : async ( _ , args ) => {
22+ console . log ( "Starting nested workflow" ) ;
23+ return args . foo . length ;
24+ } ,
25+ } ) ;
Original file line number Diff line number Diff line change @@ -15,7 +15,12 @@ import {
1515 type RegisteredMutation ,
1616 type ReturnValueForOptionalValidator ,
1717} from "convex/server" ;
18- import type { ObjectType , PropertyValidators , Validator } from "convex/values" ;
18+ import type {
19+ Infer ,
20+ ObjectType ,
21+ PropertyValidators ,
22+ Validator ,
23+ } from "convex/values" ;
1924import type { Step } from "../component/schema.js" ;
2025import type {
2126 EventId ,
@@ -113,7 +118,9 @@ export class WorkflowManager {
113118 fn : "You should not call this directly, call workflow.start instead" ;
114119 args : ObjectType < ArgsValidator > ;
115120 } ,
116- void
121+ ReturnsValidator extends Validator < unknown , "required" , string >
122+ ? Infer < ReturnsValidator >
123+ : void
117124 > {
118125 return workflowMutation (
119126 this . component ,
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export type WorkflowCtx = {
9191 */
9292 runWorkflow < Workflow extends FunctionReference < "mutation" , "internal" > > (
9393 workflow : Workflow ,
94- args : FunctionArgs < Workflow > ,
94+ args : FunctionArgs < Workflow > [ "args" ] ,
9595 opts ?: RunOptions ,
9696 ) : Promise < FunctionReturnType < Workflow > > ;
9797
You can’t perform that action at this time.
0 commit comments