From fe529e310a003a3d9fc16f13744f45335761d11a Mon Sep 17 00:00:00 2001 From: kgrhartlage Date: Wed, 4 Oct 2023 17:25:53 +0200 Subject: [PATCH 1/5] Add `rows` property to field schema --- dist/index.d.ts | 12 ++++++++++++ dist/workflow-step-template-schema.json | 6 ++++++ dist/workflow-template-schema.json | 6 ++++++ src/schemata/definitions/field.yml | 5 +++++ src/workflow-step-template-schema.json | 6 ++++++ src/workflow-template-schema.json | 6 ++++++ 6 files changed, 41 insertions(+) diff --git a/dist/index.d.ts b/dist/index.d.ts index 8634019c..475ddf0e 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -3056,6 +3056,12 @@ export declare const schemas: { description: string; markdownDescription: string; }; + rows: { + type: string; + default: boolean; + description: string; + markdownDescription: string; + }; }; markdownDescription: string; }; @@ -6412,6 +6418,12 @@ export declare const schemas: { description: string; markdownDescription: string; }; + rows: { + type: string; + default: boolean; + description: string; + markdownDescription: string; + }; }; markdownDescription: string; }; diff --git a/dist/workflow-step-template-schema.json b/dist/workflow-step-template-schema.json index 48ceb718..919d665b 100644 --- a/dist/workflow-step-template-schema.json +++ b/dist/workflow-step-template-schema.json @@ -3324,6 +3324,12 @@ "default": true, "description": "A flag indicating whether a field of type `boolean` has a display label. Setting this to `false` will display either only a checkbox or switch control element, without any visible label.\n", "markdownDescription": "A flag indicating whether a field of type `boolean` has a display label. Setting this to `false` will display either only a checkbox or switch control element, without any visible label.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " + }, + "rows": { + "type": "number", + "default": true, + "description": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n", + "markdownDescription": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " } }, "markdownDescription": "Display configuration options for certain field types and widget settings. If a field or widget does not support `ui:options`, the setting is ignored.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " diff --git a/dist/workflow-template-schema.json b/dist/workflow-template-schema.json index 89e7020e..3a808cef 100644 --- a/dist/workflow-template-schema.json +++ b/dist/workflow-template-schema.json @@ -3561,6 +3561,12 @@ "default": true, "description": "A flag indicating whether a field of type `boolean` has a display label. Setting this to `false` will display either only a checkbox or switch control element, without any visible label.\n", "markdownDescription": "A flag indicating whether a field of type `boolean` has a display label. Setting this to `false` will display either only a checkbox or switch control element, without any visible label.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " + }, + "rows": { + "type": "number", + "default": true, + "description": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n", + "markdownDescription": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " } }, "markdownDescription": "Display configuration options for certain field types and widget settings. If a field or widget does not support `ui:options`, the setting is ignored.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " diff --git a/src/schemata/definitions/field.yml b/src/schemata/definitions/field.yml index 154d685c..fc0e813e 100755 --- a/src/schemata/definitions/field.yml +++ b/src/schemata/definitions/field.yml @@ -22,6 +22,11 @@ allOf: default: true description: | A flag indicating whether a field of type `boolean` has a display label. Setting this to `false` will display either only a checkbox or switch control element, without any visible label. + rows: + type: number + default: true + description: | + The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting. readOnly: type: boolean default: false diff --git a/src/workflow-step-template-schema.json b/src/workflow-step-template-schema.json index 0bea1413..aac1d539 100644 --- a/src/workflow-step-template-schema.json +++ b/src/workflow-step-template-schema.json @@ -3324,6 +3324,12 @@ "default": true, "description": "A flag indicating whether a field of type `boolean` has a display label. Setting this to `false` will display either only a checkbox or switch control element, without any visible label.\n", "markdownDescription": "A flag indicating whether a field of type `boolean` has a display label. Setting this to `false` will display either only a checkbox or switch control element, without any visible label.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " + }, + "rows": { + "type": "number", + "default": true, + "description": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n", + "markdownDescription": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " } }, "markdownDescription": "Display configuration options for certain field types and widget settings. If a field or widget does not support `ui:options`, the setting is ignored.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " diff --git a/src/workflow-template-schema.json b/src/workflow-template-schema.json index bf124eaa..8a214f76 100644 --- a/src/workflow-template-schema.json +++ b/src/workflow-template-schema.json @@ -3561,6 +3561,12 @@ "default": true, "description": "A flag indicating whether a field of type `boolean` has a display label. Setting this to `false` will display either only a checkbox or switch control element, without any visible label.\n", "markdownDescription": "A flag indicating whether a field of type `boolean` has a display label. Setting this to `false` will display either only a checkbox or switch control element, without any visible label.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " + }, + "rows": { + "type": "number", + "default": true, + "description": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n", + "markdownDescription": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " } }, "markdownDescription": "Display configuration options for certain field types and widget settings. If a field or widget does not support `ui:options`, the setting is ignored.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " From 410ab0d0cccc9a1cc4f4efabf69386df03a0bd40 Mon Sep 17 00:00:00 2001 From: kgrhartlage Date: Wed, 4 Oct 2023 17:26:30 +0200 Subject: [PATCH 2/5] Narrow down supported setting combinations --- dist/index.d.ts | 172 ++++++++++++++++++++++++ dist/workflow-step-template-schema.json | 166 +++++++++++++++++++++++ dist/workflow-template-schema.json | 166 +++++++++++++++++++++++ src/schemata/definitions/field.yml | 100 ++++++++++++++ src/workflow-step-template-schema.json | 166 +++++++++++++++++++++++ src/workflow-template-schema.json | 166 +++++++++++++++++++++++ 6 files changed, 936 insertions(+) diff --git a/dist/index.d.ts b/dist/index.d.ts index 475ddf0e..ee996e7f 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -3036,6 +3036,92 @@ export declare const schemas: { field: { title: string; description: string; + not: { + oneOf: ({ + required: string[]; + properties: { + type: { + type: string; + enum: string[]; + const?: undefined; + }; + "ui:options": { + type: string; + required: string[]; + enum?: undefined; + }; + "ui:widget"?: undefined; + hidden?: undefined; + prepare?: undefined; + }; + } | { + required: string[]; + properties: { + type: { + const: string; + type?: undefined; + enum?: undefined; + }; + "ui:widget": { + type: string; + enum: string[]; + }; + "ui:options": { + type: string; + required: string[]; + enum?: undefined; + }; + hidden?: undefined; + prepare?: undefined; + }; + } | { + required: string[]; + properties: { + type: { + type: string; + enum: string[]; + const?: undefined; + }; + "ui:widget": { + type: string; + enum: string[]; + }; + "ui:options"?: undefined; + hidden?: undefined; + prepare?: undefined; + }; + } | { + required: string[]; + properties: { + type: { + type: string; + enum: string[]; + const?: undefined; + }; + "ui:options": { + type: string; + enum: string[]; + required?: undefined; + }; + "ui:widget"?: undefined; + hidden?: undefined; + prepare?: undefined; + }; + } | { + required: string[]; + properties: { + hidden: { + const: boolean; + }; + prepare: { + const: boolean; + }; + type?: undefined; + "ui:options"?: undefined; + "ui:widget"?: undefined; + }; + })[]; + }; allOf: ({ type: string; required: string[]; @@ -6398,6 +6484,92 @@ export declare const schemas: { field: { title: string; description: string; + not: { + oneOf: ({ + required: string[]; + properties: { + type: { + type: string; + enum: string[]; + const?: undefined; + }; + "ui:options": { + type: string; + required: string[]; + enum?: undefined; + }; + "ui:widget"?: undefined; + hidden?: undefined; + prepare?: undefined; + }; + } | { + required: string[]; + properties: { + type: { + const: string; + type?: undefined; + enum?: undefined; + }; + "ui:widget": { + type: string; + enum: string[]; + }; + "ui:options": { + type: string; + required: string[]; + enum?: undefined; + }; + hidden?: undefined; + prepare?: undefined; + }; + } | { + required: string[]; + properties: { + type: { + type: string; + enum: string[]; + const?: undefined; + }; + "ui:widget": { + type: string; + enum: string[]; + }; + "ui:options"?: undefined; + hidden?: undefined; + prepare?: undefined; + }; + } | { + required: string[]; + properties: { + type: { + type: string; + enum: string[]; + const?: undefined; + }; + "ui:options": { + type: string; + enum: string[]; + required?: undefined; + }; + "ui:widget"?: undefined; + hidden?: undefined; + prepare?: undefined; + }; + } | { + required: string[]; + properties: { + hidden: { + const: boolean; + }; + prepare: { + const: boolean; + }; + type?: undefined; + "ui:options"?: undefined; + "ui:widget"?: undefined; + }; + })[]; + }; allOf: ({ type: string; required: string[]; diff --git a/dist/workflow-step-template-schema.json b/dist/workflow-step-template-schema.json index 919d665b..a8b377d7 100644 --- a/dist/workflow-step-template-schema.json +++ b/dist/workflow-step-template-schema.json @@ -3297,6 +3297,172 @@ "field": { "title": "Field", "description": "A valid field schema is either a valid JSON schema as per [Draft 7](http://json-schema.org/draft-07/schema#) or one of our custom field types. Some additional properties are allowed at the top level.\n", + "not": { + "oneOf": [ + { + "required": [ + "type", + "ui:options" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "number", + "integer", + "object", + "array", + "boolean", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:options": { + "type": "object", + "required": [ + "rows" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget", + "ui:options" + ], + "properties": { + "type": { + "const": "string" + }, + "ui:widget": { + "type": "string", + "enum": [ + "checkbox", + "switch", + "text" + ] + }, + "ui:options": { + "type": "object", + "required": [ + "rows" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "string", + "number", + "integer", + "object", + "array", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:widget": { + "type": "string", + "enum": [ + "checkbox", + "switch" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "number", + "integer", + "object", + "array", + "boolean", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:widget": { + "type": "string", + "enum": [ + "text", + "textarea" + ] + } + } + }, + { + "required": [ + "type", + "ui:options" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "string", + "number", + "integer", + "object", + "array", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:options": { + "type": "string", + "enum": [ + "label" + ] + } + } + }, + { + "required": [ + "prepare", + "hidden" + ], + "properties": { + "hidden": { + "const": true + }, + "prepare": { + "const": true + } + } + } + ] + }, "allOf": [ { "type": "object", diff --git a/dist/workflow-template-schema.json b/dist/workflow-template-schema.json index 3a808cef..22e1a385 100644 --- a/dist/workflow-template-schema.json +++ b/dist/workflow-template-schema.json @@ -3534,6 +3534,172 @@ "field": { "title": "Field", "description": "A valid field schema is either a valid JSON schema as per [Draft 7](http://json-schema.org/draft-07/schema#) or one of our custom field types. Some additional properties are allowed at the top level.\n", + "not": { + "oneOf": [ + { + "required": [ + "type", + "ui:options" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "number", + "integer", + "object", + "array", + "boolean", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:options": { + "type": "object", + "required": [ + "rows" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget", + "ui:options" + ], + "properties": { + "type": { + "const": "string" + }, + "ui:widget": { + "type": "string", + "enum": [ + "checkbox", + "switch", + "text" + ] + }, + "ui:options": { + "type": "object", + "required": [ + "rows" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "string", + "number", + "integer", + "object", + "array", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:widget": { + "type": "string", + "enum": [ + "checkbox", + "switch" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "number", + "integer", + "object", + "array", + "boolean", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:widget": { + "type": "string", + "enum": [ + "text", + "textarea" + ] + } + } + }, + { + "required": [ + "type", + "ui:options" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "string", + "number", + "integer", + "object", + "array", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:options": { + "type": "string", + "enum": [ + "label" + ] + } + } + }, + { + "required": [ + "prepare", + "hidden" + ], + "properties": { + "hidden": { + "const": true + }, + "prepare": { + "const": true + } + } + } + ] + }, "allOf": [ { "type": "object", diff --git a/src/schemata/definitions/field.yml b/src/schemata/definitions/field.yml index fc0e813e..d2a4525a 100755 --- a/src/schemata/definitions/field.yml +++ b/src/schemata/definitions/field.yml @@ -2,6 +2,106 @@ title: Field description: | A valid field schema is either a valid JSON schema as per [Draft 7](http://json-schema.org/draft-07/schema#) or one of our custom field types. Some additional properties are allowed at the top level. +not: + oneOf: + # only allow `ui:options.rows` for string fields + - required: ['type', 'ui:options'] + properties: + type: + type: string + enum: + - 'number' + - 'integer' + - 'object' + - 'array' + - 'boolean' + - 'null' + - 'file' + - 'quantity' + - 'relationship' + - 'script' + - 'timer' + ui:options: + type: object + required: ['rows'] + # don't allow `ui:options.rows` for string fields that are not textarea + - required: [ 'type', 'ui:widget', 'ui:options'] + properties: + type: + const: string + ui:widget: + type: string + enum: ['checkbox', 'switch', 'text'] + ui:options: + type: object + required: ['rows'] + # only allow text & switch widgets for boolean fields + - required: [ 'type', 'ui:widget'] + properties: + type: + type: string + enum: + - 'string' + - 'number' + - 'integer' + - 'object' + - 'array' + - 'null' + - 'file' + - 'quantity' + - 'relationship' + - 'script' + - 'timer' + ui:widget: + type: string + enum: ['checkbox', 'switch'] + # only allow text & textarea widgets for string fields + - required: [ 'type', 'ui:widget'] + properties: + type: + type: string + enum: + - 'number' + - 'integer' + - 'object' + - 'array' + - 'boolean' + - 'null' + - 'file' + - 'quantity' + - 'relationship' + - 'script' + - 'timer' + ui:widget: + type: string + enum: ['text', 'textarea'] + # only allow `ui:options.label` for boolean fields + - required: [ 'type', 'ui:options'] + properties: + type: + type: string + enum: + - 'string' + - 'number' + - 'integer' + - 'object' + - 'array' + - 'null' + - 'file' + - 'quantity' + - 'relationship' + - 'script' + - 'timer' + ui:options: + type: string + enum: ['label'] + # do not allow setting both `prepare` and `hidden` to `true` + - required: [ 'prepare', 'hidden'] + properties: + hidden: + const: true + prepare: + const: true allOf: - type: object required: [type] diff --git a/src/workflow-step-template-schema.json b/src/workflow-step-template-schema.json index aac1d539..0c3f99c9 100644 --- a/src/workflow-step-template-schema.json +++ b/src/workflow-step-template-schema.json @@ -3297,6 +3297,172 @@ "field": { "title": "Field", "description": "A valid field schema is either a valid JSON schema as per [Draft 7](http://json-schema.org/draft-07/schema#) or one of our custom field types. Some additional properties are allowed at the top level.\n", + "not": { + "oneOf": [ + { + "required": [ + "type", + "ui:options" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "number", + "integer", + "object", + "array", + "boolean", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:options": { + "type": "object", + "required": [ + "rows" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget", + "ui:options" + ], + "properties": { + "type": { + "const": "string" + }, + "ui:widget": { + "type": "string", + "enum": [ + "checkbox", + "switch", + "text" + ] + }, + "ui:options": { + "type": "object", + "required": [ + "rows" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "string", + "number", + "integer", + "object", + "array", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:widget": { + "type": "string", + "enum": [ + "checkbox", + "switch" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "number", + "integer", + "object", + "array", + "boolean", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:widget": { + "type": "string", + "enum": [ + "text", + "textarea" + ] + } + } + }, + { + "required": [ + "type", + "ui:options" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "string", + "number", + "integer", + "object", + "array", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:options": { + "type": "string", + "enum": [ + "label" + ] + } + } + }, + { + "required": [ + "prepare", + "hidden" + ], + "properties": { + "hidden": { + "const": true + }, + "prepare": { + "const": true + } + } + } + ] + }, "allOf": [ { "type": "object", diff --git a/src/workflow-template-schema.json b/src/workflow-template-schema.json index 8a214f76..854bc374 100644 --- a/src/workflow-template-schema.json +++ b/src/workflow-template-schema.json @@ -3534,6 +3534,172 @@ "field": { "title": "Field", "description": "A valid field schema is either a valid JSON schema as per [Draft 7](http://json-schema.org/draft-07/schema#) or one of our custom field types. Some additional properties are allowed at the top level.\n", + "not": { + "oneOf": [ + { + "required": [ + "type", + "ui:options" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "number", + "integer", + "object", + "array", + "boolean", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:options": { + "type": "object", + "required": [ + "rows" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget", + "ui:options" + ], + "properties": { + "type": { + "const": "string" + }, + "ui:widget": { + "type": "string", + "enum": [ + "checkbox", + "switch", + "text" + ] + }, + "ui:options": { + "type": "object", + "required": [ + "rows" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "string", + "number", + "integer", + "object", + "array", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:widget": { + "type": "string", + "enum": [ + "checkbox", + "switch" + ] + } + } + }, + { + "required": [ + "type", + "ui:widget" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "number", + "integer", + "object", + "array", + "boolean", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:widget": { + "type": "string", + "enum": [ + "text", + "textarea" + ] + } + } + }, + { + "required": [ + "type", + "ui:options" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "string", + "number", + "integer", + "object", + "array", + "null", + "file", + "quantity", + "relationship", + "script", + "timer" + ] + }, + "ui:options": { + "type": "string", + "enum": [ + "label" + ] + } + } + }, + { + "required": [ + "prepare", + "hidden" + ], + "properties": { + "hidden": { + "const": true + }, + "prepare": { + "const": true + } + } + } + ] + }, "allOf": [ { "type": "object", From 1361a221f5b933299954fca92757c84896ce3793 Mon Sep 17 00:00:00 2001 From: kgrhartlage Date: Wed, 4 Oct 2023 17:27:15 +0200 Subject: [PATCH 3/5] Link JSON Schema 07 to definition files --- .vscode/settings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 95ddd16b..afe04861 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -32,6 +32,7 @@ "./dist/workflow-step-template-schema.json": [ "/*.step-template.yml", "/step-template.yml" - ] + ], + "http://json-schema.org/draft-07/schema": ["/src/schemata/**/*.yml"] } } From 83778b3a3a602d3b131e75b4833dc60763fe3eb1 Mon Sep 17 00:00:00 2001 From: kgrhartlage Date: Mon, 9 Oct 2023 07:31:12 +0200 Subject: [PATCH 4/5] Be more positive --- dist/index.d.ts | 368 +++++++++++++----------- dist/workflow-step-template-schema.json | 273 +++++++----------- dist/workflow-template-schema.json | 273 +++++++----------- src/schemata/definitions/field.yml | 151 ++++------ src/workflow-step-template-schema.json | 273 +++++++----------- src/workflow-template-schema.json | 273 +++++++----------- 6 files changed, 668 insertions(+), 943 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index ee996e7f..97adb664 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -3036,92 +3036,6 @@ export declare const schemas: { field: { title: string; description: string; - not: { - oneOf: ({ - required: string[]; - properties: { - type: { - type: string; - enum: string[]; - const?: undefined; - }; - "ui:options": { - type: string; - required: string[]; - enum?: undefined; - }; - "ui:widget"?: undefined; - hidden?: undefined; - prepare?: undefined; - }; - } | { - required: string[]; - properties: { - type: { - const: string; - type?: undefined; - enum?: undefined; - }; - "ui:widget": { - type: string; - enum: string[]; - }; - "ui:options": { - type: string; - required: string[]; - enum?: undefined; - }; - hidden?: undefined; - prepare?: undefined; - }; - } | { - required: string[]; - properties: { - type: { - type: string; - enum: string[]; - const?: undefined; - }; - "ui:widget": { - type: string; - enum: string[]; - }; - "ui:options"?: undefined; - hidden?: undefined; - prepare?: undefined; - }; - } | { - required: string[]; - properties: { - type: { - type: string; - enum: string[]; - const?: undefined; - }; - "ui:options": { - type: string; - enum: string[]; - required?: undefined; - }; - "ui:widget"?: undefined; - hidden?: undefined; - prepare?: undefined; - }; - } | { - required: string[]; - properties: { - hidden: { - const: boolean; - }; - prepare: { - const: boolean; - }; - type?: undefined; - "ui:options"?: undefined; - "ui:widget"?: undefined; - }; - })[]; - }; allOf: ({ type: string; required: string[]; @@ -3144,7 +3058,7 @@ export declare const schemas: { }; rows: { type: string; - default: boolean; + minimum: number; description: string; markdownDescription: string; }; @@ -3195,6 +3109,9 @@ export declare const schemas: { }; }; oneOf?: undefined; + if?: undefined; + then?: undefined; + not?: undefined; } | { oneOf: { $ref: string; @@ -3202,6 +3119,99 @@ export declare const schemas: { type?: undefined; required?: undefined; properties?: undefined; + if?: undefined; + then?: undefined; + not?: undefined; + } | { + if: { + required: string[]; + properties: { + "ui:widget": { + enum: string[]; + }; + "ui:options"?: undefined; + }; + }; + then: { + properties: { + type: { + const: string; + }; + "ui:widget"?: undefined; + }; + required?: undefined; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + not?: undefined; + } | { + if: { + required: string[]; + properties: { + "ui:options": { + required: string[]; + }; + "ui:widget"?: undefined; + }; + }; + then: { + required: string[]; + properties: { + "ui:widget": { + const: string; + }; + type?: undefined; + }; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + not?: undefined; + } | { + if: { + required: string[]; + properties: { + "ui:options": { + required: string[]; + }; + "ui:widget"?: undefined; + }; + }; + then: { + properties: { + type: { + const: string; + }; + "ui:widget"?: undefined; + }; + required?: undefined; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + not?: undefined; + } | { + not: { + required: string[]; + properties: { + hidden: { + const: boolean; + }; + prepare: { + const: boolean; + }; + }; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + if?: undefined; + then?: undefined; })[]; examples: ({ type: string; @@ -6484,92 +6494,6 @@ export declare const schemas: { field: { title: string; description: string; - not: { - oneOf: ({ - required: string[]; - properties: { - type: { - type: string; - enum: string[]; - const?: undefined; - }; - "ui:options": { - type: string; - required: string[]; - enum?: undefined; - }; - "ui:widget"?: undefined; - hidden?: undefined; - prepare?: undefined; - }; - } | { - required: string[]; - properties: { - type: { - const: string; - type?: undefined; - enum?: undefined; - }; - "ui:widget": { - type: string; - enum: string[]; - }; - "ui:options": { - type: string; - required: string[]; - enum?: undefined; - }; - hidden?: undefined; - prepare?: undefined; - }; - } | { - required: string[]; - properties: { - type: { - type: string; - enum: string[]; - const?: undefined; - }; - "ui:widget": { - type: string; - enum: string[]; - }; - "ui:options"?: undefined; - hidden?: undefined; - prepare?: undefined; - }; - } | { - required: string[]; - properties: { - type: { - type: string; - enum: string[]; - const?: undefined; - }; - "ui:options": { - type: string; - enum: string[]; - required?: undefined; - }; - "ui:widget"?: undefined; - hidden?: undefined; - prepare?: undefined; - }; - } | { - required: string[]; - properties: { - hidden: { - const: boolean; - }; - prepare: { - const: boolean; - }; - type?: undefined; - "ui:options"?: undefined; - "ui:widget"?: undefined; - }; - })[]; - }; allOf: ({ type: string; required: string[]; @@ -6592,7 +6516,7 @@ export declare const schemas: { }; rows: { type: string; - default: boolean; + minimum: number; description: string; markdownDescription: string; }; @@ -6643,6 +6567,9 @@ export declare const schemas: { }; }; oneOf?: undefined; + if?: undefined; + then?: undefined; + not?: undefined; } | { oneOf: { $ref: string; @@ -6650,6 +6577,99 @@ export declare const schemas: { type?: undefined; required?: undefined; properties?: undefined; + if?: undefined; + then?: undefined; + not?: undefined; + } | { + if: { + required: string[]; + properties: { + "ui:widget": { + enum: string[]; + }; + "ui:options"?: undefined; + }; + }; + then: { + properties: { + type: { + const: string; + }; + "ui:widget"?: undefined; + }; + required?: undefined; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + not?: undefined; + } | { + if: { + required: string[]; + properties: { + "ui:options": { + required: string[]; + }; + "ui:widget"?: undefined; + }; + }; + then: { + required: string[]; + properties: { + "ui:widget": { + const: string; + }; + type?: undefined; + }; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + not?: undefined; + } | { + if: { + required: string[]; + properties: { + "ui:options": { + required: string[]; + }; + "ui:widget"?: undefined; + }; + }; + then: { + properties: { + type: { + const: string; + }; + "ui:widget"?: undefined; + }; + required?: undefined; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + not?: undefined; + } | { + not: { + required: string[]; + properties: { + hidden: { + const: boolean; + }; + prepare: { + const: boolean; + }; + }; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + if?: undefined; + then?: undefined; })[]; examples: ({ type: string; diff --git a/dist/workflow-step-template-schema.json b/dist/workflow-step-template-schema.json index a8b377d7..1261276f 100644 --- a/dist/workflow-step-template-schema.json +++ b/dist/workflow-step-template-schema.json @@ -3297,172 +3297,6 @@ "field": { "title": "Field", "description": "A valid field schema is either a valid JSON schema as per [Draft 7](http://json-schema.org/draft-07/schema#) or one of our custom field types. Some additional properties are allowed at the top level.\n", - "not": { - "oneOf": [ - { - "required": [ - "type", - "ui:options" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "number", - "integer", - "object", - "array", - "boolean", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:options": { - "type": "object", - "required": [ - "rows" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget", - "ui:options" - ], - "properties": { - "type": { - "const": "string" - }, - "ui:widget": { - "type": "string", - "enum": [ - "checkbox", - "switch", - "text" - ] - }, - "ui:options": { - "type": "object", - "required": [ - "rows" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "string", - "number", - "integer", - "object", - "array", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:widget": { - "type": "string", - "enum": [ - "checkbox", - "switch" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "number", - "integer", - "object", - "array", - "boolean", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:widget": { - "type": "string", - "enum": [ - "text", - "textarea" - ] - } - } - }, - { - "required": [ - "type", - "ui:options" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "string", - "number", - "integer", - "object", - "array", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:options": { - "type": "string", - "enum": [ - "label" - ] - } - } - }, - { - "required": [ - "prepare", - "hidden" - ], - "properties": { - "hidden": { - "const": true - }, - "prepare": { - "const": true - } - } - } - ] - }, "allOf": [ { "type": "object", @@ -3493,7 +3327,7 @@ }, "rows": { "type": "number", - "default": true, + "minimum": 0, "description": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n", "markdownDescription": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " } @@ -3565,6 +3399,111 @@ "$ref": "#/definitions/field-schema/timer" } ] + }, + { + "if": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "enum": [ + "text", + "textarea" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "string" + } + } + } + }, + { + "if": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "boolean" + } + } + } + }, + { + "if": { + "required": [ + "ui:options" + ], + "properties": { + "ui:options": { + "required": [ + "rows" + ] + } + } + }, + "then": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "const": "textarea" + } + } + } + }, + { + "if": { + "required": [ + "ui:options" + ], + "properties": { + "ui:options": { + "required": [ + "label" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "boolean" + } + } + } + }, + { + "not": { + "required": [ + "prepare", + "hidden" + ], + "properties": { + "hidden": { + "const": true + }, + "prepare": { + "const": true + } + } + } } ], "examples": [ diff --git a/dist/workflow-template-schema.json b/dist/workflow-template-schema.json index 22e1a385..cec2db53 100644 --- a/dist/workflow-template-schema.json +++ b/dist/workflow-template-schema.json @@ -3534,172 +3534,6 @@ "field": { "title": "Field", "description": "A valid field schema is either a valid JSON schema as per [Draft 7](http://json-schema.org/draft-07/schema#) or one of our custom field types. Some additional properties are allowed at the top level.\n", - "not": { - "oneOf": [ - { - "required": [ - "type", - "ui:options" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "number", - "integer", - "object", - "array", - "boolean", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:options": { - "type": "object", - "required": [ - "rows" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget", - "ui:options" - ], - "properties": { - "type": { - "const": "string" - }, - "ui:widget": { - "type": "string", - "enum": [ - "checkbox", - "switch", - "text" - ] - }, - "ui:options": { - "type": "object", - "required": [ - "rows" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "string", - "number", - "integer", - "object", - "array", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:widget": { - "type": "string", - "enum": [ - "checkbox", - "switch" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "number", - "integer", - "object", - "array", - "boolean", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:widget": { - "type": "string", - "enum": [ - "text", - "textarea" - ] - } - } - }, - { - "required": [ - "type", - "ui:options" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "string", - "number", - "integer", - "object", - "array", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:options": { - "type": "string", - "enum": [ - "label" - ] - } - } - }, - { - "required": [ - "prepare", - "hidden" - ], - "properties": { - "hidden": { - "const": true - }, - "prepare": { - "const": true - } - } - } - ] - }, "allOf": [ { "type": "object", @@ -3730,7 +3564,7 @@ }, "rows": { "type": "number", - "default": true, + "minimum": 0, "description": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n", "markdownDescription": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " } @@ -3802,6 +3636,111 @@ "$ref": "#/definitions/field-schema/timer" } ] + }, + { + "if": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "enum": [ + "text", + "textarea" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "string" + } + } + } + }, + { + "if": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "boolean" + } + } + } + }, + { + "if": { + "required": [ + "ui:options" + ], + "properties": { + "ui:options": { + "required": [ + "rows" + ] + } + } + }, + "then": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "const": "textarea" + } + } + } + }, + { + "if": { + "required": [ + "ui:options" + ], + "properties": { + "ui:options": { + "required": [ + "label" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "boolean" + } + } + } + }, + { + "not": { + "required": [ + "prepare", + "hidden" + ], + "properties": { + "hidden": { + "const": true + }, + "prepare": { + "const": true + } + } + } } ], "examples": [ diff --git a/src/schemata/definitions/field.yml b/src/schemata/definitions/field.yml index d2a4525a..2c123ede 100755 --- a/src/schemata/definitions/field.yml +++ b/src/schemata/definitions/field.yml @@ -2,106 +2,6 @@ title: Field description: | A valid field schema is either a valid JSON schema as per [Draft 7](http://json-schema.org/draft-07/schema#) or one of our custom field types. Some additional properties are allowed at the top level. -not: - oneOf: - # only allow `ui:options.rows` for string fields - - required: ['type', 'ui:options'] - properties: - type: - type: string - enum: - - 'number' - - 'integer' - - 'object' - - 'array' - - 'boolean' - - 'null' - - 'file' - - 'quantity' - - 'relationship' - - 'script' - - 'timer' - ui:options: - type: object - required: ['rows'] - # don't allow `ui:options.rows` for string fields that are not textarea - - required: [ 'type', 'ui:widget', 'ui:options'] - properties: - type: - const: string - ui:widget: - type: string - enum: ['checkbox', 'switch', 'text'] - ui:options: - type: object - required: ['rows'] - # only allow text & switch widgets for boolean fields - - required: [ 'type', 'ui:widget'] - properties: - type: - type: string - enum: - - 'string' - - 'number' - - 'integer' - - 'object' - - 'array' - - 'null' - - 'file' - - 'quantity' - - 'relationship' - - 'script' - - 'timer' - ui:widget: - type: string - enum: ['checkbox', 'switch'] - # only allow text & textarea widgets for string fields - - required: [ 'type', 'ui:widget'] - properties: - type: - type: string - enum: - - 'number' - - 'integer' - - 'object' - - 'array' - - 'boolean' - - 'null' - - 'file' - - 'quantity' - - 'relationship' - - 'script' - - 'timer' - ui:widget: - type: string - enum: ['text', 'textarea'] - # only allow `ui:options.label` for boolean fields - - required: [ 'type', 'ui:options'] - properties: - type: - type: string - enum: - - 'string' - - 'number' - - 'integer' - - 'object' - - 'array' - - 'null' - - 'file' - - 'quantity' - - 'relationship' - - 'script' - - 'timer' - ui:options: - type: string - enum: ['label'] - # do not allow setting both `prepare` and `hidden` to `true` - - required: [ 'prepare', 'hidden'] - properties: - hidden: - const: true - prepare: - const: true allOf: - type: object required: [type] @@ -124,7 +24,7 @@ allOf: A flag indicating whether a field of type `boolean` has a display label. Setting this to `false` will display either only a checkbox or switch control element, without any visible label. rows: type: number - default: true + minimum: 0 description: | The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting. readOnly: @@ -172,6 +72,55 @@ allOf: - $ref: '#/definitions/field-schema/relationship' - $ref: '#/definitions/field-schema/script' - $ref: '#/definitions/field-schema/timer' + # only allow text & textarea widgets for string fields + - if: + required: [ui:widget] + properties: + ui:widget: + enum: ['text', 'textarea'] + then: + properties: + type: + const: string + # only allow checkbox & switch widgets for boolean fields + - if: + required: [ui:widget] + properties: + ui:widget: + enum: ['checkbox', 'switch'] + then: + properties: + type: + const: boolean + # only allow `ui:options.rows` for textarea widgets + - if: + required: ['ui:options'] + properties: + ui:options: + required: ['rows'] + then: + required: [ui:widget] + properties: + ui:widget: + const: 'textarea' + # only allow `ui:options.label` for boolean fields + - if: + required: ['ui:options'] + properties: + ui:options: + required: ['label'] + then: + properties: + type: + const: boolean + # do not allow setting both `prepare` and `hidden` to `true` + - not: + required: [ 'prepare', 'hidden'] + properties: + hidden: + const: true + prepare: + const: true examples: # enum options - type: string diff --git a/src/workflow-step-template-schema.json b/src/workflow-step-template-schema.json index 0c3f99c9..e112c92d 100644 --- a/src/workflow-step-template-schema.json +++ b/src/workflow-step-template-schema.json @@ -3297,172 +3297,6 @@ "field": { "title": "Field", "description": "A valid field schema is either a valid JSON schema as per [Draft 7](http://json-schema.org/draft-07/schema#) or one of our custom field types. Some additional properties are allowed at the top level.\n", - "not": { - "oneOf": [ - { - "required": [ - "type", - "ui:options" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "number", - "integer", - "object", - "array", - "boolean", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:options": { - "type": "object", - "required": [ - "rows" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget", - "ui:options" - ], - "properties": { - "type": { - "const": "string" - }, - "ui:widget": { - "type": "string", - "enum": [ - "checkbox", - "switch", - "text" - ] - }, - "ui:options": { - "type": "object", - "required": [ - "rows" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "string", - "number", - "integer", - "object", - "array", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:widget": { - "type": "string", - "enum": [ - "checkbox", - "switch" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "number", - "integer", - "object", - "array", - "boolean", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:widget": { - "type": "string", - "enum": [ - "text", - "textarea" - ] - } - } - }, - { - "required": [ - "type", - "ui:options" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "string", - "number", - "integer", - "object", - "array", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:options": { - "type": "string", - "enum": [ - "label" - ] - } - } - }, - { - "required": [ - "prepare", - "hidden" - ], - "properties": { - "hidden": { - "const": true - }, - "prepare": { - "const": true - } - } - } - ] - }, "allOf": [ { "type": "object", @@ -3493,7 +3327,7 @@ }, "rows": { "type": "number", - "default": true, + "minimum": 0, "description": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n", "markdownDescription": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " } @@ -3565,6 +3399,111 @@ "$ref": "#/definitions/field-schema/timer" } ] + }, + { + "if": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "enum": [ + "text", + "textarea" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "string" + } + } + } + }, + { + "if": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "boolean" + } + } + } + }, + { + "if": { + "required": [ + "ui:options" + ], + "properties": { + "ui:options": { + "required": [ + "rows" + ] + } + } + }, + "then": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "const": "textarea" + } + } + } + }, + { + "if": { + "required": [ + "ui:options" + ], + "properties": { + "ui:options": { + "required": [ + "label" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "boolean" + } + } + } + }, + { + "not": { + "required": [ + "prepare", + "hidden" + ], + "properties": { + "hidden": { + "const": true + }, + "prepare": { + "const": true + } + } + } } ], "examples": [ diff --git a/src/workflow-template-schema.json b/src/workflow-template-schema.json index 854bc374..d48fcf3e 100644 --- a/src/workflow-template-schema.json +++ b/src/workflow-template-schema.json @@ -3534,172 +3534,6 @@ "field": { "title": "Field", "description": "A valid field schema is either a valid JSON schema as per [Draft 7](http://json-schema.org/draft-07/schema#) or one of our custom field types. Some additional properties are allowed at the top level.\n", - "not": { - "oneOf": [ - { - "required": [ - "type", - "ui:options" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "number", - "integer", - "object", - "array", - "boolean", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:options": { - "type": "object", - "required": [ - "rows" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget", - "ui:options" - ], - "properties": { - "type": { - "const": "string" - }, - "ui:widget": { - "type": "string", - "enum": [ - "checkbox", - "switch", - "text" - ] - }, - "ui:options": { - "type": "object", - "required": [ - "rows" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "string", - "number", - "integer", - "object", - "array", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:widget": { - "type": "string", - "enum": [ - "checkbox", - "switch" - ] - } - } - }, - { - "required": [ - "type", - "ui:widget" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "number", - "integer", - "object", - "array", - "boolean", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:widget": { - "type": "string", - "enum": [ - "text", - "textarea" - ] - } - } - }, - { - "required": [ - "type", - "ui:options" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "string", - "number", - "integer", - "object", - "array", - "null", - "file", - "quantity", - "relationship", - "script", - "timer" - ] - }, - "ui:options": { - "type": "string", - "enum": [ - "label" - ] - } - } - }, - { - "required": [ - "prepare", - "hidden" - ], - "properties": { - "hidden": { - "const": true - }, - "prepare": { - "const": true - } - } - } - ] - }, "allOf": [ { "type": "object", @@ -3730,7 +3564,7 @@ }, "rows": { "type": "number", - "default": true, + "minimum": 0, "description": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n", "markdownDescription": "The number of rows to display when a field of type `string` is configured to display a textarea element via the `ui:widget` setting.\n\n\nSee more: [Field Schema](https://schema.laboperator.com/schemas/definitions/field) " } @@ -3802,6 +3636,111 @@ "$ref": "#/definitions/field-schema/timer" } ] + }, + { + "if": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "enum": [ + "text", + "textarea" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "string" + } + } + } + }, + { + "if": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "boolean" + } + } + } + }, + { + "if": { + "required": [ + "ui:options" + ], + "properties": { + "ui:options": { + "required": [ + "rows" + ] + } + } + }, + "then": { + "required": [ + "ui:widget" + ], + "properties": { + "ui:widget": { + "const": "textarea" + } + } + } + }, + { + "if": { + "required": [ + "ui:options" + ], + "properties": { + "ui:options": { + "required": [ + "label" + ] + } + } + }, + "then": { + "properties": { + "type": { + "const": "boolean" + } + } + } + }, + { + "not": { + "required": [ + "prepare", + "hidden" + ], + "properties": { + "hidden": { + "const": true + }, + "prepare": { + "const": true + } + } + } } ], "examples": [ From b74e3091371153feb42e58fa0371302576da44b2 Mon Sep 17 00:00:00 2001 From: kgrhartlage Date: Tue, 10 Oct 2023 15:00:34 +0200 Subject: [PATCH 5/5] Reverse if/then definitions --- dist/index.d.ts | 36 ++++++++++++++----------- dist/workflow-step-template-schema.json | 34 ++++++++++------------- dist/workflow-template-schema.json | 34 ++++++++++------------- src/schemata/definitions/field.yml | 18 ++++++------- src/workflow-step-template-schema.json | 34 ++++++++++------------- src/workflow-template-schema.json | 34 ++++++++++------------- 6 files changed, 84 insertions(+), 106 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index 97adb664..385d3fd1 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -3124,20 +3124,21 @@ export declare const schemas: { not?: undefined; } | { if: { - required: string[]; properties: { - "ui:widget": { - enum: string[]; + type: { + const: string; }; "ui:options"?: undefined; }; + required?: undefined; }; then: { properties: { - type: { - const: string; + "ui:widget": { + enum: string[]; + const?: undefined; }; - "ui:widget"?: undefined; + type?: undefined; }; required?: undefined; }; @@ -3153,7 +3154,7 @@ export declare const schemas: { "ui:options": { required: string[]; }; - "ui:widget"?: undefined; + type?: undefined; }; }; then: { @@ -3161,6 +3162,7 @@ export declare const schemas: { properties: { "ui:widget": { const: string; + enum?: undefined; }; type?: undefined; }; @@ -3177,7 +3179,7 @@ export declare const schemas: { "ui:options": { required: string[]; }; - "ui:widget"?: undefined; + type?: undefined; }; }; then: { @@ -6582,20 +6584,21 @@ export declare const schemas: { not?: undefined; } | { if: { - required: string[]; properties: { - "ui:widget": { - enum: string[]; + type: { + const: string; }; "ui:options"?: undefined; }; + required?: undefined; }; then: { properties: { - type: { - const: string; + "ui:widget": { + enum: string[]; + const?: undefined; }; - "ui:widget"?: undefined; + type?: undefined; }; required?: undefined; }; @@ -6611,7 +6614,7 @@ export declare const schemas: { "ui:options": { required: string[]; }; - "ui:widget"?: undefined; + type?: undefined; }; }; then: { @@ -6619,6 +6622,7 @@ export declare const schemas: { properties: { "ui:widget": { const: string; + enum?: undefined; }; type?: undefined; }; @@ -6635,7 +6639,7 @@ export declare const schemas: { "ui:options": { required: string[]; }; - "ui:widget"?: undefined; + type?: undefined; }; }; then: { diff --git a/dist/workflow-step-template-schema.json b/dist/workflow-step-template-schema.json index 1261276f..20bd31f7 100644 --- a/dist/workflow-step-template-schema.json +++ b/dist/workflow-step-template-schema.json @@ -3402,44 +3402,38 @@ }, { "if": { - "required": [ - "ui:widget" - ], "properties": { - "ui:widget": { - "enum": [ - "text", - "textarea" - ] + "type": { + "const": "string" } } }, "then": { "properties": { - "type": { - "const": "string" + "ui:widget": { + "enum": [ + "text", + "textarea" + ] } } } }, { "if": { - "required": [ - "ui:widget" - ], "properties": { - "ui:widget": { - "enum": [ - "checkbox", - "switch" - ] + "type": { + "const": "boolean" } } }, "then": { "properties": { - "type": { - "const": "boolean" + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] } } } diff --git a/dist/workflow-template-schema.json b/dist/workflow-template-schema.json index cec2db53..7d1b4297 100644 --- a/dist/workflow-template-schema.json +++ b/dist/workflow-template-schema.json @@ -3639,44 +3639,38 @@ }, { "if": { - "required": [ - "ui:widget" - ], "properties": { - "ui:widget": { - "enum": [ - "text", - "textarea" - ] + "type": { + "const": "string" } } }, "then": { "properties": { - "type": { - "const": "string" + "ui:widget": { + "enum": [ + "text", + "textarea" + ] } } } }, { "if": { - "required": [ - "ui:widget" - ], "properties": { - "ui:widget": { - "enum": [ - "checkbox", - "switch" - ] + "type": { + "const": "boolean" } } }, "then": { "properties": { - "type": { - "const": "boolean" + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] } } } diff --git a/src/schemata/definitions/field.yml b/src/schemata/definitions/field.yml index 2c123ede..b71b105b 100755 --- a/src/schemata/definitions/field.yml +++ b/src/schemata/definitions/field.yml @@ -74,24 +74,22 @@ allOf: - $ref: '#/definitions/field-schema/timer' # only allow text & textarea widgets for string fields - if: - required: [ui:widget] - properties: - ui:widget: - enum: ['text', 'textarea'] - then: properties: type: const: string - # only allow checkbox & switch widgets for boolean fields - - if: - required: [ui:widget] + then: properties: ui:widget: - enum: ['checkbox', 'switch'] - then: + enum: ['text', 'textarea'] + # only allow checkbox & switch widgets for boolean fields + - if: properties: type: const: boolean + then: + properties: + ui:widget: + enum: ['checkbox', 'switch'] # only allow `ui:options.rows` for textarea widgets - if: required: ['ui:options'] diff --git a/src/workflow-step-template-schema.json b/src/workflow-step-template-schema.json index e112c92d..5e04ed01 100644 --- a/src/workflow-step-template-schema.json +++ b/src/workflow-step-template-schema.json @@ -3402,44 +3402,38 @@ }, { "if": { - "required": [ - "ui:widget" - ], "properties": { - "ui:widget": { - "enum": [ - "text", - "textarea" - ] + "type": { + "const": "string" } } }, "then": { "properties": { - "type": { - "const": "string" + "ui:widget": { + "enum": [ + "text", + "textarea" + ] } } } }, { "if": { - "required": [ - "ui:widget" - ], "properties": { - "ui:widget": { - "enum": [ - "checkbox", - "switch" - ] + "type": { + "const": "boolean" } } }, "then": { "properties": { - "type": { - "const": "boolean" + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] } } } diff --git a/src/workflow-template-schema.json b/src/workflow-template-schema.json index d48fcf3e..c9f5d52f 100644 --- a/src/workflow-template-schema.json +++ b/src/workflow-template-schema.json @@ -3639,44 +3639,38 @@ }, { "if": { - "required": [ - "ui:widget" - ], "properties": { - "ui:widget": { - "enum": [ - "text", - "textarea" - ] + "type": { + "const": "string" } } }, "then": { "properties": { - "type": { - "const": "string" + "ui:widget": { + "enum": [ + "text", + "textarea" + ] } } } }, { "if": { - "required": [ - "ui:widget" - ], "properties": { - "ui:widget": { - "enum": [ - "checkbox", - "switch" - ] + "type": { + "const": "boolean" } } }, "then": { "properties": { - "type": { - "const": "boolean" + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] } } }