diff --git a/schema/input.ts b/schema/input.ts index 2d1ce97..d01024f 100644 --- a/schema/input.ts +++ b/schema/input.ts @@ -1,82 +1,73 @@ +import { UiConfig } from "./ui"; + /** * @x-go-file input.go */ export interface Input { + /** + * Type defines the input type. + */ + type: + | "string" + | "number" + | "boolean" + | "array" + | "duration" + | "choice" // GitHub compatibility + | "environment" // GitHub compatibility + | "secret"; - /** - * Type defines the input type. - */ - type: - "string" - | "number" - | "boolean" - | "array" - | "duration" - | "choice" // GitHub compatibility - | "environment" // GitHub compatibility - | "secret" - - /** - * Description defines the input description. - */ - description?: string - - /** - * @go-type: interface{} - */ - default?: any - - /** - * Required indicates the input is required. - */ - required?: boolean; + /** + * Description defines the input description. + */ + description?: string; - /** - * Items defines an array type. - */ - items?: any[] + /** + * @go-type: interface{} + * Default value populated for this input + */ + default?: any; - /** - * Enum defines a list of accepted input values. - */ - enum?: any[] + /** + * Required indicates the input is required. + */ + required?: boolean; - /** - * Pattern defines a regular expression input constraint. - */ - pattern?: string; + /** + * Items defines an array type. + */ + items?: any[]; - /** - * Component defines the form element that should be used to - * render the input. - */ - component?: "dropdown" | "text" | "number" | "date" | "datetime" | string; + /** + * Enum defines a list of accepted input values. + */ + enum?: any[]; - /** - * Autofocus configures the form element autofocus attribute. - */ - autofocus?: boolean; + /** + * Options defines a list of accepted input values. + * This is an alias for enum. + * @github + */ + options?: any[]; - /** - * Placeholder configures the form element placeholder attribute. - */ - placeholder?: string; + /** + * Pattern defines a regular expression input constraint. + */ + pattern?: string; - /** - * Tooltip configures the form element alt attribute. - */ - tooltip?: string; + /** + * Mask indicates the input should be masked. + * @deprecated + */ + mask?: boolean; - /** - * Options defines a list of accepted input values. - * This is an alias for enum. - * @github - */ - options?: any[] + /** + * Label to be displayed in the UI for this input + */ + label?: string; - /** - * Mask indicates the input should be masked. - * @deprecated - */ - mask?: boolean + /** + * Config to override default UI rendering behaviour + */ + ui?: UiConfig; } diff --git a/schema/template.ts b/schema/template.ts index 4a55426..681292b 100644 --- a/schema/template.ts +++ b/schema/template.ts @@ -10,4 +10,46 @@ export interface Template { inputs?: Record stage?: Stage; step?: Step; + + /** + * Provide a Layout to control ordering and grouping of inputs in the UI + */ + layout?: Layout + + /** + * Base64 encoded image to be shown in the list of templates + */ + icon?: string + + /** + * enum of supported logo names from Harness Design System + * https://harness-design.netlify.app/components/logo/#available-logos + */ + iconName?: string + + /** + * Absolute URL to a hosted image + */ + iconUrl?: string + + id?: string + name?: string + description?: string + version?: string + author?: "harness" | string + alias?: "build" | "deploy" + module?: Array<"cd" | "ci"> + tags?: Record +} + +type Layout = Array +type InputName = string + +/* + * InputGroups will be shown as accordions in the UI if a title is provided + */ +interface InputGroup { + items: Layout // you can have nested groups within groups + title?: string + open?: boolean } diff --git a/schema/ui.ts b/schema/ui.ts new file mode 100644 index 0000000..77f39f0 --- /dev/null +++ b/schema/ui.ts @@ -0,0 +1,37 @@ +export interface UiConfig { + /** + * CEL expression to add dynamic behaviour. + * This input will be displayed only when this condition is true. + * All inputs in this template are available to reference here. + */ + visible?: string + + /** + * Component defines the form element that should be used to + * override the default renderer for the input. + */ + component?: "dropdown" | "text" | "number" | "date" | "datetime" | "select" | string; + + /** + * Autofocus configures the form element autofocus attribute. + */ + autofocus?: boolean; + + /** + * Placeholder configures the form element placeholder attribute. + */ + placeholder?: string; + + /** + * Tooltip configures the form element alt attribute. + */ + tooltip?: string; + + /** + * Types of values allowed for this input. + * Fixed: User must enter value when configuring the pipeline + * Runtime: User must enter value when running the pipeline + * Expression: Value will be derived by evaluating this CEL / JEXL expression + */ + allowedValueTypes?: Array<'fixed' | 'runtime' | 'expression'> +} \ No newline at end of file