[Alerting v2] Create workflow extension service#267924
Conversation
|
Pinging @elastic/response-ops (Team:ResponseOps) |
kdelemme
left a comment
There was a problem hiding this comment.
I'm very confused by the duplicated services
| ) {} | ||
|
|
||
| public registerStepDefinitions(stepDefintions: ServerStepDefinitionOrLoader[]): void { | ||
| stepDefintions.forEach((stepDefinition) => |
There was a problem hiding this comment.
| stepDefintions.forEach((stepDefinition) => | |
| stepDefinitions.forEach((stepDefinition) => |
| registerPublicTriggerDefinitions(triggerDefinitions: PublicTriggerDefinition[]): void; | ||
| } | ||
|
|
||
| export class WorkflowExtensionsService implements WorkflowExtensionsPublicServiceContract { |
There was a problem hiding this comment.
I don't understand we have two WorkflowExtensionsService ?
| @@ -0,0 +1,42 @@ | |||
| # Alerting V2 workflows_extensions integration | |||
There was a problem hiding this comment.
can we add an entry for defining a step definition?
I tested this with a mock trigger but did not include that code in the PR. I will open a PR next for an "assign user to episode trigger registration". That should also help. Thanks for the review! |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Page load bundle
History
cc @adcoelho |
|
I take a look at the PR, and I would like to discuss/suggest some changes:
|
Closes elastic/rna-program#446 ## Summary This PR creates a new `WorkflowExtensionsService` and does the wiring for registering workflow triggers and steps in the alerting v2 plugin. ## How registration works I created a README with this information, but: 1. Define a shared trigger definition in `common` (`id` + `eventSchema`) with Zod. 2. Register it on the server in `server/lib/workflow_extensions/register_trigger_definitions.ts` via `registerTriggerDefinitions(service)`, which calls `WorkflowExtensionsService.registerTriggerDefinitions(...)`. 3. Define a public trigger definition (`PublicTriggerDefinition`) with UI metadata (title, description, icon, docs). 4. Register it on the public side in `public/lib/workflow_extensions/register_trigger_definitions.ts` via `registerTriggerDefinitions(service)`. 5. Add/update the trigger schema hash in: - `src/platform/plugins/shared/workflows_extensions/test/scout/api/fixtures/approved_trigger_definitions.ts` To confirm a trigger was created correctly: How to visualize this in the UI 1. Start Kibana normally (your local dev workflow). 2. Go to Management -> Workflows. 3. Create/edit a workflow and open trigger selection. 4. Look for your trigger title 5. Open its docs panel; you should see the configured description/example from translations.ts. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary [This PR addresses this comment.](#267924 (comment)) > - I think we should separate the setup from the emitting in the service. It is ok to have only functions for setup, as we do with registerSavedObjects and registerFeaturePrivileges. > - The service should have only the emitEvent: (triggerId: string, payload: Record<string, unknown>) => Promise<void>. > - The constructor should accept the workflow client already instantiated with @Inject as we do with the ES and SO client in the other services. > - Put one README in x-pack/platform/plugins/shared/alerting_v2/public/lib/workflow_extensions for public and one in x-pack/platform/plugins/shared/alerting_v2/server/lib/services/workflow_extensions_service/tokens.ts for server. You can update the x-pack/platform/plugins/shared/alerting_v2/README.md with a paragraph that points to the two files and explains why and how they wire together.
## Summary [This PR addresses this comment.](elastic#267924 (comment)) > - I think we should separate the setup from the emitting in the service. It is ok to have only functions for setup, as we do with registerSavedObjects and registerFeaturePrivileges. > - The service should have only the emitEvent: (triggerId: string, payload: Record<string, unknown>) => Promise<void>. > - The constructor should accept the workflow client already instantiated with @Inject as we do with the ES and SO client in the other services. > - Put one README in x-pack/platform/plugins/shared/alerting_v2/public/lib/workflow_extensions for public and one in x-pack/platform/plugins/shared/alerting_v2/server/lib/services/workflow_extensions_service/tokens.ts for server. You can update the x-pack/platform/plugins/shared/alerting_v2/README.md with a paragraph that points to the two files and explains why and how they wire together.
Closes https://github.com/elastic/rna-program/issues/446
Summary
This PR creates a new
WorkflowExtensionsServiceand does the wiring for registering workflow triggers and steps in the alerting v2 plugin.How registration works
I created a README with this information, but:
common(id+eventSchema) with Zod.server/lib/workflow_extensions/register_trigger_definitions.tsviaregisterTriggerDefinitions(service), which callsWorkflowExtensionsService.registerTriggerDefinitions(...).PublicTriggerDefinition) with UI metadata (title, description, icon, docs).public/lib/workflow_extensions/register_trigger_definitions.tsviaregisterTriggerDefinitions(service).src/platform/plugins/shared/workflows_extensions/test/scout/api/fixtures/approved_trigger_definitions.tsTo confirm a trigger was created correctly:
How to visualize this in the UI