Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8d45d70
feat(wes): check I/O Schemas against the profile
uniqueg Dec 3, 2026
abd7e89
feat(wes): check file reference values
uniqueg Dec 3, 2026
8d98107
feat(wes): render Markdown descriptions safely
uniqueg Dec 3, 2026
21d392a
feat(wes): add the I/O Schema input form
uniqueg Dec 3, 2026
6a40038
fix(wes): harden I/O Schema checks
uniqueg Dec 3, 2026
8be98ef
feat(wes): render the I/O Schema widget hints
uniqueg Dec 3, 2026
c771794
fix(wes): bound the I/O form's field walk
uniqueg Dec 3, 2026
2bba81e
feat(wes): check file reference inputs
uniqueg Dec 3, 2026
70ca407
feat(wes): add error messages, hidden inputs
uniqueg Dec 3, 2026
e340895
feat(wes): edit lists and unions in the I/O form
uniqueg Dec 3, 2026
48d818c
feat(wes): show allOf groups as form sections
uniqueg Dec 3, 2026
cedf572
fix(wes): name I/O form controls and buttons
uniqueg Dec 3, 2026
48fdfbd
fix(wes): check file values by the schema
uniqueg Dec 3, 2026
8f06592
fix(wes): bound and narrow the file value walk
uniqueg Dec 3, 2026
06bda5d
fix(wes): resolve all references of an IO schema
uniqueg Dec 4, 2026
79809eb
fix(wes): follow every reference in file checks
uniqueg Dec 4, 2026
15b57ae
fix(wes): fix I/O form state and controls
uniqueg Dec 4, 2026
e0e666d
fix(wes): describe combined and large inputs right
uniqueg Dec 4, 2026
8ced628
fix(wes): define the I/O form element only once
uniqueg Dec 4, 2026
0462c94
docs(wes): document the I/O form fixes
uniqueg Dec 4, 2026
1148d44
fix(wes): keep new number list items editable
uniqueg Dec 4, 2026
12fd37f
fix(wes): compile annotation schemas everywhere
uniqueg Dec 4, 2026
189a418
fix(wes): refuse file values behind lost refs
uniqueg Dec 4, 2026
4c6d0fc
fix(wes): fix slider edges and union defaults
uniqueg Dec 4, 2026
440eee7
docs(wes): document fail-closed file checks
uniqueg Dec 4, 2026
2b9ca89
fix(wes): close gaps in defaults, sliders, file checks
uniqueg Dec 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wes-io-form.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@elixir-cloud/wes": minor
---

Add `ecc-client-ga4gh-wes-io-form`, which renders the input form of a workflow from its GA4GH IO Schema (profile 0.3.0), checks the schema offline against the profile, validates the values in the browser and emits them with `ecc-io-form-changed` (`{values, valid, errors}`). Output descriptions of `ecc-client-ga4gh-wes-run-output` can be rendered as Markdown (off by default).
52 changes: 52 additions & 0 deletions apps/documentation/components/packages/wes/IoFormPreview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React, { useState } from 'react';
import { ECCClientGa4ghWesIoForm } from '@elixir-cloud/wes/react';
import PreviewLayout from '@/components/common/PreviewLayout';
import { ioFormExamples } from '@/components/packages/wes/ioFormExamples';

const allowedSchemes = ['drs', 'https', 's3'];

interface Change {
values: Record<string, unknown>;
valid: boolean;
errors: { pointer: string; message: string }[];
}

export default function IoFormPreview() {
const [example, setExample] = useState('demo');
const [change, setChange] = useState<Change | null>(null);

return (
<PreviewLayout>
<div className='flex w-full flex-col gap-4'>
<label className='flex items-center gap-2 text-sm'>
Example
<select
className='rounded-md border px-2 py-1'
value={example}
onChange={(e) => {
setChange(null);
setExample(e.target.value);
}}
>
{Object.entries(ioFormExamples).map(([key, { label }]) => (
<option key={key} value={key}>
{label}
</option>
))}
</select>
</label>
<ECCClientGa4ghWesIoForm
key={example}
schema={ioFormExamples[example].schema}
allowedSchemes={allowedSchemes}
onEccIoFormChanged={(event: CustomEvent<Change>) => setChange(event.detail)}
/>
{change && (
<pre className='overflow-auto rounded-md bg-muted p-3 text-xs'>
{JSON.stringify(change, null, 2)}
</pre>
)}
</div>
</PreviewLayout>
);
}
698 changes: 698 additions & 0 deletions apps/documentation/components/packages/wes/ioFormExamples.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion apps/documentation/pages/docs/wes/_meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"introduction": "Introduction",
"providers": "Providers",
"io-schema": "I/O Schemas",
"components": "Components"
}
}
5 changes: 3 additions & 2 deletions apps/documentation/pages/docs/wes/components/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"runs": "Runs",
"run": "Run",
"run-output": "Run Output",
"run-create": "Run Create"
}
"run-create": "Run Create",
"io-form": "I/O Form"
}
143 changes: 143 additions & 0 deletions apps/documentation/pages/docs/wes/components/io-form.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { Callout, Tabs } from 'nextra/components'
import ComponentName from '@/components/common/ComponentName'
import IoFormPreview from '@/components/packages/wes/IoFormPreview'

# EccClientGa4ghWesIoForm Component

<ComponentName
tagName='ecc-client-ga4gh-wes-io-form'
reactTagName='ECCClientGa4ghWesIoForm'
version='2.0.0-alpha.52'
/>

<Callout type="info">
A proposal (cloud-components#444): the element, its event and the libraries behind it may still change.
</Callout>

## Overview

The `ecc-client-ga4gh-wes-io-form` component renders the input form of a workflow from its [GA4GH IO Schema](https://github.com/elixir-cloud-aai/ga4gh-io-schema) (version 0.3.0, commit [`2c3dc49`](https://github.com/elixir-cloud-aai/ga4gh-io-schema/tree/2c3dc49ad89f0a556272f160369a2a2d7a21dac3)). It renders the `inputs` of the schema, validates the values in the browser and emits them; the app submits them, e.g. as `workflow_params` of a WES run.

1. The schema is checked offline against the profile (see [I/O Schemas](../io-schema)). A schema that doesn't conform shows its errors, with the JSON Pointer of each, and no form.
2. Each input gets a control by its `type`, `format` and `enum`:

| Input | Control |
|-------|---------|
| `string` | Text field |
| `string` with `format` `date`, `time` or `date-time` | Date, time or date-and-time picker |
| `integer`, `number` | Text field that gives a number |
| `boolean` | Checkbox |
| `enum` or `const` (any type) | Dropdown |
| `object` with `properties` | A group with a field per property, at any depth |
| `array` with `items` | A list with a field per item, "Add" and "Remove" within `minItems` and `maxItems` |
| Branches of `allOf` with `properties` (e.g. nf-core parameter groups) | Sections of the object, with the branch's `title` and `description` |
| `anyOf` or `oneOf` without a `type` | A choice of the branch (by its `title`, else its type), then the branch's control |
| Anything else (e.g. `prefixItems`, objects without `properties`) | JSON text area |

A widget hint (`x-ga4gh-ui-widget`) chooses the control where it fits its schema, with the keywords it needs next to it, as the profile's [UI widgets](https://ga4gh-io-schema.readthedocs.io/en/latest/specification/widgets/) define:

| Widget | Control |
|--------|---------|
| `text`, `number`, `checkbox`, `date-picker`, `time-picker`, `datetime-picker` | As above |
| `textarea` | Text area |
| `slider` | Slider within the bounds, in steps of `multipleOf` (else 1 for integers, any step for numbers); an exclusive bound moves one step inward (a thousandth of the range without a step) |
| `dropdown`, `radio` | Dropdown (radio buttons are rendered as a dropdown for now) |
| `dropdown` or `tags` on an array with `items.enum` | Multiple choice |
| `tags` on an array of strings | One tag per line |
| `typeahead` | Text field with the `examples` as suggestions; with `enum`, a dropdown |
| `switch` | Checkbox (for now) |
| `color-picker` | Colour picker, giving `#rrggbb` in lowercase |

File references (`x-ga4gh-file`, also as a branch of `anyOf` or `oneOf`) get a text field for a URI or a relative path. Their values are checked by the profile's rules (see [File references](../io-schema#file-references)) against `allowedSchemes`, narrowed by the reference's `schemes`; the checks follow the schema, not the controls, so they also cover branches of `anyOf` or `oneOf` that the form doesn't show, items of lists and tags, `prefixItems`, `contains`, maps (`patternProperties`, `additionalProperties`, `unevaluatedProperties`), `dependentSchemas` and both `then` and `else` (references by JSON Pointer, `$anchor`, `$dynamicAnchor` and `$id`, also inside embedded resources; `$dynamicRef` to every schema with its anchor name, and a value behind a reference the checks can't follow is refused). In a union, a string isn't checked as a file reference only if a branch without a file reference surely takes it: every keyword of that branch (also through `allOf` and `$ref`) is `type`, `const`, `enum`, `pattern`, `minLength`, `maxLength` or an annotation, and the string passes them. File reference text is kept as entered, so surrounding spaces make it invalid. Values nested more than 64 levels deep are refused. Refused values make the form invalid, and refused defaults aren't prefilled. A picker for DRS or storage is up to the app for now.

A widget that doesn't fit, a viewer, or a `custom:` widget renders the input by its type. Inputs whose `type` allows `null` get a "No value (null)" checkbox, which disables the control while it is checked. Required inputs are marked with `*` (also when an `allOf` branch requires them). Inputs with more than 1000 properties, and lists with more than 1000 items, are edited as JSON.
3. Inputs start from their `default` values (a union without one from the default of its first branch); inputs the user clears are left out of the values, not sent as `null` or `""`. A schema's own `default` is kept as it is, also `""` or `null`.
4. Errors show at their input once it was changed, and at all inputs after `reportValidity()`.
5. A schema's `x-ga4gh-error-message` replaces the validator's messages for failures at its value, once per value; of several, the outermost wins (the input's own over that of a shared definition it refers to). Failures of a property's value use the property's message; a missing property uses the message of its object.
6. Inputs with `x-ga4gh-hidden: true` are listed under a collapsed "Advanced" section, except inputs that must be set (required, without a default) and inputs whose values fail.

Values follow the profile's widget table: a time is an RFC 3339 `full-time` with the offset of the browser's time zone (`14:30:00+01:00`), a date-time is in UTC (`2026-12-14T09:15:00Z`). Text that isn't a number is kept, so that the error says what is wrong.

## Security

Schemas are treated as untrusted: titles, descriptions and choices are shown as text, never as markup. Descriptions with `x-ga4gh-description-format: markdown` are shown as plain text unless the app switches Markdown on (see [Descriptions](../io-schema#descriptions)).

## Usage

The preview renders example schemas of the IO Schema profile and shows what the form emits.

<Tabs items={['Preview', 'React', 'HTML']}>
<Tabs.Tab>
<IoFormPreview />
</Tabs.Tab>

<Tabs.Tab>
```tsx showLineNumbers copy filename="io-form.tsx"
import React, { useState } from 'react';
import { ECCClientGa4ghWesIoForm } from '@elixir-cloud/wes/react';

export default function IoForm({ schema }: { schema: object }) {
const [inputs, setInputs] = useState({ values: {}, valid: false });
return (
<>
<ECCClientGa4ghWesIoForm
schema={schema}
allowedSchemes={['drs', 'https', 's3']}
onEccIoFormChanged={(e) => setInputs(e.detail)}
/>
<button disabled={!inputs.valid}>Run</button>
</>
);
}
```
</Tabs.Tab>

<Tabs.Tab>
```html showLineNumbers copy filename="io-form.html"
<!DOCTYPE html>
<html lang="en">
<head>
<script type="module" src="https://esm.sh/@elixir-cloud/wes@2.0.0-alpha.52"></script>
</head>
<body>
<ecc-client-ga4gh-wes-io-form allowed-schemes="drs https s3"></ecc-client-ga4gh-wes-io-form>

<script type="module">
const form = document.querySelector('ecc-client-ga4gh-wes-io-form');
form.schema = await (await fetch('ga4gh-io.schema.json')).json();
form.addEventListener('ecc-io-form-changed', (e) => {
console.log(e.detail.valid, e.detail.values, e.detail.errors);
});
</script>
</body>
</html>
```
</Tabs.Tab>
</Tabs>

## Properties

| Property | Attribute | Type | Default | Description |
|----------|-----------|------|---------|-------------|
| `schema` | | `object` | `undefined` | The IO schema of the workflow. |
| `values` | | `object` | `undefined` | Values to start from instead of the defaults. |
| `allowedSchemes` | `allowed-schemes` | `string[]` | `["drs", "https"]` | URI schemes that file references and links in descriptions may have; the attribute takes them separated by spaces or commas, in any case. Changing it checks the values again (defaults refused at load stay out). |
| `inputValues` | | `object` | | The current values (read only, a copy). |

## Methods

| Method | Description |
|--------|-------------|
| `reportValidity()` | Shows the errors of all inputs and returns whether the values are valid. |

## Events

| Event | Detail | Description |
|-------|--------|-------------|
| `ecc-io-form-changed` | `{ values, valid, errors }` | When the schema is loaded and whenever a value changes. `errors` holds `{ pointer, message }`, with JSON Pointers into `values`. |

## CSS Parts

| Part | Description |
|------|-------------|
| `base` | The form. |
58 changes: 58 additions & 0 deletions apps/documentation/pages/docs/wes/io-schema.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Callout } from 'nextra/components'

# I/O Schemas

The WES components understand the [GA4GH IO Schema Profile](https://github.com/elixir-cloud-aai/ga4gh-io-schema) ([docs](https://ga4gh-io-schema.readthedocs.io/en/latest/)): JSON Schema 2020-12 with `x-ga4gh-*` keywords that describe the inputs and outputs of a workflow, for example to render input forms and to show outputs.

## Profile version

The package supports version **0.3.0** of the profile, pinned at commit [`2c3dc49`](https://github.com/elixir-cloud-aai/ga4gh-io-schema/tree/2c3dc49ad89f0a556272f160369a2a2d7a21dac3). Its meta-schema and vocabularies are bundled with the package; `scripts/sync-io-schema.mjs` in the package copies them, the conformance suite and the example schemas from a checkout of the profile's repository at the pinned commit.

## Checks

Before [`ecc-client-ga4gh-wes-io-form`](./components/io-form) uses an IO schema, it checks it **offline**, as the profile asks:

1. `$schema` must name the profile's meta-schema.
2. The schema must pass the meta-schema, with formats asserted.
3. Every `$ref` in `inputs`, `outputs`, the top-level `$defs` and annotation schemas (`contentSchema`, `x-ga4gh-tabular-schema`) must resolve within the schema or to the JSON Schema meta-schemas. Nothing is fetched over the network: a schema that refers to a remote schema is rejected. Embedded resources may not reuse the `$id` of a schema in use (such as the profile's meta-schema). Names with `#` work everywhere except inside an embedded `$id` resource, where hyperjump can't address them.

Input values are then validated against the schema's `inputs` with the semantics of JSON Schema 2020-12. Failures are reported with the JSON Pointer of the value, the keyword that failed and a message.

The checks pass the profile's conformance suite (every valid case is accepted, every invalid one rejected) and accept the profile's example schemas.

## Validator and Content Security Policy

The checks use [@hyperjump/json-schema](https://github.com/hyperjump-io/json-schema), which doesn't compile schemas into code, so pages that embed the components need **no `'unsafe-eval'`** in their Content Security Policy.

<Callout type="info">
hyperjump's settings are global to the page: the package turns off its retrieval of schemas over HTTP(S) and turns on format assertion. Pages that use hyperjump themselves get these settings, too.
</Callout>

The validator sits behind a small interface (`IoSchemaValidator`), so that another library could replace it without changing the components. Apps can use the checks themselves and replace the validator through `@elixir-cloud/wes/utils`:

```typescript
import { checkIoSchema, setIoSchemaValidator } from '@elixir-cloud/wes/utils';

const result = await checkIoSchema(schema);
if (result.valid) {
const { valid, errors } = result.validateInputs(values);
}
```

Checks run one after the other, because hyperjump's registry of schemas is global.

## File references

JSON Schema can't check the values of file references (`x-ga4gh-file`), so the components check them by the profile's rules (see [Values](https://ga4gh-io-schema.readthedocs.io/en/latest/specification/files/#values)) before a value is used:

- A URI must have a scheme on the deployment's allow-list (`allowedSchemes` of the components, default `drs https`), narrowed by the file reference's own `schemes`, which never extend it. `javascript`, `data`, `file` and other schemes that run code or refer to local data are always refused.
- Inputs may also be relative paths (files attached to the run request), but only where the file reference has no `schemes`: no `..` segments (also not percent-encoded), no leading `~`, `//` or `\\`, and no absolute paths.
- Control characters and leading or trailing whitespace are refused, as they could hide a scheme.

Outputs must be absolute URIs. The checks pass the profile's test vectors for file reference values (`tests/vectors/file-values`).

## Descriptions

Titles, descriptions and `enum` values of IO schemas are always shown as text, never as markup.

Descriptions with `"x-ga4gh-description-format": "markdown"` are shown as plain text, which the profile allows. The package also has a renderer for the profile's Markdown subset (raw HTML shown as escaped text, images as their alt text, links only with a scheme from `allowedSchemes`, which open in a new window; of GFM only tables, strikethrough and autolinks), built on [markdown-it](https://github.com/markdown-it/markdown-it). It is switched off until the maintainers decide whether the components render Markdown; an app can switch it on for all components with `setDescriptionFormat('markdown')` from `@elixir-cloud/wes/utils`, before the components render: components already on the page keep the old format until they render again. markdown-it is part of the package's bundle either way.
Loading
Loading