Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.modal.delete("Base Command").then(() => {
// Reset the expression's validity
// @TODO: if this is an ExpressionModel, model won't revalidate when an entry is removed
const entryAtIndex = this.formControl.at(index).value;
if (entryAtIndex instanceof ExpressionModel) {
entryAtIndex.clearIssue(ErrorCode.EXPR_ALL);
}
this.formControl.removeAt(index);
this.cdr.markForCheck();
}, err => {
console.warn(err);
this.modal.delete("secondary file").then(() => {
// Reset the expression's validity
const entryAtIndex = this.formControl.at(index).value;
if (entryAtIndex) {
entryAtIndex.clearIssue(ErrorCode.EXPR_ALL);
}
this.formControl.removeAt(index);
this.cdr.markForCheck();
}, err => {
console.warn(err);
this.modal.delete("base command").then(() => {
// reset the expression's validity
this.baseCommand[i].clearIssue(ErrorCode.EXPR_ALL);
(this.form.get("list") as FormArray).removeAt(i);
}, err => {
console.warn(err);
// import "./assets/styles/theme";
// import "./plugins/port-drag/theme.scss";
// import "./plugins/selection/theme.scss";
import {WorkflowFactory} from "cwlts/models";
import {Workflow} from "./graph/workflow";
import {SVGArrangePlugin} from "./plugins/arrange/arrange";
import {SVGNodeMovePlugin} from "./plugins/node-move/node-move";
import {SVGPortDragPlugin} from "./plugins/port-drag/port-drag";
import {SelectionPlugin} from "./plugins/selection/selection";
import {SVGEdgeHoverPlugin} from "./plugins/edge-hover/edge-hover";
import {ZoomPlugin} from "./plugins/zoom/zoom";
const sample = require(__dirname + "/../cwl-samples/rna-seq-alignment.json");
const wf = WorkflowFactory.from(sample);
const svgRoot = document.getElementById("svg") as any;
const workflow = new Workflow({
model: wf,
svgRoot: svgRoot,
plugins: [
new SVGArrangePlugin(),
new SVGEdgeHoverPlugin(),
new SVGNodeMovePlugin({
movementSpeed: 10
}),
new SVGPortDragPlugin(),
new SelectionPlugin(),
new ZoomPlugin(),
]
).subscribeTracked(this, () => {
this.modelChangedFromHistory = WorkflowFactory.from(this.workflowEditorService.historyRedo(this.model));
// Resets the reference of inspected node (reference is lost after model serialization)
this.resetInspectedNodeReference();
this.modelChange.next(this.modelChangedFromHistory);
});
).subscribeTracked(this, () => {
this.modelChangedFromHistory = WorkflowFactory.from(this.workflowEditorService.historyUndo(this.model));
// Resets the reference of inspected node (reference is lost after model serialization)
this.resetInspectedNodeReference();
this.modelChange.next(this.modelChangedFromHistory);
});
switchTab(tabName): void {
super.switchTab(tabName);
if (this.jobSubscription) {
this.jobSubscription.unsubscribe();
this.jobSubscription = null;
}
if (!this.dataModel) return;
if (tabName === "test") {
// create the workflow model that will be displayed on the test tab
this.workflowWrapper = WorkflowFactory.from({cwlVersion: this.dataModel.cwlVersion} as any);
// add this tool as its only step
const step = this.workflowWrapper.addStepFromProcess(this.dataModel.serialize());
/**
* Adding a step sometimes generates a different id for that step than that of an app that it was made from.
* On graph job representation, step progress plugin knows about tool id, and will try to update execution state on it.
* If this representation has a different id, they will not match and step will not be found on the SVG.
* This is a place to fix that since this workflow is not a source of truth for the data, but just a utility
* to help us render a graph, so just patch the ID to ensure that it's exactly what we expect to find.
*
* However, ID is not required by CWL, so this applies only if dataModel has one.
*/
if (this.dataModel.id) {
this.workflowWrapper.changeStepId(step, this.dataModel.id);
}
// iterate through all inputs of the tool
this.iFrame = document.createElement("iframe");
const perm = ["allow-same-origin", "allow-scripts"];
this.iFrame.style.display = "none";
this.iFrame.sandbox = perm.join(" ");
this.iFrame.onload = () => {
this.iFrame.contentWindow.document.open("text/html", "replace");
this.iFrame.contentWindow.document.write(this.iframeContent());
this.iFrame.contentWindow.document.close();
};
document.body.appendChild(this.iFrame);
// FIXME We have to improve this
ExpressionEvaluator.evaluateExpression = this.evaluateCode.bind(this);
}
this.workflowWrapper.steps[0].in.forEach((input: WorkflowStepInputModel) => {
if (isType(input, ["File", "Directory"])) {
// create inputs from file ports
this.workflowWrapper.createInputFromPort(input);
} else {
// everything else should be exposed (show up in the step inspector)
this.workflowWrapper.exposePort(input);
}
});
isValidatableCWL: boolean;
isValidCWL: boolean;
isValidJSON: boolean;
errors: Issue[];
warnings: Issue[];
class?: string | "CommandLineTool" | "Workflow" | "ExpressionTool";
}
@Injectable()
export class CwlSchemaValidationWorkerService {
private worker: WebWorker;
private draft4;
private cwlSchema = cwlSchemas.schemas.mixed;
constructor(private workerBuilder: WebWorkerBuilderService) {
this.worker = this.workerBuilder.create(this.workerFunction, [
"ajv.min.js",
"js-yaml.min.js"
], {
cwlSchema: this.cwlSchema,
// FIXME: will not work in browser, window.require call
draft4: {
"id": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Core schema meta-schema",
"definitions": {
"schemaArray": {