Skip to content

Conversation

ernest-nowacki
Copy link
Contributor

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

  • Updated the BaseTrigger and Trigger interfaces in src/sdk/utils/triggers/trigger-interface.ts to use TRawTriggerOutput and TTriggerOutput type parameters, and renamed method arguments and documentation to clarify the distinction between raw and adapted output. The default implementation of adapt now returns the raw output unchanged. [1] [2]
  • Refactored all generated and manual trigger classes to extend the new BaseTriggerImpl with explicit raw and adapted output types, and updated their adapt 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

  • Updated the workflow handler types and utility functions in 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

  • Added a call to cre.sendResponseValue in the onCronTrigger handler in src/workflows/hello-world/hello-world.ts to demonstrate usage of the adapted output in a workflow.

@ernest-nowacki ernest-nowacki requested a review from a team as a code owner August 26, 2025 16:44
fmonper1
fmonper1 previously approved these changes Aug 26, 2025
@fmonper1 fmonper1 enabled auto-merge (squash) August 28, 2025 07:46
@ernest-nowacki ernest-nowacki removed the request for review from TJBigelow August 29, 2025 09:12
@fmonper1 fmonper1 merged commit f902a6b into main Aug 29, 2025
7 checks passed
@fmonper1 fmonper1 deleted the feat/types branch August 29, 2025 09:53
jeffrifwaldsmartcontract pushed a commit that referenced this pull request Aug 29, 2025
* Rename trigger related generics to more understadable names

* Improve base class for trigger generator

* Send response back to the engine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants