Skip to content

Commit 81e6ac3

Browse files
talborenqn895
authored andcommitted
remove triggers.elastic. prefix from workflow triggers (elastic#232026)
title
1 parent 233b07d commit 81e6ac3

File tree

18 files changed

+51
-70
lines changed

18 files changed

+51
-70
lines changed

examples/workflows/public/components/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ workflow:
6565
name: New workflow
6666
enabled: false
6767
triggers:
68-
- type: triggers.elastic.manual
68+
- type: manual
6969
steps:
7070
- name: step-with-console-log-1
7171
type: console

src/platform/packages/shared/kbn-workflows/spec/examples/basic.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ workflow:
55
description: 'Remind users to enroll in JAMF'
66
enabled: true
77
triggers:
8-
- type: triggers.elastic.scheduled
8+
- type: scheduled
99
with:
1010
every: 1
1111
unit: day
12-
- type: triggers.elastic.manual
12+
- type: manual
1313
inputs:
1414
consts:
1515
- name: jamf-server-url

src/platform/packages/shared/kbn-workflows/spec/examples/example_merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ workflow:
44
description: "Investigate a reported phishing email with parallel analysis and AI summary."
55
enabled: true
66
triggers:
7-
- type: triggers.elastic.manual
7+
- type: manual
88
steps:
99
- name: Parallel analysis
1010
type: parallel

src/platform/packages/shared/kbn-workflows/spec/examples/example_nesting.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ workflow:
44
description: "Handle alerts based on maliciousness"
55
enabled: true
66
triggers:
7-
- type: triggers.elastic.scheduled
7+
- type: scheduled
88
with:
99
every: 1
1010
unit: day
11-
- type: triggers.elastic.manual
11+
- type: manual
1212
steps:
1313
- name: Check if alert is malicious
1414
type: if

src/platform/packages/shared/kbn-workflows/spec/examples/example_on_failure.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ workflow:
44
version: 1
55
enabled: true
66
triggers:
7-
- type: triggers.elastic.scheduled
7+
- type: scheduled
88
with:
99
every: 1
1010
unit: day
11-
- type: triggers.elastic.manual
11+
- type: manual
1212
steps:
1313
- name: AI Summary
1414
type: openai.completion

src/platform/packages/shared/kbn-workflows/spec/examples/example_pishing_from_wireframes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ workflow:
44
description: "Workflow to detect if an alert is a real pishing attempt or not"
55
enabled: true
66
triggers:
7-
- type: triggers.elastic.detectionRule
7+
- type: alert
88
with:
99
rule_name: "Email Reported by User as ..."
1010
steps:

src/platform/packages/shared/kbn-workflows/spec/schema.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export const WorkflowSettingsSchema = z.object({
2626
});
2727

2828
/* --- Triggers --- */
29-
export const DetectionRuleTriggerSchema = z.object({
30-
type: z.literal('triggers.elastic.detectionRule'),
29+
export const AlertRuleTriggerSchema = z.object({
30+
type: z.literal('alert'),
3131
enabled: z.boolean().optional().default(true),
3232
with: z.union([
3333
z.object({ rule_id: z.string().min(1) }),
@@ -36,7 +36,7 @@ export const DetectionRuleTriggerSchema = z.object({
3636
});
3737

3838
export const ScheduledTriggerSchema = z.object({
39-
type: z.literal('triggers.elastic.scheduled'),
39+
type: z.literal('scheduled'),
4040
enabled: z.boolean().optional().default(true),
4141
with: z.union([
4242
z.object({
@@ -48,12 +48,12 @@ export const ScheduledTriggerSchema = z.object({
4848
});
4949

5050
export const ManualTriggerSchema = z.object({
51-
type: z.literal('triggers.elastic.manual'),
51+
type: z.literal('manual'),
5252
enabled: z.boolean().optional().default(true),
5353
});
5454

5555
export const TriggerSchema = z.discriminatedUnion('type', [
56-
DetectionRuleTriggerSchema,
56+
AlertRuleTriggerSchema,
5757
ScheduledTriggerSchema,
5858
ManualTriggerSchema,
5959
]);

src/platform/plugins/shared/workflows_management/public/entities/workflows/lib/get_workflow_graph.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('getWorkflowGraph', () => {
1717
enabled: true,
1818
triggers: [
1919
{
20-
type: 'triggers.elastic.manual' as const,
20+
type: 'manual' as const,
2121
enabled: true,
2222
},
2323
],
@@ -36,10 +36,10 @@ describe('getWorkflowGraph', () => {
3636
expect(workflowGraph.nodes().length).toBe(2);
3737
expect(workflowGraph.edges().length).toBe(1);
3838

39-
expect(workflowGraph.node('triggers.elastic.manual').type).toBe('trigger');
39+
expect(workflowGraph.node('manual').type).toBe('trigger');
4040
expect(workflowGraph.node('first-step').type).toBe('action');
4141

42-
expect(workflowGraph.hasEdge('triggers.elastic.manual', 'first-step')).toBe(true);
42+
expect(workflowGraph.hasEdge('manual', 'first-step')).toBe(true);
4343
});
4444

4545
it('should return the correct graph with a nested step', () => {
@@ -49,7 +49,7 @@ describe('getWorkflowGraph', () => {
4949
enabled: true,
5050
triggers: [
5151
{
52-
type: 'triggers.elastic.manual' as const,
52+
type: 'manual' as const,
5353
enabled: true,
5454
},
5555
],
@@ -91,13 +91,13 @@ describe('getWorkflowGraph', () => {
9191
expect(workflowGraph.nodes().length).toBe(5);
9292
expect(workflowGraph.edges().length).toBe(4);
9393

94-
expect(workflowGraph.node('triggers.elastic.manual').type).toBe('trigger');
94+
expect(workflowGraph.node('manual').type).toBe('trigger');
9595
expect(workflowGraph.node('first-step').type).toBe('action');
9696
expect(workflowGraph.node('if-split').type).toBe('if');
9797
expect(workflowGraph.node('if-true').type).toBe('action');
9898
expect(workflowGraph.node('if-false').type).toBe('action');
9999

100-
expect(workflowGraph.hasEdge('triggers.elastic.manual', 'first-step')).toBe(true);
100+
expect(workflowGraph.hasEdge('manual', 'first-step')).toBe(true);
101101
expect(workflowGraph.hasEdge('first-step', 'if-split')).toBe(true);
102102
expect(workflowGraph.hasEdge('if-split', 'if-true')).toBe(true);
103103
expect(workflowGraph.hasEdge('if-split', 'if-false')).toBe(true);

src/platform/plugins/shared/workflows_management/public/entities/workflows/lib/get_workflow_graph.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import { graphlib } from '@dagrejs/dagre';
1111
import type { WorkflowYaml } from '@kbn/workflows';
12+
import { getTriggerLabel } from '../../../shared/lib/graph_utils';
1213

1314
export type WorkflowGraphNodeType =
1415
| 'if'
@@ -31,19 +32,6 @@ export type WorkflowGraph = graphlib.Graph<WorkflowGraphNodeLabel>;
3132

3233
export const flowNodeTypes = ['if', 'merge', 'parallel', 'foreach', 'atomic', 'merge', 'trigger'];
3334

34-
function getTriggerLabel(triggerType: string) {
35-
switch (triggerType) {
36-
case 'triggers.elastic.manual':
37-
return 'Manual';
38-
case 'triggers.elastic.detectionRule':
39-
return 'Detection Rule';
40-
case 'triggers.elastic.scheduled':
41-
return 'Scheduled';
42-
default:
43-
return triggerType;
44-
}
45-
}
46-
4735
function transformYamlToNodesAndEdges(
4836
triggers: WorkflowYaml['triggers'],
4937
steps: WorkflowYaml['steps']

src/platform/plugins/shared/workflows_management/public/features/workflow_context/lib/get_context_for_path.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('getContextSchemaForPath', () => {
2121
enabled: true,
2222
triggers: [
2323
{
24-
type: 'triggers.elastic.manual' as const,
24+
type: 'manual' as const,
2525
enabled: true,
2626
},
2727
],

0 commit comments

Comments
 (0)