New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cwlts

Package Overview
Dependencies
Maintainers
1
Versions
291
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cwlts - npm Package Compare versions

Comparing version 1.8.1 to 1.8.2

models/d2sb/ParameterTypeModel.d.ts

5

models/d2sb/CommandArgumentModel.d.ts
import { CommandLineBinding } from "../../mappings/d2sb/CommandLineBinding";
import { CommandLinePart } from "../helpers/CommandLinePart";
import { CommandLineInjectable } from "../interfaces/CommandLineInjectable";
export declare class CommandArgumentModel implements CommandLineInjectable {
import { ValidationBase } from "../helpers/validation/ValidationBase";
export declare class CommandArgumentModel extends ValidationBase implements CommandLineInjectable {
part: CommandLinePart;
arg: string | CommandLineBinding;
constructor(arg: string | CommandLineBinding);
constructor(loc: string, arg: string | CommandLineBinding);
getCommandPart(job?: any, value?: any): CommandLinePart;
evaluateArg(arg: CommandLineBinding, job: any): CommandLinePart;
}

9

models/d2sb/CommandArgumentModel.js
"use strict";
var CommandLinePart_1 = require("../helpers/CommandLinePart");
var ExpressionEvaluator_1 = require("../helpers/ExpressionEvaluator");
var CommandArgumentModel = (function () {
function CommandArgumentModel(arg) {
var ValidationBase_1 = require("../helpers/validation/ValidationBase");
var CommandArgumentModel = (function (_super) {
__extends(CommandArgumentModel, _super);
function CommandArgumentModel(loc, arg) {
_super.call(this, loc);
this.arg = arg;

@@ -36,3 +39,3 @@ }

return CommandArgumentModel;
}());
}(ValidationBase_1.ValidationBase));
exports.CommandArgumentModel = CommandArgumentModel;

@@ -6,2 +6,3 @@ import { CommandInputParameter } from "../../mappings/d2sb/CommandInputParameter";

import { MapType, EnumType, ArrayType, RecordType } from "../../mappings/d2sb/CommandInputSchema";
import { PrimitiveType } from "../helpers/TypeResolver";
import { CommandInputRecordField } from "../../mappings/d2sb/CommandInputRecordField";

@@ -29,5 +30,5 @@ import { Expression } from "../../mappings/d2sb/Expression";

*/
type: string;
type: PrimitiveType;
/** Primitive type of items, if input is an array */
items: string;
items: PrimitiveType;
/** InputBinding defined for items inside of {type: "array"} object */

@@ -42,3 +43,3 @@ private itemsBinding;

/** name property in type object, only applicable for "enum" and "record" */
private typeName;
private name;
job: any;

@@ -62,3 +63,2 @@ self: any;

setDescription(description: string): void;
toString(format?: string): void;
setValueFrom(value: string | Expression): void;

@@ -65,0 +65,0 @@ getValueFrom(): ExpressionModel;

@@ -32,3 +32,3 @@ "use strict";

/** name property in type object, only applicable for "enum" and "record" */
this.typeName = null;
this.name = null;
if (input) {

@@ -67,3 +67,3 @@ this.deserialize(input);

this.itemsBinding = resolved.itemsBinding;
this.typeName = resolved.typeName;
this.name = resolved.name;
};

@@ -245,10 +245,2 @@ CommandInputParameterModel.prototype.getCommandPart = function (job, value, self) {

};
//@todo(maya) implement serialization
CommandInputParameterModel.prototype.toString = function (format) {
if (format === void 0) { format = 'json'; }
if (format === 'json') {
}
else if (format === 'yaml') {
}
};
CommandInputParameterModel.prototype.setValueFrom = function (value) {

@@ -334,3 +326,3 @@ var _this = this;

}
if (!this.typeName) {
if (!this.name) {
val.errors.push({

@@ -364,3 +356,3 @@ message: "Type enum must have a name",

}
if (!this.typeName) {
if (!this.name) {
val.errors.push({

@@ -367,0 +359,0 @@ message: "Type record must have a name",

@@ -28,7 +28,7 @@ import { CommandArgumentModel } from "./CommandArgumentModel";

addBaseCommand(cmd?: ExpressionModel): ExpressionModel;
addArgument(arg: CommandArgumentModel): void;
addArgument(argument: CommandArgumentModel): CommandArgumentModel;
removeArgument(arg: CommandArgumentModel | number): void;
addInput(input?: CommandInputParameterModel): CommandInputParameterModel;
removeInput(input: CommandInputParameterModel | number): void;
addOutput(output: CommandOutputParameterModel): void;
addOutput(output: CommandOutputParameterModel): CommandOutputParameterModel;
removeOutput(output: CommandOutputParameterModel | number): void;

@@ -42,3 +42,2 @@ getCommandLine(): string;

deserialize(attr: CommandLineTool): void;
setValidationCallback(fn: (any) => void): void;
}

@@ -16,2 +16,4 @@ "use strict";

this.outputs = [];
this.baseCommand = [];
this.arguments = [];
this.customProps = {};

@@ -36,4 +38,11 @@ this.class = "CommandLineTool";

};
CommandLineToolModel.prototype.addArgument = function (arg) {
this.arguments.push(arg);
CommandLineToolModel.prototype.addArgument = function (argument) {
var _this = this;
argument = argument || new CommandInputParameterModel_1.CommandInputParameterModel('');
argument.loc = this.loc + ".arguments[" + this.arguments.length + "]";
this.arguments.push(argument);
argument.setValidationCallback(function (err) {
_this.updateValidity(err);
});
return argument;
};

@@ -68,3 +77,10 @@ CommandLineToolModel.prototype.removeArgument = function (arg) {

CommandLineToolModel.prototype.addOutput = function (output) {
var _this = this;
output = output || new CommandInputParameterModel_1.CommandInputParameterModel('');
output.loc = this.loc + ".outputs[" + this.outputs.length + "]";
this.outputs.push(output);
output.setValidationCallback(function (err) {
_this.updateValidity(err);
});
return output;
};

@@ -151,6 +167,10 @@ CommandLineToolModel.prototype.removeOutput = function (output) {

});
this.outputs = attr.outputs.map(function (output) { return new CommandOutputParameterModel_1.CommandOutputParameterModel(output); });
this.arguments = attr.arguments
? attr.arguments.map(function (arg) { return new CommandArgumentModel_1.CommandArgumentModel(arg); })
: [];
attr.inputs.forEach(function (output, index) {
_this.addOutput(new CommandOutputParameterModel_1.CommandOutputParameterModel(_this.loc + ".outputs[" + index + "]", output));
});
if (attr.arguments) {
attr.arguments.forEach(function (arg, index) {
_this.addArgument(new CommandArgumentModel_1.CommandArgumentModel(_this.loc + ".arguments[" + index + "]", arg));
});
}
this.stdin = attr.stdin || '';

@@ -180,6 +200,4 @@ this.stdout = attr.stdout || '';

};
CommandLineToolModel.prototype.setValidationCallback = function (fn) {
};
return CommandLineToolModel;
}(validation_1.ValidationBase));
exports.CommandLineToolModel = CommandLineToolModel;

@@ -65,3 +65,3 @@ "use strict";

//noinspection TypeScriptUnresolvedVariable
var tool = new CommandLineToolModel_1.CommandLineToolModel(BWAMemTool.default);
var tool = new CommandLineToolModel_1.CommandLineToolModel("", BWAMemTool.default);
//noinspection TypeScriptUnresolvedVariable

@@ -73,3 +73,3 @@ tool.setJob(BWAMemJob.default);

//noinspection TypeScriptUnresolvedVariable
var tool = new CommandLineToolModel_1.CommandLineToolModel(BindingTestTool.default);
var tool = new CommandLineToolModel_1.CommandLineToolModel("", BindingTestTool.default);
//noinspection TypeScriptUnresolvedVariable

@@ -167,3 +167,3 @@ tool.setJob(BWAMemJob.default);

chai_1.expect(tool.validation.errors).to.not.be.empty;
chai_1.expect(tool.validation.errors[0].loc).to.equal("baseCommand[0]");
chai_1.expect(tool.validation.errors[0].loc).to.equal("document.baseCommand[0]");
chai_1.expect(tool.validation.errors[0].message).to.contain("SyntaxError");

@@ -179,5 +179,5 @@ var expr2 = new ExpressionModel_1.ExpressionModel("", {

chai_1.expect(tool.validation.warnings).to.not.be.empty;
chai_1.expect(tool.validation.warnings[0].loc).to.equal("baseCommand[1]", "location of warning");
chai_1.expect(tool.validation.warnings[0].loc).to.equal("document.baseCommand[1]", "location of warning");
chai_1.expect(tool.validation.warnings[0].message).to.contain("ReferenceError", "value of warning");
chai_1.expect(tool.validation.errors[0].loc).to.equal("baseCommand[0]", "location of error after setting warning");
chai_1.expect(tool.validation.errors[0].loc).to.equal("document.baseCommand[0]", "location of error after setting warning");
chai_1.expect(tool.validation.errors[0].message).to.contain("SyntaxError", "value of error after setting warning");

@@ -184,0 +184,0 @@ });

import { CommandOutputParameter } from "../../mappings/d2sb/CommandOutputParameter";
import { Datatype } from "../../mappings/d2sb/Datatype";
import { CommandOutputSchema } from "../../mappings/d2sb/CommandOutputSchema";
import { CommandOutputBinding } from "../../mappings/d2sb/CommandOutputBinding";
export declare class CommandOutputParameterModel implements CommandOutputParameter {
import { Serializable } from "../interfaces/Serializable";
import { TypeResolution, PrimitiveType } from "../helpers/TypeResolver";
import { ValidationBase } from "../helpers/validation";
import { CommandOutputRecordField } from "../../mappings/v1.0/CommandOutputRecordField";
export declare class CommandOutputParameterModel extends ValidationBase implements Serializable<CommandOutputParameter> {
id: string;
type: Datatype | CommandOutputSchema | string | Array<Datatype | CommandOutputSchema | string>;
_type: TypeResolution;
outputBinding: CommandOutputBinding;
label: string;
description: string;
constructor(attr: CommandOutputParameter);
isRequired: boolean;
type: PrimitiveType;
items: PrimitiveType;
readonly fields: Array<CommandOutputRecordField>;
constructor(loc: string, attr: CommandOutputParameter);
serialize(): CommandOutputParameter;
deserialize(attr: CommandOutputParameter): void;
}
"use strict";
var CommandOutputParameterModel = (function () {
function CommandOutputParameterModel(attr) {
var TypeResolver_1 = require("../helpers/TypeResolver");
var validation_1 = require("../helpers/validation");
var CommandOutputParameterModel = (function (_super) {
__extends(CommandOutputParameterModel, _super);
function CommandOutputParameterModel(loc, attr) {
_super.call(this, loc);
this.deserialize(attr);
}
Object.defineProperty(CommandOutputParameterModel.prototype, "isRequired", {
get: function () {
return this._type.isRequired;
},
set: function (r) {
this._type.isRequired = r;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CommandOutputParameterModel.prototype, "type", {
get: function () {
return this._type.type;
},
set: function (t) {
this._type.type = t;
//@todo add cases for enum, array and record for adding symbols, items and fields
},
enumerable: true,
configurable: true
});
Object.defineProperty(CommandOutputParameterModel.prototype, "items", {
get: function () {
return this._type.items;
},
set: function (t) {
this._type.type = "array";
this._type.items = t;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CommandOutputParameterModel.prototype, "fields", {
get: function () {
return this._type.fields;
},
enumerable: true,
configurable: true
});
CommandOutputParameterModel.prototype.serialize = function () {
var output = {};
output.id = this.id;
if (this.outputBinding)
output.outputBinding = this.outputBinding;
return output;
};
CommandOutputParameterModel.prototype.deserialize = function (attr) {
this.id = attr.id;
this.outputBinding = attr.outputBinding;
this.type = attr.type;
this._type = TypeResolver_1.TypeResolver.resolveType(attr.type);
this.label = attr.label;
this.description = attr.description;
}
};
return CommandOutputParameterModel;
}());
}(validation_1.ValidationBase));
exports.CommandOutputParameterModel = CommandOutputParameterModel;
import { CommandLineBinding } from "../../mappings/draft-4/CommandLineBinding";
import { CommandInputRecordField } from "../../mappings/d2sb/CommandInputRecordField";
import { CommandOutputRecordField } from "../../mappings/v1.0/CommandOutputRecordField";
import { CWLVersion } from "../../mappings/v1.0/CWLVersion";
export declare type PrimitiveType = "array" | "enum" | "record" | "File" | "string" | "int" | "float" | "null" | "boolean" | "long" | "double" | "bytes";
export interface TypeResolution {
type: string;
items: string;
fields: any[];
type: PrimitiveType;
items: PrimitiveType;
fields: Array<CommandInputRecordField> | Array<CommandOutputRecordField>;
symbols: string[];
isRequired: boolean;
itemsBinding: CommandLineBinding;
typeName: string;
name: string;
}
export declare class TypeResolver {
static resolveType(type: any, result?: TypeResolution): TypeResolution;
static doesTypeMatch(type: string, value: any): boolean;
static doesTypeMatch(type: PrimitiveType, value: any): boolean;
static serializeType(type: TypeResolution, version?: CWLVersion): any;
}

@@ -13,3 +13,3 @@ "use strict";

itemsBinding: null,
typeName: null
name: null
};

@@ -86,7 +86,7 @@ if (type === null || type === undefined) {

result.fields = type.fields;
result.typeName = type.name || null;
result.name = type.name || null;
return result;
case "enum":
result.symbols = type.symbols;
result.typeName = type.name || null;
result.name = type.name || null;
return result;

@@ -134,4 +134,49 @@ case "string":

};
TypeResolver.serializeType = function (type, version) {
var t;
switch (type.type) {
case "array":
if (version === "v1.0" && !type.itemsBinding) {
t = type.items + "[]";
}
else {
t = {
type: "array",
items: type.items
};
if (type.itemsBinding)
t.inputBinding = t;
}
break;
case "record":
t = {
type: "record",
fields: type.fields,
name: type.name
};
if (type.itemsBinding)
t.inputBinding = t;
break;
case "enum":
t = {
type: "enum",
symbols: type.symbols,
name: type.name
};
if (type.itemsBinding)
t.inputBinding = t;
break;
default:
t = type.type;
}
if (!type.isRequired) {
t = version === "v1.0" ? t + "?" : ["null", t];
}
else if (version !== "v1.0") {
t = [t];
}
return t;
};
return TypeResolver;
}());
exports.TypeResolver = TypeResolver;

@@ -195,2 +195,111 @@ "use strict";

});
describe("serializeType", function () {
it("should resolve a primitive type that is required", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType(["string"]);
var serialized = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serialized).to.deep.equal(["string"]);
});
it("should resolve a primitive type that is not required", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType(["null", "string"]);
var serialized = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serialized).to.deep.equal(["null", "string"]);
});
it("should resolve a complex array type that is required", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType({ type: "array", items: "File" });
var serialized = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serialized).to.deep.equal([{ type: "array", items: "File" }]);
});
it("should resolve a complex array type that is not required", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType(["null", { type: "array", items: "File" }]);
var serialized = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serialized).to.deep.equal(["null", { type: "array", items: "File" }]);
});
it("should resolve complex enum type that is required", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType({
type: "enum",
name: "enum",
symbols: ["one", "two"]
});
var serialized = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serialized).to.deep.equal([{
type: "enum",
name: "enum",
symbols: ["one", "two"]
}]);
});
it("should resolve complex enum type that is not required", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType(["null", {
type: "enum",
name: "enum",
symbols: ["one", "two"]
}]);
var serialized = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serialized).to.deep.equal(["null", {
type: "enum",
name: "enum",
symbols: ["one", "two"]
}]);
});
it("should resolve complex record type that is required", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType({
type: "record",
name: "rec",
fields: [
{ id: "f1", type: "string" },
{ id: "f2", type: "File" }
]
});
var serialized = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serialized).to.deep.equal([{
type: "record",
name: "rec",
fields: [
{ id: "f1", type: "string" },
{ id: "f2", type: "File" }
]
}]);
});
it("should resolve complex record type that is not required", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType(["null", {
type: "record",
name: "rec",
fields: [
{ id: "f1", type: "string" },
{ id: "f2", type: "File" }
]
}]);
var serialized = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serialized).to.deep.equal(["null", {
type: "record",
name: "rec",
fields: [
{ id: "f1", type: "string" },
{ id: "f2", type: "File" }
]
}]);
});
it("should resolve shorthand for array", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType("string[]");
var serializedV1 = TypeResolver_1.TypeResolver.serializeType(resolved, "v1.0");
var serializedD2 = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serializedV1).to.deep.equal("string[]");
chai_1.expect(serializedD2).to.deep.equal([{ type: "array", items: "string" }]);
});
it("should resolve shorthand for primitive that is not required", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType("string?");
var serializedV1 = TypeResolver_1.TypeResolver.serializeType(resolved, "v1.0");
var serializedD2 = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serializedV1).to.deep.equal("string?");
chai_1.expect(serializedD2).to.deep.equal(["null", "string"]);
});
it("should resolve shorthand for array that is not required", function () {
it("should resolve shorthand for array", function () {
var resolved = TypeResolver_1.TypeResolver.resolveType("string[]?");
var serializedV1 = TypeResolver_1.TypeResolver.serializeType(resolved, "v1.0");
var serializedD2 = TypeResolver_1.TypeResolver.serializeType(resolved);
chai_1.expect(serializedV1).to.deep.equal("string[]?");
chai_1.expect(serializedD2).to.deep.equal(["null", { type: "array", items: "string" }]);
});
});
});
});
export interface Serializable<T> {
serialize(): T;
deserialize(T: any): void;
deserialize(attr: T): void;
}
{
"name": "cwlts",
"version": "1.8.1",
"version": "1.8.2",
"description": "TypeScript data model for Common Workflow Language",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc