This project contains TypeScript objects and utilities auto-generated by https://github.com/common-workflow-language/schema_salad for parsing documents corresponding to the https://w3id.org/cwl/cwl schema
To install the latest version of cwl-ts-auto execute:
npm install cwl-ts-auto
Documents can be loaded by specyfying a file path or by string
import * as cwlTsAuto from 'cwl-ts-auto'
import fs from 'fs'
import url from 'url'
// Load document by file
cwlTsAuto.loadDocument('./test.cwl')
.then((file) => {
if (file instanceof cwlTsAuto.CommandLineTool) {
console.log('This document is a CommandLineTool with baseCommand: ', file.baseCommand)
}
})
.catch((e) => {
if(e instanceof cwlTsAuto.ValidationException) {
console.log(e.toString())
} else {
console.log(e)
}
})
// Load document by string
let docAsString = fs.readFileSync('./test.cwl').toString()
cwlTsAuto.loadDocumentByString(docAsString, url.pathToFileURL('/your/base/uri/').toString())
.then((file) => {
if (file instanceof cwlTsAuto.CommandLineTool) {
console.log('This document is a CommandLineTool with baseCommand: ', file.baseCommand)
}
})
.catch((e) => {
if(e instanceof cwlTsAuto.ValidationException) {
console.log(e.toString())
} else {
console.log(e)
}
})
// Load document by URL
cwlTsAuto.loadDocument('https://raw.githubusercontent.com/common-workflow-lab/cwl-ts-auto/main/src/test/data/examples/valid-cat-tool.cwl')
.then((file) => {
if (file instanceof cwlTsAuto.CommandLineTool) {
console.log('This document is a CommandLineTool with baseCommand: ', file.baseCommand)
}
})
.catch((e) => {
if(e instanceof cwlTsAuto.ValidationException) {
console.log(e.toString())
} else {
console.log(e)
}
})
This example shows how to create a simple CommandLineTool with one input
import * as cwlTsAuto from 'cwl-ts-auto'
let exampleCommandLineTool =
new cwlTsAuto.CommandLineTool({
class_: cwlTsAuto.CommandLineTool_class.COMMANDLINETOOL,
inputs: [],
outputs: []
})
exampleCommandLineTool.baseCommand = 'echo'
let exampleInput =
new cwlTsAuto.CommandInputParameter({
type: cwlTsAuto.PrimitiveType.STRING
})
exampleInput.default_ = 'Hello World!'
exampleCommandLineTool.inputs.push(exampleInput)
console.log(JSON.stringify(exampleCommandLineTool.save()))
The complete documentation, autogenerated by TypeDoc can be found under the following link: https://common-workflow-lab.github.io/cwl-ts-auto/
cwl-ts-auto only supports the CWL v1.2 syntax. Other documents have to be upgraded using the cwl-upgrader
Generated using TypeDoc