-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert to new node defintion pattern.
- Loading branch information
Showing
2 changed files
with
31 additions
and
34 deletions.
There are no files selected for viewing
63 changes: 30 additions & 33 deletions
63
packages/core/src/Profiles/Core/Debug/AssertExpectTrue.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,33 @@ | ||
import { Assert } from '../../../Diagnostics/Assert.js'; | ||
import { Fiber } from '../../../Execution/Fiber.js'; | ||
import { IGraphApi } from '../../../Graphs/Graph.js'; | ||
import { FlowNode } from '../../../Nodes/FlowNode.js'; | ||
import { NodeDescription } from '../../../Nodes/Registry/NodeDescription.js'; | ||
import { Socket } from '../../../Sockets/Socket.js'; | ||
import { | ||
makeFlowNodeDefinition, | ||
NodeCategory | ||
} from '../../../Nodes/NodeDefinitions.js'; | ||
|
||
export class ExpectTrue extends FlowNode { | ||
public static Description = new NodeDescription( | ||
'debug/expectTrue', | ||
'Action', | ||
'Assert Expect True', | ||
(description, graph) => new ExpectTrue(description, graph) | ||
); | ||
|
||
constructor(description: NodeDescription, graph: IGraphApi) { | ||
super( | ||
description, | ||
graph, | ||
[ | ||
new Socket('flow', 'flow'), | ||
new Socket('boolean', 'condition'), | ||
new Socket('string', 'description') | ||
], | ||
[new Socket('flow', 'flow')] | ||
); | ||
} | ||
|
||
triggered(fiber: Fiber, triggeredSocketName: string) { | ||
Assert.mustBeTrue( | ||
this.readInput('condition'), | ||
this.readInput('description') | ||
); | ||
fiber.commit(this, 'flow'); | ||
export const ExpectTrue = makeFlowNodeDefinition({ | ||
typeName: 'debug/expectTrue', | ||
category: NodeCategory.Action, | ||
label: 'Assert Expect True', | ||
in: () => { | ||
return [ | ||
{ | ||
key: 'flow', | ||
valueType: 'flow' | ||
}, | ||
{ | ||
key: 'condition', | ||
valueType: 'boolean' | ||
}, | ||
{ | ||
key: 'description', | ||
valueType: 'string' | ||
} | ||
]; | ||
}, | ||
initialState: undefined, | ||
out: { flow: 'flow' }, | ||
triggered: ({ read, commit }) => { | ||
Assert.mustBeTrue(read('condition'), read('description')); | ||
commit('flow'); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters