File tree Expand file tree Collapse file tree 5 files changed +11
-11
lines changed Expand file tree Collapse file tree 5 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ export const defineWorkflow =
51
51
...transition ,
52
52
from : transition . from ? setOf ( many ( transition . from ) ) : undefined ,
53
53
key : ( transition . key ?? uuid . v5 ( name , input . id ) ) as ID ,
54
- conditions : maybeMany ( transition . conditions ) ,
54
+ conditions : maybeMany ( transition . conditions ) ?? [ ] ,
55
55
notifiers : [
56
56
...( input . defaultNotifiers ?? [ ] ) ,
57
57
...( maybeMany ( transition . notifiers ) ?? [ ] ) ,
Original file line number Diff line number Diff line change @@ -171,10 +171,10 @@ export class SerializedWorkflow extends DataObject {
171
171
relatedStates :
172
172
transition . to . relatedStates ?. map ( serializeState ) ?? [ ] ,
173
173
} ,
174
- conditions : ( transition . conditions ?? [ ] ) . map ( ( condition ) => ( {
174
+ conditions : transition . conditions . map ( ( condition ) => ( {
175
175
label : condition . description ,
176
176
} ) ) ,
177
- notifiers : ( transition . notifiers ?? [ ] ) . map ( ( notifier ) => ( {
177
+ notifiers : transition . notifiers . map ( ( notifier ) => ( {
178
178
label : notifier . description ,
179
179
} ) ) ,
180
180
permissions : getPermissions ( transition ) ,
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export type InternalTransition<
26
26
name : Names ;
27
27
key : ID ;
28
28
from ?: ReadonlySet < State > ;
29
- conditions ? : ReadonlyArray < TransitionCondition < Context > > ;
30
- notifiers ? : ReadonlyArray < TransitionNotifier < Context > > ;
29
+ conditions : ReadonlyArray < TransitionCondition < Context > > ;
30
+ notifiers : ReadonlyArray < TransitionNotifier < Context > > ;
31
31
} >
32
32
> ;
Original file line number Diff line number Diff line change @@ -75,9 +75,10 @@ export const WorkflowFlowchart = <W extends Workflow>(workflow: () => W) => {
75
75
: `--> ${ dynamicToId ( t . to ) } ` ;
76
76
const endHalf = `${ endId } {{ ${ t . label } }}:::${ t . type } ${ to } ` ;
77
77
78
- const conditions = t . conditions
79
- ? '--"' + t . conditions . map ( ( c ) => c . description ) . join ( '\\n' ) + '"'
80
- : '' ;
78
+ const conditions =
79
+ t . conditions . length > 0
80
+ ? '--"' + t . conditions . map ( ( c ) => c . description ) . join ( '\\n' ) + '"'
81
+ : '' ;
81
82
const from = ( t . from ? [ ...t . from ] . map ( useState ) : [ '*(*)' ] ) . join (
82
83
' & ' ,
83
84
) ;
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ export const WorkflowService = <W extends Workflow>(workflow: () => W) => {
59
59
) ;
60
60
61
61
// Resolve conditions & filter as needed
62
- const conditions = available . flatMap ( ( t ) => t . conditions ?? [ ] ) ;
62
+ const conditions = available . flatMap ( ( t ) => t . conditions ) ;
63
63
const resolvedConditions = new Map (
64
64
await Promise . all (
65
65
[ ...new Set ( conditions ) ] . map (
@@ -69,8 +69,7 @@ export const WorkflowService = <W extends Workflow>(workflow: () => W) => {
69
69
) ,
70
70
) ;
71
71
available = available . flatMap ( ( t ) => {
72
- const conditions =
73
- t . conditions ?. map ( ( c ) => resolvedConditions . get ( c ) ! ) ?? [ ] ;
72
+ const conditions = t . conditions . map ( ( c ) => resolvedConditions . get ( c ) ! ) ;
74
73
if ( conditions . some ( ( c ) => c . status === 'OMIT' ) ) {
75
74
return [ ] ;
76
75
}
You can’t perform that action at this time.
0 commit comments