Skip to content

Commit

Permalink
Merge pull request #231 from bhouston/assert-expect-true
Browse files Browse the repository at this point in the history
convert to new node defintion pattern.
  • Loading branch information
bhouston committed Jul 26, 2023
2 parents 7a9abf9 + 1a30315 commit c61e979
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 34 deletions.
63 changes: 30 additions & 33 deletions packages/core/src/Profiles/Core/Debug/AssertExpectTrue.ts
@@ -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');
}
}
});
2 changes: 1 addition & 1 deletion packages/core/src/Profiles/Core/registerCoreProfile.ts
Expand Up @@ -75,7 +75,7 @@ export const getCoreNodesMap = memo<Record<string, NodeDefinition>>(() => {

// actions
DebugLog,
AssertExpectTrue.Description,
AssertExpectTrue,

// events
LifecycleOnStart,
Expand Down

0 comments on commit c61e979

Please sign in to comment.