@@ -84,15 +84,17 @@ export class ProcessController {
8484
8585 @ApiOperation ( { summary : 'Get a process by ID' } )
8686 @ApiParam ( { name : 'id' , description : 'Process ID' , format : 'uuid' } )
87- @ApiQuery ( { name : 'predict' , description : 'Predict next states' , type : 'boolean' } )
87+ @ApiQuery ( { name : 'events' , description : 'Return the process events' , type : 'boolean' } )
88+ @ApiQuery ( { name : 'prediction' , description : 'Predict next states' , type : 'boolean' } )
8889 @ApiResponse ( { status : 200 , description : 'Success' } )
8990 @ApiProduces ( 'application/json' )
9091 @Get ( '/:id' )
9192 public async get (
9293 @Param ( 'id' ) id : string ,
9394 @AuthUser ( ) user : Account | undefined ,
9495 @AuthApiKey ( ) apiKey : ApiKey | undefined ,
95- @Query ( 'predict' ) withPrediction : boolean | undefined ,
96+ @Query ( 'events' ) withEvents : boolean | undefined ,
97+ @Query ( 'prediction' ) withPrediction : boolean | undefined ,
9698 @Res ( ) res : Response ,
9799 ) : Promise < void > {
98100 if ( ! ( await this . processes . has ( id ) ) ) {
@@ -115,12 +117,16 @@ export class ProcessController {
115117 if ( withPrediction ) {
116118 process = this . processes . predict ( process ) ;
117119 }
120+ if ( ! withEvents ) {
121+ delete process . events ;
122+ }
118123
119124 res . status ( 200 ) . json ( process ) ;
120125 }
121126
122127 @ApiOperation ( { summary : 'Start a process' } )
123- @ApiQuery ( { name : 'predict' , description : 'Predict next states' , type : 'boolean' } )
128+ @ApiQuery ( { name : 'events' , description : 'Return the process events' , type : 'boolean' } )
129+ @ApiQuery ( { name : 'prediction' , description : 'Predict next states' , type : 'boolean' } )
124130 @ApiHeader ( {
125131 name : 'As-Actor' ,
126132 description :
@@ -136,7 +142,8 @@ export class ProcessController {
136142 @Headers ( 'As-Actor' ) actor : string | undefined ,
137143 @AuthUser ( ) user : Account | undefined ,
138144 @AuthApiKey ( ) apiKey : ApiKey | undefined ,
139- @Query ( 'predict' ) addPrediction : boolean | undefined ,
145+ @Query ( 'events' ) withEvents : boolean | undefined ,
146+ @Query ( 'prediction' ) withPrediction : boolean | undefined ,
140147 @Body ( ) instructions : StartInstructions ,
141148 @Res ( ) res : Response ,
142149 ) : Promise < void > {
@@ -157,16 +164,21 @@ export class ProcessController {
157164 process = await this . doStep ( process , user , apiKey , action , actor , response , res ) ;
158165 if ( ! process ) return ;
159166
160- if ( addPrediction ) {
167+ if ( withPrediction ) {
161168 process = this . processes . predict ( process ) ;
162169 }
170+ if ( ! withEvents ) {
171+ delete process . events ;
172+ }
163173
164174 res . status ( 201 ) . header ( 'Location' , `/processes/${ process . id } ` ) . json ( process ) ;
165175 }
166176
167177 @ApiOperation ( { summary : 'Step through a process' } )
168178 @ApiParam ( { name : 'id' , description : 'Process ID' , format : 'uuid' } )
169179 @ApiParam ( { name : 'action' , description : 'Process action' } )
180+ @ApiQuery ( { name : 'events' , description : 'Return the process events' , type : 'boolean' } )
181+ @ApiQuery ( { name : 'prediction' , description : 'Predict next states' , type : 'boolean' } )
170182 @ApiHeader ( {
171183 name : 'As-Actor' ,
172184 description :
@@ -184,7 +196,8 @@ export class ProcessController {
184196 @Headers ( 'As-Actor' ) actor : string | undefined ,
185197 @AuthUser ( ) user : Account | undefined ,
186198 @AuthApiKey ( ) apiKey : ApiKey | undefined ,
187- @Query ( 'predict' ) addPrediction : boolean | undefined ,
199+ @Query ( 'events' ) withEvents : boolean | undefined ,
200+ @Query ( 'prediction' ) withPrediction : boolean | undefined ,
188201 @Body ( ) body : any ,
189202 @Res ( ) res : Response ,
190203 ) : Promise < void > {
@@ -203,9 +216,12 @@ export class ProcessController {
203216 process = await this . doStep ( process , user , apiKey , action , actor , body , res ) ;
204217 if ( ! process ) return ;
205218
206- if ( addPrediction ) {
219+ if ( withPrediction ) {
207220 process = this . processes . predict ( process ) ;
208221 }
222+ if ( ! withEvents ) {
223+ delete process . events ;
224+ }
209225
210226 res . status ( 200 ) . json ( process ) ;
211227 }
0 commit comments