Clean up the types used in the TS SDK a bit #15
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I believe renaming generics makes it easier to reason about the code and the intended usage.
This pull request refactors the trigger interfaces and implementations throughout the SDK to clarify the distinction between raw trigger output and adapted output types. The changes make the codebase more explicit and flexible, especially for cases where the trigger output needs to be transformed before being used in workflows. Most trigger classes and related types now accept both a raw output type and an adapted output type, and method names and signatures have been updated to reflect this.
Trigger interface and class refactoring
BaseTrigger
andTrigger
interfaces insrc/sdk/utils/triggers/trigger-interface.ts
to useTRawTriggerOutput
andTTriggerOutput
type parameters, and renamed method arguments and documentation to clarify the distinction between raw and adapted output. The default implementation ofadapt
now returns the raw output unchanged. [1] [2]BaseTriggerImpl
with explicit raw and adapted output types, and updated theiradapt
methods to use the new parameter names and documentation. This affects files in blockchain, internal, HTTP, and cron capabilities, as well as the code generator logic. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]Workflow handler and runner updates
src/sdk/workflow.ts
to use the new trigger output type parameters, ensuring that workflow handlers receive the properly adapted output type.Example workflow update
cre.sendResponseValue
in theonCronTrigger
handler insrc/workflows/hello-world/hello-world.ts
to demonstrate usage of the adapted output in a workflow.