-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from allanhvam/dev
feat: trigger output type
- Loading branch information
Showing
12 changed files
with
79 additions
and
31 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { math } from "./math.js"; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { type Trigger } from "../../index.js"; | ||
|
||
export const math = () => { | ||
return { | ||
name: "math", | ||
options: undefined, | ||
start: (workflow: { name: string }, run) => { | ||
console.log(`math: trigger start for ${workflow.name}`); | ||
}, | ||
stop: (workflow: { name: string }) => { | ||
console.log(`math: trigger stop for ${workflow.name}`); | ||
}, | ||
} satisfies Trigger<number, number>; | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { workflow } from "../../workflows/index.js"; | ||
import { MathService } from "../services/MathService.js"; | ||
import { math } from "../triggers/index.js"; | ||
|
||
export const addTow = workflow({ | ||
name: "add-tow", | ||
description: "Adds 2 to argument.", | ||
trigger: math(), | ||
services: { | ||
math: new MathService(), | ||
}, | ||
run: (services) => async (input: number) => { | ||
const output = await services.math.add(input, 2); | ||
return output; | ||
}, | ||
}); |
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,2 +1,2 @@ | ||
export { manual } from "./manual.js"; | ||
export { startup } from "./startup.js"; | ||
export { startup } from "./startup.js"; |
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
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
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,13 +1,11 @@ | ||
import { type IWorkflowHistoryStore } from "../stores/IWorkflowHistoryStore.js"; | ||
|
||
export type WorkflowFunctionReturnType = Promise<any>; | ||
|
||
export type WorkflowFunction = (...args: any[]) => WorkflowFunctionReturnType; | ||
export type WorkflowFunction = (...args: any[]) => Promise<any>; | ||
|
||
export type WorkflowResultType<W extends WorkflowFunction> = ReturnType<W> extends Promise<infer R> ? R : never; | ||
|
||
export type WorkflowHandle<T extends WorkflowFunction> = { | ||
result: () => Promise<WorkflowResultType<T>> | ||
store?: IWorkflowHistoryStore | ||
readonly workflowId: string | ||
result: () => Promise<WorkflowResultType<T>>; | ||
store?: IWorkflowHistoryStore; | ||
readonly workflowId: string; | ||
}; |
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