2222// Each SwitchBranch carries an embedded FlowGraph. The exporter "hoists"
2323// those graphs as named `do` tasks at the top level of the document, then
2424// generates `then: <hoisted-name>` references in the switch entries.
25+ import { isActivityComplexArg } from '$lib/tasks/model' ;
2526import type {
2627 CallActivityConfig ,
2728 CallGRPCConfig ,
@@ -228,17 +229,29 @@ function exportCallActivityConfig(
228229 c : CallActivityConfig ,
229230) : Record < string , unknown > {
230231 const w : Record < string , unknown > = { name : c . name } ;
231- if ( c . arguments !== undefined ) w . arguments = c . arguments ;
232232 if ( c . taskQueue !== undefined ) w . taskQueue = c . taskQueue ;
233+ if ( c . arguments !== undefined ) {
234+ w . arguments = c . arguments . map ( ( arg ) =>
235+ isActivityComplexArg ( arg ) ? arg . value : arg ,
236+ ) ;
237+ }
233238 return { call : 'activity' , with : w } ;
234239}
235240
236241function exportRunContainerConfig (
237242 c : RunContainerConfig ,
238243) : Record < string , unknown > {
239244 const container : Record < string , unknown > = { image : c . image } ;
240- if ( c . arguments !== undefined ) container . arguments = c . arguments ;
245+ if ( c . arguments !== undefined )
246+ container . arguments = c . arguments . map ( ( arg ) =>
247+ isActivityComplexArg ( arg ) ? arg . value : arg ,
248+ ) ;
241249 if ( c . environment !== undefined ) container . environment = c . environment ;
250+ if ( c . workingDirectory !== undefined )
251+ container . workingDirectory = c . workingDirectory ;
252+ if ( c . lifetime !== undefined ) container . lifetime = c . lifetime ;
253+ if ( c . await === false ) container . await = false ;
254+ if ( c . ports !== undefined ) container . ports = c . ports ;
242255 return { run : { container } } ;
243256}
244257
@@ -247,39 +260,56 @@ function exportRunScriptConfig(c: RunScriptConfig): Record<string, unknown> {
247260 language : c . language ,
248261 code : c . code ,
249262 } ;
250- if ( c . arguments !== undefined ) script . arguments = c . arguments ;
263+ if ( c . arguments !== undefined )
264+ script . arguments = c . arguments . map ( ( arg ) =>
265+ isActivityComplexArg ( arg ) ? arg . value : arg ,
266+ ) ;
251267 if ( c . environment !== undefined ) script . environment = c . environment ;
252268 return { run : { script } } ;
253269}
254270
255271function exportRunShellConfig ( c : RunShellConfig ) : Record < string , unknown > {
256272 const shell : Record < string , unknown > = { command : c . command } ;
257- if ( c . arguments !== undefined ) shell . arguments = c . arguments ;
273+ if ( c . arguments !== undefined )
274+ shell . arguments = c . arguments . map ( ( arg ) =>
275+ isActivityComplexArg ( arg ) ? arg . value : arg ,
276+ ) ;
258277 if ( c . environment !== undefined ) shell . environment = c . environment ;
278+ if ( c . workingDirectory !== undefined )
279+ shell . workingDirectory = c . workingDirectory ;
280+ if ( c . await === false ) shell . await = false ;
259281 return { run : { shell } } ;
260282}
261283
262284function exportRunWorkflowConfig (
263285 c : RunWorkflowConfig ,
264286) : Record < string , unknown > {
265- return {
266- run : {
267- workflow : { name : c . name , namespace : c . namespace , version : c . version } ,
268- } ,
287+ const workflow : Record < string , unknown > = {
288+ name : c . name ,
289+ namespace : c . namespace ,
290+ version : c . version ,
269291 } ;
292+ if ( c . await === false ) workflow . await = false ;
293+ return { run : { workflow } } ;
270294}
271295
272296function exportWaitConfig ( c : WaitConfig ) : Record < string , unknown > {
273297 return { wait : c . duration } ;
274298}
275299
276300function exportRaiseConfig ( c : RaiseConfig ) : Record < string , unknown > {
277- const error : Record < string , unknown > = {
278- type : c . errorType ,
279- status : c . errorStatus ,
280- } ;
281- if ( c . errorDetail !== undefined ) error . detail = c . errorDetail ;
282- return { raise : { error } } ;
301+ if ( ! c . definition ) {
302+ return { raise : { error : { } } } ;
303+ }
304+ const definition : Record < string , unknown > = { } ;
305+ if ( c . definition . type !== undefined ) definition [ 'type' ] = c . definition . type ;
306+ if ( c . definition . title !== undefined )
307+ definition [ 'title' ] = c . definition . title ;
308+ if ( c . definition . detail !== undefined )
309+ definition [ 'detail' ] = c . definition . detail ;
310+ if ( c . definition . status !== undefined )
311+ definition [ 'status' ] = c . definition . status ;
312+ return { raise : { error : { definition } } } ;
283313}
284314
285315function exportListenConfig ( c : ListenConfig ) : Record < string , unknown > {
0 commit comments