@@ -1107,15 +1107,19 @@ describe('validateStackExpressions (ADR-0032 build-time)', () => {
11071107 // record-change trigger's — so a sweep of the object the conditions are
11081108 // typed against gets the run-fails verdict, bare name included. A sweep of
11091109 // another object binds a row of THAT object: the warning stays.
1110- it ( 'refuses a type mismatch on a time-relative sweep of the flow object, and warns on a sweep of another (#29959)' , ( ) => {
1111- const flowOf = ( name : string , sweepObject : string | undefined ) => ( {
1110+ // [#30026] A start naming no `objectName` is typed against the swept
1111+ // object (`timeRelative.object`, which the schema requires): its record IS
1112+ // that row, so `tr_sweep_only` is refused like `tr_same`. Before, it got no
1113+ // type verdict at all.
1114+ it ( 'refuses a type mismatch on a time-relative sweep of the typed object, and warns on a sweep of another (#29959, #30026)' , ( ) => {
1115+ const flowOf = ( name : string , startObject : string | undefined , sweepObject : string ) => ( {
11121116 name,
11131117 nodes : [
11141118 {
11151119 id : 'start' , type : 'start' ,
11161120 config : {
1117- objectName : 'crm_opportunity' , condition : 'title > 5' , schedule : '0 * * * *' ,
1118- timeRelative : { ... ( sweepObject ? { object : sweepObject } : { } ) , dateField : 'close_date' , offsetDays : 3 } ,
1121+ ... ( startObject ? { objectName : startObject } : { } ) , condition : 'title > 5' , schedule : '0 * * * *' ,
1122+ timeRelative : { object : sweepObject , dateField : 'close_date' , offsetDays : 3 } ,
11191123 } ,
11201124 } ,
11211125 { id : 'route' , type : 'decision' , config : { conditions : [ { label : 'Long' , expression : 'record.title > 5' } ] } } ,
@@ -1130,12 +1134,12 @@ describe('validateStackExpressions (ADR-0032 build-time)', () => {
11301134 { name : 'crm_opportunity' , fields : { title : { type : 'text' , required : true } , close_date : { type : 'date' } } } ,
11311135 { name : 'crm_task' , fields : { close_date : { type : 'date' } } } ,
11321136 ] ;
1133- for ( const [ name , sweepObject , severity ] of [
1134- [ 'tr_default ' , undefined , 'error' ] ,
1135- [ 'tr_same' , 'crm_opportunity' , 'error' ] ,
1136- [ 'tr_other' , 'crm_task' , 'warning' ] ,
1137+ for ( const [ name , startObject , sweepObject , severity ] of [
1138+ [ 'tr_sweep_only ' , undefined , 'crm_opportunity' , 'error' ] ,
1139+ [ 'tr_same' , 'crm_opportunity' , 'crm_opportunity' , ' error'] ,
1140+ [ 'tr_other' , 'crm_opportunity' , ' crm_task', 'warning' ] ,
11371141 ] as const ) {
1138- const found = typeMismatches ( validateStackExpressions ( { objects, flows : [ flowOf ( name , sweepObject ) ] } ) ) ;
1142+ const found = typeMismatches ( validateStackExpressions ( { objects, flows : [ flowOf ( name , startObject , sweepObject ) ] } ) ) ;
11391143 expect ( found . map ( i => [ i . where , i . severity ] ) , name ) . toEqual ( [
11401144 [ `flow '${ name } ' · node 'start' (start) condition` , severity ] ,
11411145 [ `flow '${ name } ' · node 'route' (decision) decision branch expression at config.conditions[0].expression` , severity ] ,
@@ -1149,6 +1153,73 @@ describe('validateStackExpressions (ADR-0032 build-time)', () => {
11491153 }
11501154 } ) ;
11511155
1156+ // [#30026] Where the sweep is of another object, the author is told why the
1157+ // verdict is only a warning: once, at the start node's `objectName`, and
1158+ // only on a flow that was served a warning it explains.
1159+ it ( 'says why a time-relative sweep of another object only warns, once, where a warning was served (#30026)' , ( ) => {
1160+ const objects = [
1161+ { name : 'crm_opportunity' , fields : { title : { type : 'text' , required : true } , close_date : { type : 'date' } } } ,
1162+ { name : 'crm_task' , fields : { close_date : { type : 'date' } } } ,
1163+ ] ;
1164+ const flowOf = ( name : string , startObject : string | undefined , sweepObject : string , condition : string ) => ( {
1165+ name,
1166+ nodes : [
1167+ {
1168+ id : 'start' , type : 'start' ,
1169+ config : {
1170+ ...( startObject ? { objectName : startObject } : { } ) , condition, schedule : '0 * * * *' ,
1171+ timeRelative : { object : sweepObject , dateField : 'close_date' , offsetDays : 3 } ,
1172+ } ,
1173+ } ,
1174+ { id : 'end' , type : 'end' } ,
1175+ ] ,
1176+ edges : [ { id : 'e1' , source : 'start' , target : 'end' , condition } ] ,
1177+ } ) ;
1178+ const notes = ( issues : ReturnType < typeof validateStackExpressions > ) =>
1179+ issues . filter ( i => i . where . endsWith ( '(start) config.objectName' ) ) ;
1180+ const other = validateStackExpressions ( { objects, flows : [ flowOf ( 'tr_other' , 'crm_opportunity' , 'crm_task' , 'title > 5' ) ] } ) ;
1181+ expect ( notes ( other ) . map ( i => [ i . where , i . severity , i . path , i . source ] ) ) . toEqual ( [
1182+ [ "flow 'tr_other' · node 'start' (start) config.objectName" , 'warning' , 'flows[0].nodes[0].config.objectName' , 'crm_opportunity' ] ,
1183+ ] ) ;
1184+ expect ( notes ( other ) [ 0 ] ! . message ) . toContain ( "each run's record is a row of 'crm_task'" ) ;
1185+ expect ( notes ( other ) [ 0 ] ! . message ) . toContain ( "Set config.objectName to 'crm_task', or remove it" ) ;
1186+ // No warning to explain, or no other object: no note.
1187+ for ( const [ name , startObject , sweepObject , condition ] of [
1188+ [ 'tr_other_clean' , 'crm_opportunity' , 'crm_task' , 'size(title) > 5' ] ,
1189+ [ 'tr_same' , 'crm_opportunity' , 'crm_opportunity' , 'title > 5' ] ,
1190+ [ 'tr_sweep_only' , undefined , 'crm_opportunity' , 'title > 5' ] ,
1191+ ] as const ) {
1192+ expect ( notes ( validateStackExpressions ( { objects, flows : [ flowOf ( name , startObject , sweepObject , condition ) ] } ) ) , name ) . toEqual ( [ ] ) ;
1193+ }
1194+ } ) ;
1195+
1196+ // [#30026] Typed against the swept object, a well-typed sweep-only flow
1197+ // stays clean: its fields resolve, so nothing is refused that runs.
1198+ it ( 'leaves a well-typed time-relative flow typed only by its swept object clean (#30026)' , ( ) => {
1199+ const issues = validateStackExpressions ( {
1200+ objects : [ { name : 'crm_opportunity' , fields : { title : { type : 'text' , required : true } , amount : { type : 'number' , required : true } , close_date : { type : 'date' } } } ] ,
1201+ flows : [ {
1202+ name : 'tr_sweep_only' ,
1203+ nodes : [
1204+ {
1205+ id : 'start' , type : 'start' ,
1206+ config : {
1207+ condition : 'size(title) > 5 && record.amount > 10' , schedule : '0 * * * *' ,
1208+ timeRelative : { object : 'crm_opportunity' , dateField : 'close_date' , offsetDays : 3 } ,
1209+ } ,
1210+ } ,
1211+ { id : 'route' , type : 'decision' , config : { conditions : [ { label : 'Big' , expression : 'amount > 10' } ] } } ,
1212+ { id : 'end' , type : 'end' } ,
1213+ ] ,
1214+ edges : [
1215+ { id : 'e1' , source : 'start' , target : 'route' , condition : "record.title != 'x'" } ,
1216+ { id : 'e2' , source : 'route' , target : 'end' , label : 'Big' } ,
1217+ ] ,
1218+ } ] ,
1219+ } ) ;
1220+ expect ( issues ) . toEqual ( [ ] ) ;
1221+ } ) ;
1222+
11521223 // [#29959] `seedRunVariables` seeds the flow's declared variables before it
11531224 // flattens the record, and the flattening skips a name already bound: a
11541225 // bare `title` here reads the NUMBER variable and `title > 5` runs. Only
@@ -3975,7 +4046,8 @@ const READ_SURFACES: Array<{ receiver: string; expected: string[]; declaredBy: s
39754046 keys : ( ) => shapeKeysOf ( ObjectStackSchema . shape . flows ) ,
39764047 } ,
39774048 { receiver : 'node' , expected : [ 'config' , 'id' , 'type' ] , declaredBy : 'flows[].nodes[]' , keys : ( ) => shapeKeysOf ( flowShape ( ) . nodes ) } ,
3978- { receiver : 'startNode' , expected : [ 'config' ] , declaredBy : 'flows[].nodes[]' , keys : ( ) => shapeKeysOf ( flowShape ( ) . nodes ) } ,
4049+ // [#30026] `id`: the time-relative note names the start node it sits on.
4050+ { receiver : 'startNode' , expected : [ 'config' , 'id' ] , declaredBy : 'flows[].nodes[]' , keys : ( ) => shapeKeysOf ( flowShape ( ) . nodes ) } ,
39794051 {
39804052 receiver : 'edge' ,
39814053 expected : [ 'condition' , 'id' , 'source' , 'target' ] ,
0 commit comments