Skip to content

Commit 84f804d

Browse files
committed
feat: verify that only valid choices are allowed for binding type
1 parent 6137db6 commit 84f804d

File tree

5 files changed

+422
-0
lines changed

5 files changed

+422
-0
lines changed

packages/zeebe-element-templates-json-schema/src/defs/properties/bindingType.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@
3232
"value"
3333
],
3434
"properties": {
35+
"choices": {
36+
"type": "array",
37+
"items": {
38+
"properties": {
39+
"value": {
40+
"enum": [
41+
"latest",
42+
"versionTag",
43+
"deployment"
44+
]
45+
}
46+
}
47+
}
48+
},
3549
"type": {
3650
"enum": [
3751
"Hidden",
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
export const template = {
2+
'$schema': 'https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json',
3+
'name': 'Reusable Rule Template',
4+
'id': 'io.camunda.examples.Decision',
5+
'description': 'A reusable rule template',
6+
'version': 1,
7+
'engines': {
8+
'camunda': '^8.6'
9+
},
10+
'appliesTo': [
11+
'bpmn:Task',
12+
'bpmn:BusinessRuleTask'
13+
],
14+
'elementType': {
15+
'value': 'bpmn:BusinessRuleTask'
16+
},
17+
'properties': [
18+
{
19+
'type': 'Hidden',
20+
'value': 'aReusableRule',
21+
'binding': {
22+
'type': 'zeebe:calledDecision',
23+
'property': 'decisionId'
24+
}
25+
},
26+
{
27+
'type': 'Hidden',
28+
'value': 'aResultVariable',
29+
'binding': {
30+
'type': 'zeebe:calledDecision',
31+
'property': 'resultVariable'
32+
}
33+
},
34+
{
35+
'type': 'Dropdown',
36+
'label': 'Binding',
37+
'id': 'bindingType',
38+
'binding': {
39+
'type': 'zeebe:calledDecision',
40+
'property': 'bindingType'
41+
},
42+
'choices': [
43+
{
44+
'name': 'Latest',
45+
'value': 'foo'
46+
},
47+
{
48+
'name': 'Deployment',
49+
'value': 'bar'
50+
},
51+
{
52+
'name': 'Version Tag',
53+
'value': 'baz'
54+
}
55+
],
56+
'value': 'latest',
57+
},
58+
{
59+
'type': 'String',
60+
'label': 'Version tag',
61+
'binding': {
62+
'type': 'zeebe:calledDecision',
63+
'property': 'versionTag'
64+
},
65+
'condition': {
66+
'property': 'bindingType',
67+
'equals': 'versionTag'
68+
}
69+
}
70+
]
71+
};
72+
73+
export const errors = [
74+
{
75+
keyword: 'enum',
76+
dataPath: '/properties/2/choices/0/value',
77+
schemaPath: '#/allOf/1/items/allOf/20/allOf/0/then/properties/choices/items/properties/value/enum',
78+
params: {
79+
allowedValues: [
80+
'latest',
81+
'versionTag',
82+
'deployment'
83+
]
84+
},
85+
message: 'should be equal to one of the allowed values'
86+
},
87+
{
88+
keyword: 'enum',
89+
dataPath: '/properties/2/choices/1/value',
90+
schemaPath: '#/allOf/1/items/allOf/20/allOf/0/then/properties/choices/items/properties/value/enum',
91+
params: {
92+
allowedValues: [
93+
'latest',
94+
'versionTag',
95+
'deployment'
96+
]
97+
},
98+
message: 'should be equal to one of the allowed values'
99+
},
100+
{
101+
keyword: 'enum',
102+
dataPath: '/properties/2/choices/2/value',
103+
schemaPath: '#/allOf/1/items/allOf/20/allOf/0/then/properties/choices/items/properties/value/enum',
104+
params: {
105+
allowedValues: [
106+
'latest',
107+
'versionTag',
108+
'deployment'
109+
]
110+
},
111+
message: 'should be equal to one of the allowed values'
112+
},
113+
{
114+
keyword: 'if',
115+
dataPath: '/properties/2',
116+
schemaPath: '#/allOf/1/items/allOf/20/allOf/0/if',
117+
params: {
118+
failingKeyword: 'then'
119+
},
120+
message: 'should match "then" schema'
121+
},
122+
{
123+
keyword: 'type',
124+
dataPath: '',
125+
schemaPath: '#/oneOf/1/type',
126+
params: {
127+
type: 'array'
128+
},
129+
message: 'should be array'
130+
},
131+
{
132+
keyword: 'oneOf',
133+
dataPath: '',
134+
schemaPath: '#/oneOf',
135+
params: {
136+
passingSchemas: null
137+
},
138+
message: 'should match exactly one schema in oneOf'
139+
}
140+
];
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
export const template = {
2+
'$schema': 'https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json',
3+
'id': 'io.camunda.examples.Payment',
4+
'name': 'Payment',
5+
'description': 'Payment process call activity',
6+
'appliesTo': [
7+
'bpmn:Task'
8+
],
9+
'elementType': {
10+
'value': 'bpmn:CallActivity'
11+
},
12+
'properties':[
13+
{
14+
'label': 'Payment ID',
15+
'type': 'String',
16+
'binding': {
17+
'type': 'zeebe:input',
18+
'name': 'paymentID'
19+
}
20+
},
21+
{
22+
'type': 'Hidden',
23+
'value': 'paymentProcess',
24+
'binding': {
25+
'type': 'zeebe:calledElement',
26+
'property': 'processId'
27+
}
28+
},
29+
{
30+
'type': 'Dropdown',
31+
'label': 'Binding',
32+
'id': 'bindingType',
33+
'binding': {
34+
'type': 'zeebe:calledElement',
35+
'property': 'bindingType'
36+
},
37+
'choices': [
38+
{
39+
'name': 'Latest',
40+
'value': 'foo'
41+
},
42+
{
43+
'name': 'Deployment',
44+
'value': 'bar'
45+
},
46+
{
47+
'name': 'Version Tag',
48+
'value': 'baz'
49+
}
50+
],
51+
'value': 'latest',
52+
},
53+
{
54+
'type': 'String',
55+
'label': 'Version tag',
56+
'binding': {
57+
'type': 'zeebe:calledElement',
58+
'property': 'versionTag'
59+
},
60+
'condition': {
61+
'property': 'bindingType',
62+
'equals': 'versionTag'
63+
}
64+
}
65+
]
66+
};
67+
68+
export const errors = [
69+
{
70+
keyword: 'enum',
71+
dataPath: '/properties/2/choices/0/value',
72+
schemaPath: '#/allOf/1/items/allOf/20/allOf/0/then/properties/choices/items/properties/value/enum',
73+
params: {
74+
allowedValues: [
75+
'latest',
76+
'versionTag',
77+
'deployment'
78+
]
79+
},
80+
message: 'should be equal to one of the allowed values'
81+
},
82+
{
83+
keyword: 'enum',
84+
dataPath: '/properties/2/choices/1/value',
85+
schemaPath: '#/allOf/1/items/allOf/20/allOf/0/then/properties/choices/items/properties/value/enum',
86+
params: {
87+
allowedValues: [
88+
'latest',
89+
'versionTag',
90+
'deployment'
91+
]
92+
},
93+
message: 'should be equal to one of the allowed values'
94+
},
95+
{
96+
keyword: 'enum',
97+
dataPath: '/properties/2/choices/2/value',
98+
schemaPath: '#/allOf/1/items/allOf/20/allOf/0/then/properties/choices/items/properties/value/enum',
99+
params: {
100+
allowedValues: [
101+
'latest',
102+
'versionTag',
103+
'deployment'
104+
]
105+
},
106+
message: 'should be equal to one of the allowed values'
107+
},
108+
{
109+
keyword: 'if',
110+
dataPath: '/properties/2',
111+
schemaPath: '#/allOf/1/items/allOf/20/allOf/0/if',
112+
params: {
113+
failingKeyword: 'then'
114+
},
115+
message: 'should match "then" schema'
116+
},
117+
{
118+
keyword: 'type',
119+
dataPath: '',
120+
schemaPath: '#/oneOf/1/type',
121+
params: {
122+
type: 'array'
123+
},
124+
message: 'should be array'
125+
},
126+
{
127+
keyword: 'oneOf',
128+
dataPath: '',
129+
schemaPath: '#/oneOf',
130+
params: {
131+
passingSchemas: null
132+
},
133+
message: 'should match exactly one schema in oneOf'
134+
}
135+
];

0 commit comments

Comments
 (0)