From 2ab4d9129af9b60c0aec7a264748083c7b0bf014 Mon Sep 17 00:00:00 2001 From: Martin Stamm Date: Thu, 16 Nov 2023 11:57:41 +0100 Subject: [PATCH] feat(condition): add `isActive` condition --- .../src/defs/condition.json | 11 +++++++++++ .../test/fixtures/condition-default-type.js | 9 +++++++++ .../condition-missing-condition-keyword.js | 9 +++++++++ .../test/fixtures/condition-wrong-types.js | 18 ++++++++++++++++++ .../test/fixtures/condition.js | 12 ++++++++++++ .../test/fixtures/condition-default-type.js | 9 +++++++++ .../test/fixtures/condition-empty-allMatch.js | 9 +++++++++ .../condition-missing-condition-keyword.js | 9 +++++++++ .../test/fixtures/condition-wrong-types.js | 18 ++++++++++++++++++ .../test/fixtures/condition.js | 12 ++++++++++++ 10 files changed, 116 insertions(+) diff --git a/packages/element-templates-json-schema-shared/src/defs/condition.json b/packages/element-templates-json-schema-shared/src/defs/condition.json index 9b0cb00..f0b16a6 100644 --- a/packages/element-templates-json-schema-shared/src/defs/condition.json +++ b/packages/element-templates-json-schema-shared/src/defs/condition.json @@ -56,6 +56,17 @@ "required": [ "oneOf" ] + }, + { + "properties": { + "isActive": { + "type": "boolean", + "description": "For `true`, activates the property when given property is active" + } + }, + "required": [ + "isActive" + ] } ] } diff --git a/packages/element-templates-json-schema/test/fixtures/condition-default-type.js b/packages/element-templates-json-schema/test/fixtures/condition-default-type.js index ffb2e4d..2f1095d 100644 --- a/packages/element-templates-json-schema/test/fixtures/condition-default-type.js +++ b/packages/element-templates-json-schema/test/fixtures/condition-default-type.js @@ -43,6 +43,15 @@ export const errors = [ params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, + { + dataPath: '/properties/1/condition', + keyword: 'required', + message: "should have required property 'isActive'", + params: { + missingProperty: 'isActive' + }, + schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + }, { keyword: 'oneOf', dataPath: '/properties/1/condition', diff --git a/packages/element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js b/packages/element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js index 3f56450..1e27c36 100644 --- a/packages/element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js +++ b/packages/element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js @@ -44,6 +44,15 @@ export const errors = [ params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, + { + dataPath: '/properties/1/condition', + keyword: 'required', + message: "should have required property 'isActive'", + params: { + missingProperty: 'isActive' + }, + schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + }, { keyword: 'oneOf', dataPath: '/properties/1/condition', diff --git a/packages/element-templates-json-schema/test/fixtures/condition-wrong-types.js b/packages/element-templates-json-schema/test/fixtures/condition-wrong-types.js index b50e337..629c564 100644 --- a/packages/element-templates-json-schema/test/fixtures/condition-wrong-types.js +++ b/packages/element-templates-json-schema/test/fixtures/condition-wrong-types.js @@ -58,6 +58,15 @@ export const errors = [ params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, + { + dataPath: '/properties/1/condition', + keyword: 'required', + message: "should have required property 'isActive'", + params: { + missingProperty: 'isActive' + }, + schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + }, { keyword: 'oneOf', dataPath: '/properties/1/condition', @@ -100,6 +109,15 @@ export const errors = [ params: { type: [ 'string', 'number' ] }, message: 'should be string,number' }, + { + dataPath: '/properties/2/condition', + keyword: 'required', + message: "should have required property 'isActive'", + params: { + missingProperty: 'isActive' + }, + schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + }, { keyword: 'oneOf', dataPath: '/properties/2/condition', diff --git a/packages/element-templates-json-schema/test/fixtures/condition.js b/packages/element-templates-json-schema/test/fixtures/condition.js index 00f135c..0a91480 100644 --- a/packages/element-templates-json-schema/test/fixtures/condition.js +++ b/packages/element-templates-json-schema/test/fixtures/condition.js @@ -90,6 +90,18 @@ export const template = { 'type': 'property', 'name': 'input4' } + }, + { + 'label': 'isActive', + 'type': 'String', + 'condition': { + property: 'myId', + isActive: true + }, + 'binding': { + 'type': 'property', + 'name': 'input4' + } } ] }; diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-default-type.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-default-type.js index 381bd9e..299908e 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-default-type.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-default-type.js @@ -43,6 +43,15 @@ export const errors = [ params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, + { + dataPath: '/properties/1/condition', + keyword: 'required', + message: "should have required property 'isActive'", + params: { + missingProperty: 'isActive' + }, + schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + }, { keyword: 'oneOf', dataPath: '/properties/1/condition', diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-empty-allMatch.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-empty-allMatch.js index 40e2e5e..79125d4 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-empty-allMatch.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-empty-allMatch.js @@ -57,6 +57,15 @@ export const errors = [ }, 'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/required' }, + { + 'dataPath': '/properties/2/condition', + 'keyword': 'required', + 'message': "should have required property 'isActive'", + 'params': { + 'missingProperty': 'isActive' + }, + 'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + }, { 'dataPath': '/properties/2/condition', 'keyword': 'oneOf', diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js index 991df7b..30f2120 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js @@ -44,6 +44,15 @@ export const errors = [ params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, + { + dataPath: '/properties/1/condition', + keyword: 'required', + message: "should have required property 'isActive'", + params: { + missingProperty: 'isActive' + }, + schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + }, { keyword: 'oneOf', dataPath: '/properties/1/condition', diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-types.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-types.js index fa336c6..357305c 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-types.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-types.js @@ -58,6 +58,15 @@ export const errors = [ params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, + { + dataPath: '/properties/1/condition', + keyword: 'required', + message: "should have required property 'isActive'", + params: { + missingProperty: 'isActive' + }, + schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + }, { keyword: 'oneOf', dataPath: '/properties/1/condition', @@ -100,6 +109,15 @@ export const errors = [ params: { type: [ 'string', 'number' ] }, message: 'should be string,number' }, + { + dataPath: '/properties/2/condition', + keyword: 'required', + message: "should have required property 'isActive'", + params: { + missingProperty: 'isActive' + }, + schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + }, { keyword: 'oneOf', dataPath: '/properties/2/condition', diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition.js index 00f135c..0a91480 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition.js @@ -90,6 +90,18 @@ export const template = { 'type': 'property', 'name': 'input4' } + }, + { + 'label': 'isActive', + 'type': 'String', + 'condition': { + property: 'myId', + isActive: true + }, + 'binding': { + 'type': 'property', + 'name': 'input4' + } } ] };