-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
breaking: implement workflow hooks (first iteration) #8346
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
|
packages/core/core-flows/src/sales-channel/workflows/create-sales-channels.ts
Outdated
Show resolved
Hide resolved
integration-tests/modules/__tests__/promotion/admin/campaigns.spec.ts
Outdated
Show resolved
Hide resolved
packages/core/core-flows/src/definition/cart/workflows/complete-cart.ts
Outdated
Show resolved
Hide resolved
packages/core/workflows-sdk/src/utils/composer/helpers/create-step-handler.ts
Show resolved
Hide resolved
packages/core/workflows-sdk/src/utils/composer/helpers/create-step-handler.ts
Outdated
Show resolved
Hide resolved
packages/core/workflows-sdk/src/utils/composer/create-workflow.ts
Outdated
Show resolved
Hide resolved
packages/core/workflows-sdk/src/utils/composer/create-workflow.ts
Outdated
Show resolved
Hide resolved
@olivermrbl @srindom The PR is ready for the final review. Maybe you can go through the changelog once (in the PR description) to see if everything looks as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work 🚢
Fixes: FRMW-2629
This PR implements the workflow hooks proposal as defined in the linked RFC.
ChangeLog
This PR adds a new helper,
createHook
, to theworkflows-sdk
. ThecreateHook
helper exposes a hook from a workflow. Later (after the workflow has been composed), the workflow consumers can bind a handler to the hook to run custom logic.Note
As of now, you can only register one hook handler, and the workflow orchestrator ignores the return value.
Exposing hook via
createHook
Points to note
createStep
function, thecreateHook
method is called within the workflow composition callback.Registering the hook handler
The workflow user must register a hook handler to run custom logic within a workflow. They can do that as follows.
Points to note
Introducing the
WorkflowResponse
class and breaking changesThe introduction of hooks has changed the return value of the
createWorkflow
composition callback. Now, we must return both the workflow results and the configured hooks.Instead of manually composing the return value, you can use the
WorkflowResponse
class to construct the current response. TheWorkflowResponse
class accepts the following parameters.