Compare commits

...

3 Commits

Author SHA1 Message Date
Alex Yang 6f4445c1a0 fix: no flatten
wtf why I added this
2024-11-13 00:43:11 -08:00
Alex Yang ade95d3af7 fix: no flatten
wtf why I added this
2024-11-13 00:42:48 -08:00
Alex Yang 6a788d771f fix: output event check 2024-11-13 00:34:15 -08:00
2 changed files with 20 additions and 4 deletions
+5 -4
View File
@@ -397,10 +397,11 @@ export class WorkflowContext<Start = string, Stop = string, Data = unknown>
);
}
const outputs = outputsMap.get(step) ?? [];
const outputEvents = flattenEvents(outputs, [
nextEvent,
]);
if (outputEvents.length !== outputs.length) {
if (
!outputs.some(
(output) => nextEvent.constructor === output,
)
) {
if (this.#strict) {
const error = Error(
`Step ${step.name} returned an unexpected output event ${nextEvent}`,
+15
View File
@@ -794,6 +794,21 @@ describe("workflow event loop", () => {
}
`);
});
test("workflow multiple output", async () => {
const myFlow = new Workflow<unknown, string, string>({ verbose: true });
myFlow.addStep(
{
inputs: [StartEvent<string>],
outputs: [StopEvent<string>, StopEvent<string>],
},
async (_context, ev) => {
return new StopEvent(`Hello ${ev.data}!`);
},
);
const result = await myFlow.run("world").strict();
expect(result.data).toBe("Hello world!");
});
});
describe("snapshot", async () => {