File tree Expand file tree Collapse file tree
apps/sim/lib/workflows/migrations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,25 +97,31 @@ function migrateBlockSubblockIds(
9797 continue
9898 }
9999
100- const oldEntry = result [ oldId ]
100+ const oldEntry : unknown = result [ oldId ]
101101 const configuredType = blockConfig ?. subBlocks ?. find ( ( config ) => config . id === newId ) ?. type
102- result [ newId ] = isPlainRecord ( oldEntry )
103- ? {
104- ...oldEntry ,
105- id : newId ,
106- type :
107- configuredType ||
108- ( typeof oldEntry . type === 'string' && oldEntry . type . length > 0
109- ? oldEntry . type === 'unknown'
110- ? DEFAULT_SUBBLOCK_TYPE
111- : oldEntry . type
112- : DEFAULT_SUBBLOCK_TYPE ) ,
113- }
114- : ( {
115- id : newId ,
116- type : configuredType || DEFAULT_SUBBLOCK_TYPE ,
117- value : oldEntry ,
118- } as BlockState [ 'subBlocks' ] [ string ] )
102+ if ( isPlainRecord ( oldEntry ) ) {
103+ const type =
104+ configuredType ||
105+ ( typeof oldEntry . type === 'string' && oldEntry . type . length > 0
106+ ? oldEntry . type === 'unknown'
107+ ? DEFAULT_SUBBLOCK_TYPE
108+ : oldEntry . type
109+ : DEFAULT_SUBBLOCK_TYPE )
110+ const value = Object . hasOwn ( oldEntry , 'value' ) ? oldEntry . value : null
111+
112+ result [ newId ] = {
113+ ...oldEntry ,
114+ id : newId ,
115+ type : type as BlockState [ 'subBlocks' ] [ string ] [ 'type' ] ,
116+ value : value as BlockState [ 'subBlocks' ] [ string ] [ 'value' ] ,
117+ }
118+ } else {
119+ result [ newId ] = {
120+ id : newId ,
121+ type : configuredType || DEFAULT_SUBBLOCK_TYPE ,
122+ value : oldEntry as BlockState [ 'subBlocks' ] [ string ] [ 'value' ] ,
123+ }
124+ }
119125 delete result [ oldId ]
120126 }
121127
You can’t perform that action at this time.
0 commit comments