diff --git a/packages/zeebe-element-templates-json-schema/src/defs/engines.json b/packages/zeebe-element-templates-json-schema/src/defs/engines.json new file mode 100644 index 0000000..f13eab8 --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/src/defs/engines.json @@ -0,0 +1,19 @@ +{ + "$id": "#/engines", + "type": "object", + "description": "Defines the compatibility of this element template with different engines. Keys are engine names, values are semantic version ranges.", + "default": {}, + "examples": [ + { + "camunda": "^8.5" + } + ], + "properties": { + "camunda": { + "$id": "#/engines/camunda", + "type": "string", + "description": "A semantic version range that denotes compatible Camunda versions.", + "default": "" + } + } +} \ No newline at end of file diff --git a/packages/zeebe-element-templates-json-schema/src/schema.json b/packages/zeebe-element-templates-json-schema/src/schema.json index daf75b3..fa90163 100644 --- a/packages/zeebe-element-templates-json-schema/src/schema.json +++ b/packages/zeebe-element-templates-json-schema/src/schema.json @@ -28,6 +28,9 @@ "$ref": "#/definitions/properties", "$id": "#/properties" }, + "engines": { + "$ref": "src/defs/engines.json" + }, "icon": { "$ref": "src/defs/icon.json" }, diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/engines-invalid-version.js b/packages/zeebe-element-templates-json-schema/test/fixtures/engines-invalid-version.js new file mode 100644 index 0000000..313f771 --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/engines-invalid-version.js @@ -0,0 +1,41 @@ +export const template = { + 'name': 'Engines Invalid Versions', + 'id': 'foo', + 'appliesTo': [ + 'bpmn:Task' + ], + 'engines': { + 'camunda': [ '8.5' ], + }, + 'properties': [], +}; + +export const errors = [ + { + dataPath: '/engines/camunda', + keyword: 'type', + message: 'should be string', + params: { + type: 'string' + }, + schemaPath: '#/properties/engines/properties/camunda/type' + }, + { + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { + type: 'array' + }, + message: 'should be array' + }, + { + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { + passingSchemas: null + }, + message: 'should match exactly one schema in oneOf' + } +]; diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/engines-invalid.js b/packages/zeebe-element-templates-json-schema/test/fixtures/engines-invalid.js new file mode 100644 index 0000000..e9f49bb --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/engines-invalid.js @@ -0,0 +1,39 @@ +export const template = { + 'name': 'Engines Invalid', + 'id': 'foo', + 'appliesTo': [ + 'bpmn:Task' + ], + 'engines': '8.5', + 'properties': [], +}; + +export const errors = [ + { + dataPath: '/engines', + keyword: 'type', + message: 'should be object', + params: { + type: 'object' + }, + schemaPath: '#/properties/engines/type' + }, + { + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { + type: 'array' + }, + message: 'should be array' + }, + { + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { + passingSchemas: null + }, + message: 'should match exactly one schema in oneOf' + } +]; diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/engines-no-camunda.js b/packages/zeebe-element-templates-json-schema/test/fixtures/engines-no-camunda.js new file mode 100644 index 0000000..d7f5d7f --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/engines-no-camunda.js @@ -0,0 +1,13 @@ +export const template = { + 'name': 'Engines Valid', + 'id': 'foo', + 'appliesTo': [ + 'bpmn:Task' + ], + 'engines': { + 'other': '^1.3-beta.0' + }, + 'properties': [] +}; + +export const errors = null; diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/engines.js b/packages/zeebe-element-templates-json-schema/test/fixtures/engines.js new file mode 100644 index 0000000..84e0c94 --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/engines.js @@ -0,0 +1,14 @@ +export const template = { + 'name': 'Engines Valid', + 'id': 'foo', + 'appliesTo': [ + 'bpmn:Task' + ], + 'engines': { + 'camunda': '8.5', + 'other': '^1.3-beta.0' + }, + 'properties': [], +}; + +export const errors = null; diff --git a/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js b/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js index 22f7ce1..3e8a610 100644 --- a/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js +++ b/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js @@ -389,6 +389,19 @@ describe('validation', function() { testTemplate('placeholder-invalid-type'); }); + + + describe('engines', function() { + + testTemplate('engines'); + + testTemplate('engines-no-camunda'); + + testTemplate('engines-invalid'); + + testTemplate('engines-invalid-version'); + }); + }); });