8000 Add generated code for cwl-v1.2.1_proposed by ZimmerA · Pull Request #2 · common-workflow-lab/cwl-ts-auto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add generated code for cwl-v1.2.1_proposed #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Continuous integration tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: 17.x

jobs:

CI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- run: node --version
- run: npm install
- run: npm test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2.1.0
with:
fail_ci_if_error: true
flags: unittests
106 changes: 106 additions & 0 deletions .gitignore
10000
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

built/
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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
To install the latest version of cwl-ts-auto execute:

`npm install 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/)
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "cwl-ts-auto",
"version": "0.1.0",
"description": "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.",
"author": "Adrian Zimmer",
"homepage" : "https://www.commonwl.org/",
"license": "Apache License, Version 2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/common-workflow-lab/cwl-ts-auto"
},
"bugs": {
"url": "https://github.com/common-workflow-lab/cwl-ts-auto/issues"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf ./dist && tsc",
"test": "nyc --reporter=lcov mocha --require ts-node/register src/test/**/*.ts"
},
"devDependencies": {
"@types/chai": "^4.2.22",
"@types/chai-as-promised": "^7.1.4",
"@types/js-yaml": "^4.0.4",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.6",
"@types/node-fetch": "^2.5.12",
"@types/sinon": "^10.0.6",
"@types/uuid": "^8.3.3",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"mocha": "^9.1.3",
"nyc": "^15.1.0",
"sinon": "^12.0.1",
"ts-node": "^10.4.0",
"typescript": "^4.4.4",
"codecov.io": "^0.1.6"
},
"dependencies": {
"js-yaml": "^4.1.0",
"node-fetch": "^2.6.6",
"uri-js": "^4.4.1",
"uuid": "^8.3.2"
},
"files": [
"/dist"
]
}
4 changes: 4 additions & 0 deletions src/Any.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export enum Any {
ANY='Any',
}
142 changes: 142 additions & 0 deletions src/ArraySchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@

import {
Dictionary,
expandUrl,
loadField,
LoaderInstances,
LoadingOptions,
Saveable,
ValidationException,
prefixUrl,
save,
saveRelativeUri
} from './util/Internal'
import { v4 as uuidv4 } from 'uuid'
import * as Internal from './util/Internal'


/**
* Auto-generated class implementation for https://w3id.org/cwl/salad#ArraySchema
*/
export class ArraySchema extends Saveable implements Internal.ArraySchemaProperties {
extensionFields?: Internal.Dictionary<any>

/**
* Defines the type of the array elements.
*/
items: Internal.PrimitiveType | Internal.RecordSchema | Internal.EnumSchema | Internal.ArraySchema | string | Array<Internal.PrimitiveType | Internal.RecordSchema | Internal.EnumSchema | Internal.ArraySchema | string>

/**
* Must be `array`
*/
type: Internal.enum_d062602be0b4b8fd33e69e29a841317b6ab665bc


constructor ({loadingOptions, extensionFields, items, type} : {loadingOptions?: LoadingOptions} & Internal.ArraySchemaProperties) {
super(loadingOptions)
this.extensionFields = extensionFields ?? {}
this.items = items
this.type = type
}

/**
* Used to construct instances of {@link ArraySchema }.
*
* @param __doc Document fragment to load this record object from.
* @param baseuri Base URI to generate child document IDs against.
* @param loadingOptions Context for loading URIs and populating objects.
* @param docRoot ID at this position in the document (if available)
* @returns An instance of {@link ArraySchema }
* @throws {@link ValidationException} If the document fragment is not a
* {@link Dictionary} or validation of fields fails.
*/
static override async fromDoc (__doc: any, baseuri: string, loadingOptions: LoadingOptions,
docRoot?: string): Promise<Saveable> {
const _doc = Object.assign({}, __doc)
const __errors: ValidationException[] = []

let items
try {
items = await loadField(_doc.items, LoaderInstances.typedslunionOfPrimitiveTypeLoaderOrRecordSchemaLoaderOrEnumSchemaLoaderOrArraySchemaLoaderOrstrtypeOrarrayOfunionOfPrimitiveTypeLoaderOrRecordSchemaLoaderOrEnumSchemaLoaderOrArraySchemaLoaderOrstrtype2,
baseuri, loadingOptions)
} catch (e) {
if (e instanceof ValidationException) {
__errors.push(
new ValidationException('the `items` field is not valid because: ', [e])
)
} else {
throw e
}
}

let type
try {
type = await loadField(_doc.type, LoaderInstances.typedslenum_d062602be0b4b8fd33e69e29a841317b6ab665bcLoader2,
baseuri, loadingOptions)
} catch (e) {
if (e instanceof ValidationException) {
__errors.push(
new ValidationException('the `type` field is not valid because: ', [e])
)
} else {
throw e
}
}

const extensionFields: Dictionary<any> = {}
for (const [key, value] of Object.entries(_doc)) {
if (!ArraySchema.attr.has(key)) {
if ((key as string).includes(':')) {
const ex = expandUrl(key, '', loadingOptions, false, false)
extensionFields[ex] = value
} else {
__errors.push(
new ValidationException(`invalid field ${key as string}, \
expected one of: \`items\`,\`type\``)
)
break
}
}
}

if (__errors.length > 0) {
throw new ValidationException("Trying 'ArraySchema'", __errors)
}

const schema = new ArraySchema({
extensionFields: extensionFields,
loadingOptions: loadingOptions,
items: items,
type: type
})
return schema
}

save (top: boolean = false, baseUrl: string = '', relativeUris: boolean = true)
: Dictionary<any> {
const r: Dictionary<any> = {}
for (const ef in this.extensionFields) {
r[prefixUrl(ef, this.loadingOptions.vocab)] = this.extensionFields.ef
}

if (this.items != null) {
r.items = save(this.items, false, baseUrl, relativeUris)
}

if (this.type != null) {
r.type = save(this.type, false, baseUrl, relativeUris)
}

if (top) {
if (this.loadingOptions.namespaces != null) {
r.$namespaces = this.loadingOptions.namespaces
}
if (this.loadingOptions.schemas != null) {
r.$schemas = this.loadingOptions.schemas
}
}
return r
}

static attr: Set<string> = new Set(['items','type'])
}
21 changes: 21 additions & 0 deletions src/ArraySchemaProperties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import * as Internal from './util/Internal'


/**
* Auto-generated interface for https://w3id.org/cwl/salad#ArraySchema
*/
export interface ArraySchemaProperties {

extensionFields?: Internal.Dictionary<any>

/**
* Defines the type of the array elements.
*/
items: Internal.PrimitiveType | Internal.RecordSchema | Internal.EnumSchema | Internal.ArraySchema | string | Array<Internal.PrimitiveType | Internal.RecordSchema | Internal.EnumSchema | Internal.ArraySchema | string>

/**
* Must be `array`
*/
type: Internal.enum_d062602be0b4b8fd33e69e29a841317b6ab665bc
}
5 changes: 5 additions & 0 deletions src/CWLType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

export enum CWLType {
FILE='File',
DIRECTORY='Directory',
}
Loading
0