Skip to content

Commit 891bf36

Browse files
yT0n1philippfromme
authored andcommitted
feat: disallow ad-hoc subprocess properties if task definition present
Related to camunda/tmp-camunda-modeler-adhoc-subprocess#2
1 parent e5e79cb commit 891bf36

File tree

4 files changed

+324
-0
lines changed

4 files changed

+324
-0
lines changed

packages/zeebe-element-templates-json-schema/src/defs/template/adHoc.json

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,148 @@
176176
"properties"
177177
]
178178
}
179+
},
180+
{
181+
"$comment": "When JOB_WORKER implementation type properties are set (zeebe:taskDefinition), BPMN implementation properties (cancelRemainingInstances, completionCondition, activeElementsCollection) must not be set on AdHocSubProcess",
182+
"if": {
183+
"allOf": [
184+
{
185+
"anyOf": [
186+
{
187+
"required": [
188+
"elementType"
189+
],
190+
"properties": {
191+
"elementType": {
192+
"required": [
193+
"value"
194+
],
195+
"properties": {
196+
"value": {
197+
"const": "bpmn:AdHocSubProcess"
198+
}
199+
}
200+
}
201+
}
202+
},
203+
{
204+
"required": [
205+
"appliesTo"
206+
],
207+
"properties": {
208+
"appliesTo": {
209+
"const": [
210+
"bpmn:AdHocSubProcess"
211+
]
212+
}
213+
}
214+
}
215+
]
216+
},
217+
{
218+
"properties": {
219+
"properties": {
220+
"contains": {
221+
"type": "object",
222+
"properties": {
223+
"binding": {
224+
"properties": {
225+
"type": {
226+
"const": "zeebe:taskDefinition"
227+
},
228+
"property": {
229+
"const": "type"
230+
}
231+
},
232+
"required": [
233+
"type",
234+
"property"
235+
]
236+
}
237+
},
238+
"required": [
239+
"binding"
240+
]
241+
}
242+
}
243+
},
244+
"required": [
245+
"properties"
246+
]
247+
}
248+
]
249+
},
250+
"then": {
251+
"allOf": [
252+
{
253+
"properties": {
254+
"properties": {
255+
"items": {
256+
"not": {
257+
"properties": {
258+
"binding": {
259+
"properties": {
260+
"type": {
261+
"const": "property"
262+
},
263+
"name": {
264+
"enum": [
265+
"cancelRemainingInstances",
266+
"completionCondition"
267+
]
268+
}
269+
},
270+
"required": [
271+
"type",
272+
"name"
273+
]
274+
}
275+
},
276+
"required": [
277+
"binding"
278+
]
279+
}
280+
}
281+
}
282+
},
283+
"required": [
284+
"properties"
285+
]
286+
},
287+
{
288+
"properties": {
289+
"properties": {
290+
"items": {
291+
"not": {
292+
"properties": {
293+
"binding": {
294+
"properties": {
295+
"type": {
296+
"const": "zeebe:adHoc"
297+
},
298+
"property": {
299+
"const": "activeElementsCollection"
300+
}
301+
},
302+
"required": [
303+
"type",
304+
"property"
305+
]
306+
}
307+
},
308+
"required": [
309+
"binding"
310+
]
311+
}
312+
}
313+
}
314+
},
315+
"required": [
316+
"properties"
317+
]
318+
}
319+
]
320+
}
179321
}
180322
]
181323
}

packages/zeebe-element-templates-json-schema/src/error-messages.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,44 @@
552552
],
553553
"errorMessage": "When using \"zeebe:adHoc\" with properties \"outputCollection\" and \"outputElement\", \"zeebe:taskDefinition\" with property=\"type\" must be set on the same element"
554554
},
555+
{
556+
"path": [
557+
"definitions",
558+
"template",
559+
"allOf",
560+
1,
561+
"allOf",
562+
9,
563+
"allOf",
564+
2,
565+
"then",
566+
"allOf",
567+
0,
568+
"properties",
569+
"properties",
570+
"items"
571+
],
572+
"errorMessage": "Property ${0/binding/name} must not be set when using a \"zeebe:taskDefinition\" implementation for a \"bpmn:AdHocSubProcess\""
573+
},
574+
{
575+
"path": [
576+
"definitions",
577+
"template",
578+
"allOf",
579+
1,
580+
"allOf",
581+
9,
582+
"allOf",
583+
2,
584+
"then",
585+
"allOf",
586+
1,
587+
"properties",
588+
"properties",
589+
"items"
590+
],
591+
"errorMessage": "Property ${0/binding/property} must not be set when using a \"zeebe:taskDefinition\" implementation for a \"bpmn:AdHocSubProcess\""
592+
},
555593
{
556594
"path": [
557595
"definitions",
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
export const template = {
2+
'$schema': 'https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json',
3+
'name': 'AdHoc Template',
4+
'id': 'io.camunda.examples.AdHoc.Valid',
5+
'description': 'activeElementsCollection, completionCondition, and cancelRemainingInstances cannot be set together with job worker properties',
6+
'version': 1,
7+
'appliesTo': [ 'bpmn:AdHocSubProcess' ],
8+
'elementType': { 'value': 'bpmn:AdHocSubProcess' },
9+
'properties': [
10+
{
11+
'type': 'Hidden',
12+
'binding': { 'type': 'zeebe:taskDefinition', 'property': 'type' },
13+
'value': 'io.camunda.agenticai:aiagent-job-worker:1'
14+
},
15+
{
16+
'type': 'Hidden',
17+
'binding': {
18+
'type': 'property',
19+
'name': 'cancelRemainingInstances'
20+
},
21+
'value': 'false'
22+
},
23+
{
24+
'type': 'String',
25+
'feel': 'required',
26+
'binding': {
27+
'type': 'property',
28+
'name': 'completionCondition'
29+
}
30+
},
31+
{
32+
'type': 'Hidden',
33+
'binding': { 'type': 'zeebe:adHoc', 'property': 'activeElementsCollection' },
34+
'value': '=anActiveElementsCollection'
35+
}
36+
]
37+
};
38+
39+
export const errors = [
40+
{
41+
keyword: 'errorMessage',
42+
dataPath: '/properties/1',
43+
schemaPath: '#/allOf/1/allOf/9/allOf/2/then/allOf/0/properties/properties/items/errorMessage',
44+
params: {
45+
errors: [
46+
{
47+
keyword: 'not',
48+
dataPath: '/properties/1',
49+
schemaPath: '#/allOf/1/allOf/9/allOf/2/then/allOf/0/properties/properties/items/not',
50+
params: {},
51+
message: 'should NOT be valid',
52+
emUsed: true
53+
}
54+
]
55+
},
56+
message: 'Property "cancelRemainingInstances" must not be set when using a "zeebe:taskDefinition" implementation for a "bpmn:AdHocSubProcess"'
57+
},
58+
{
59+
keyword: 'errorMessage',
60+
dataPath: '/properties/2',
61+
schemaPath: '#/allOf/1/allOf/9/allOf/2/then/allOf/0/properties/properties/items/errorMessage',
62+
params: {
63+
errors: [
64+
{
65+
keyword: 'not',
66+
dataPath: '/properties/2',
67+
schemaPath: '#/allOf/1/allOf/9/allOf/2/then/allOf/0/properties/properties/items/not',
68+
params: {},
69+
message: 'should NOT be valid',
70+
emUsed: true
71+
}
72+
]
73+
},
74+
message: 'Property "completionCondition" must not be set when using a "zeebe:taskDefinition" implementation for a "bpmn:AdHocSubProcess"'
75+
},
76+
{
77+
keyword: 'errorMessage',
78+
dataPath: '/properties/3',
79+
schemaPath: '#/allOf/1/allOf/9/allOf/2/then/allOf/1/properties/properties/items/errorMessage',
80+
params: {
81+
errors: [
82+
{
83+
keyword: 'not',
84+
dataPath: '/properties/3',
85+
schemaPath: '#/allOf/1/allOf/9/allOf/2/then/allOf/1/properties/properties/items/not',
86+
params: {},
87+
message: 'should NOT be valid',
88+
emUsed: true
89+
}
90+
]
91+
},
92+
message: 'Property "activeElementsCollection" must not be set when using a "zeebe:taskDefinition" implementation for a "bpmn:AdHocSubProcess"'
93+
},
94+
{
95+
keyword: 'if',
96+
dataPath: '',
97+
schemaPath: '#/allOf/1/allOf/9/allOf/2/if',
98+
params: {
99+
failingKeyword: 'then'
100+
},
101+
message: 'should match "then" schema'
102+
},
103+
{
104+
keyword: 'enum',
105+
dataPath: '/properties/3/binding/property',
106+
schemaPath: '#/allOf/1/items/properties/binding/allOf/11/then/properties/property/enum',
107+
params: {
108+
allowedValues: [
109+
'outputCollection',
110+
'outputElement'
111+
]
112+
},
113+
message: 'should be equal to one of the allowed values'
114+
},
115+
{
116+
keyword: 'if',
117+
dataPath: '/properties/3/binding',
118+
schemaPath: '#/allOf/1/items/properties/binding/allOf/11/if',
119+
params: {
120+
failingKeyword: 'then'
121+
},
122+
message: 'should match "then" schema'
123+
},
124+
{
125+
keyword: 'type',
126+
dataPath: '',
127+
schemaPath: '#/oneOf/1/type',
128+
params: {
129+
type: 'array'
130+
},
131+
message: 'should be array'
132+
},
133+
{
134+
keyword: 'oneOf',
135+
dataPath: '',
136+
schemaPath: '#/oneOf',
137+
params: {
138+
passingSchemas: null
139+
},
140+
message: 'should match exactly one schema in oneOf'
141+
}
142+
];

packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,8 @@ describe('validation', function() {
644644

645645
describe('zeebe:adHoc', function() {
646646

647+
it('ad-hoc/invalid-bpmn-ad-hoc-impl-properties');
648+
647649
it('ad-hoc/invalid-element-type');
648650

649651
it('ad-hoc/invalid-feel-output-collection');

0 commit comments

Comments
 (0)