I/O Schemas
The WES components understand the GA4GH IO Schema Profile (opens in a new tab) (docs (opens in a new tab)): 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 (opens in a new tab). Its meta-schema and vocabularies are bundled with the package; scripts/sync-io-schema.mjs in the package copies them, the conformance suite, the test vectors and the example schemas from a checkout of the profile's repository at the pinned commit.
Checks
Before ecc-client-ga4gh-wes-io-form uses an IO schema, it checks it offline, as the profile asks:
$schemamust name the profile's meta-schema.- The schema must pass the meta-schema, with formats asserted.
- Every
$refininputs,outputs, the top-level$defsand 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$idof a schema in use (such as the profile's meta-schema). Names with#work everywhere except inside an embedded$idresource, 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 (opens in a new tab), which doesn't compile schemas into code, so pages that embed the components need no 'unsafe-eval' in their Content Security Policy.
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.
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:
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 (opens in a new tab)) before a value is used:
- A URI must have a scheme on the deployment's allow-list (
allowedSchemesof the components, defaultdrs https), narrowed by the file reference's ownschemes, which never extend it.javascript,data,fileand 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).
Run requests
@elixir-cloud/wes/utils builds WES run requests from input values by the profile's engine bindings (opens in a new tab), which ecc-client-ga4gh-wes-run-create uses in schema mode:
import {
buildRunRequest,
findPrimaryDescriptorPath,
trsDescriptorUrl,
} from '@elixir-cloud/wes/utils';
const request = await buildRunRequest(schema, values, {
workflowUrl: trsDescriptorUrl(trsUrl, toolId, versionId, 'NFL', findPrimaryDescriptorPath(files)),
binding: { descriptorTypeVersion: 'DSL2' }, // only if the schema has none
});toWorkflowParams()checks the schema, validates the values againstinputs, checks every file reference value, and translates the values for the descriptor type: unqualified names forNFLandSMK, names qualified with the entry point forWDL,FileandDirectoryobjects for CWL file values. Inputs are renamed byx-ga4gh-parameter; defaults of the schema are never inserted. Values that Nextflow or the CWL loader would change (${, keys with-for Nextflow;Fileobjects, keys with$or:for CWL) are refused. Errors areTranslationErrors with the JSON Pointer of the value.buildRunRequest()addsworkflow_type,workflow_type_versionandworkflow_url(for CWL, with the entry point as its fragment). Tags and engine parameters are left to the caller and to engine profiles.trsDescriptorUrl(),findPrimaryDescriptorPath()andfindSchemaFile()give the workflow URL of a TRS tool version and find its IO schema among its files.unsupportedBy()says whether a WES service runs a binding's type and version, by itsservice-info.
The translation passes the profile's test vectors (tests/vectors/wes-params, workflow-urls and trs-files). It needs a validator that can check subschemas (validateAt of the check result), and refuses schemas that it can't follow: references that don't resolve within the document, references and branches inside embedded $id resources, and $dynamicRef. GALAXY workflows have no binding in profile 0.3.0.
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 (opens in a new tab). 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.
