https://github.com/common-workflow-lab/cwl-ts-auto
Autogenerated TypeScript bindings for CWL
https://github.com/common-workflow-lab/cwl-ts-auto
Last synced: 4 months ago
JSON representation
Autogenerated TypeScript bindings for CWL
- Host: GitHub
- URL: https://github.com/common-workflow-lab/cwl-ts-auto
- Owner: common-workflow-lab
- License: apache-2.0
- Created: 2021-11-05T17:41:37.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-11-21T07:21:09.000Z (6 months ago)
- Last Synced: 2025-11-21T09:15:42.783Z (6 months ago)
- Language: TypeScript
- Homepage:
- Size: 903 KB
- Stars: 6
- Watchers: 10
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cwl-ts-auto

[](https://badge.fury.io/js/cwl-ts-auto)
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
## Installation & Usage
To install the latest version of cwl-ts-auto execute:
`npm install cwl-ts-auto`
### Loading Documents
Documents can be loaded by specyfying a file path or by string
```TypeScript
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)
}
})
```
### Creating, editing and saving Documents
This example shows how to create a simple CommandLineTool with one input
```TypeScript
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()))
```
## Documentation
The complete documentation, autogenerated by [TypeDoc](https://typedoc.org/) can be found under the following link:
https://common-workflow-lab.github.io/cwl-ts-auto/
## Limitations
cwl-ts-auto only supports the CWL v1.2 syntax. Other documents have to be upgraded using the [cwl-upgrader](https://pypi.org/project/cwl-upgrader/)
## Running and debugging tests
To run tests, install npm and run `npm test`, which launches mocha as defined
in `package.json`. Additional options to mocha can be passed afer `--`. To run
a single test run `run npm test -- --grep $my_test_id`. It is occasionally
helpful to pass `--allow-uncaught` to mocha to get a better handle on failing
test assertions. To debug a test using the chrome inspector insert a
breakpoint anywhere in code called by the test. Breakpoints are using the
`debugger;` instruction. Open chrome and navigate to `chrome://inspect`, then
run `npm test -- --grep valid_cond_wf_003_1_nojs --inspect --debug-brk`, switch
back to chrome and click inspect.