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"] } } diff --git a/dist/index.d.ts b/dist/index.d.ts index 8634019c..385d3fd1 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; + minimum: number; + description: string; + markdownDescription: string; + }; }; markdownDescription: string; }; @@ -3103,6 +3109,9 @@ export declare const schemas: { }; }; oneOf?: undefined; + if?: undefined; + then?: undefined; + not?: undefined; } | { oneOf: { $ref: string; @@ -3110,6 +3119,101 @@ export declare const schemas: { type?: undefined; required?: undefined; properties?: undefined; + if?: undefined; + then?: undefined; + not?: undefined; + } | { + if: { + properties: { + type: { + const: string; + }; + "ui:options"?: undefined; + }; + required?: undefined; + }; + then: { + properties: { + "ui:widget": { + enum: string[]; + const?: undefined; + }; + type?: undefined; + }; + required?: undefined; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + not?: undefined; + } | { + if: { + required: string[]; + properties: { + "ui:options": { + required: string[]; + }; + type?: undefined; + }; + }; + then: { + required: string[]; + properties: { + "ui:widget": { + const: string; + enum?: undefined; + }; + type?: undefined; + }; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + not?: undefined; + } | { + if: { + required: string[]; + properties: { + "ui:options": { + required: string[]; + }; + type?: 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; @@ -6412,6 +6516,12 @@ export declare const schemas: { description: string; markdownDescription: string; }; + rows: { + type: string; + minimum: number; + description: string; + markdownDescription: string; + }; }; markdownDescription: string; }; @@ -6459,6 +6569,9 @@ export declare const schemas: { }; }; oneOf?: undefined; + if?: undefined; + then?: undefined; + not?: undefined; } | { oneOf: { $ref: string; @@ -6466,6 +6579,101 @@ export declare const schemas: { type?: undefined; required?: undefined; properties?: undefined; + if?: undefined; + then?: undefined; + not?: undefined; + } | { + if: { + properties: { + type: { + const: string; + }; + "ui:options"?: undefined; + }; + required?: undefined; + }; + then: { + properties: { + "ui:widget": { + enum: string[]; + const?: undefined; + }; + type?: undefined; + }; + required?: undefined; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + not?: undefined; + } | { + if: { + required: string[]; + properties: { + "ui:options": { + required: string[]; + }; + type?: undefined; + }; + }; + then: { + required: string[]; + properties: { + "ui:widget": { + const: string; + enum?: undefined; + }; + type?: undefined; + }; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + oneOf?: undefined; + not?: undefined; + } | { + if: { + required: string[]; + properties: { + "ui:options": { + required: string[]; + }; + type?: 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 48ceb718..20bd31f7 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", + "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) " } }, "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) " @@ -3393,6 +3399,105 @@ "$ref": "#/definitions/field-schema/timer" } ] + }, + { + "if": { + "properties": { + "type": { + "const": "string" + } + } + }, + "then": { + "properties": { + "ui:widget": { + "enum": [ + "text", + "textarea" + ] + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "boolean" + } + } + }, + "then": { + "properties": { + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] + } + } + } + }, + { + "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 89e7020e..7d1b4297 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", + "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) " } }, "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) " @@ -3630,6 +3636,105 @@ "$ref": "#/definitions/field-schema/timer" } ] + }, + { + "if": { + "properties": { + "type": { + "const": "string" + } + } + }, + "then": { + "properties": { + "ui:widget": { + "enum": [ + "text", + "textarea" + ] + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "boolean" + } + } + }, + "then": { + "properties": { + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] + } + } + } + }, + { + "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 154d685c..b71b105b 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 + 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: type: boolean default: false @@ -67,6 +72,53 @@ 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: + properties: + type: + const: string + then: + properties: + ui:widget: + 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'] + 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 0bea1413..5e04ed01 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", + "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) " } }, "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) " @@ -3393,6 +3399,105 @@ "$ref": "#/definitions/field-schema/timer" } ] + }, + { + "if": { + "properties": { + "type": { + "const": "string" + } + } + }, + "then": { + "properties": { + "ui:widget": { + "enum": [ + "text", + "textarea" + ] + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "boolean" + } + } + }, + "then": { + "properties": { + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] + } + } + } + }, + { + "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 bf124eaa..c9f5d52f 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", + "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) " } }, "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) " @@ -3630,6 +3636,105 @@ "$ref": "#/definitions/field-schema/timer" } ] + }, + { + "if": { + "properties": { + "type": { + "const": "string" + } + } + }, + "then": { + "properties": { + "ui:widget": { + "enum": [ + "text", + "textarea" + ] + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "boolean" + } + } + }, + "then": { + "properties": { + "ui:widget": { + "enum": [ + "checkbox", + "switch" + ] + } + } + } + }, + { + "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": [