Skip to content

Commit d77bd4e

Browse files
authored
Merge pull request #71 from Exabyte-io/update/SOF-7161
SOF-7161: esse schema
2 parents 0d12189 + b29f510 commit d77bd4e

File tree

6 files changed

+1551
-1149
lines changed

6 files changed

+1551
-1149
lines changed

package-lock.json

+1,528-1,142
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"devDependencies": {
4949
"@exabyte-io/ade.js": "2024.1.23-1",
5050
"@exabyte-io/application-flavors.js": "2024.1.23-1",
51-
"@exabyte-io/code.js": "2024.1.18-0",
51+
"@exabyte-io/code.js": "2024.2.20-0",
52+
"@mat3ra/esse": "2024.2.19-1",
5253
"@exabyte-io/eslint-config": "^2022.11.17-0",
5354
"@exabyte-io/ide.js": "2022.7.28-1",
5455
"@exabyte-io/made.js": "2023.3.8-0",
@@ -75,7 +76,8 @@
7576
"@exabyte-io/ade.js": "*",
7677
"@exabyte-io/ide.js": "*",
7778
"@exabyte-io/mode.js": "*",
78-
"@exabyte-io/code.js": "*"
79+
"@exabyte-io/code.js": "*",
80+
"@mat3ra/esse": "*"
7981
},
8082
"engines": {
8183
"node": ">=12.0.0"

src/subworkflows/subworkflow.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export class Subworkflow extends BaseSubworkflow {
9090
_id: Cls.generateSubworkflowId(),
9191
name,
9292
application: application.toJSON(),
93-
properties: lodash.sortedUniq(lodash.flatten(units.map((x) => x.resultNames))),
93+
properties: lodash.sortedUniq(
94+
lodash.flatten(units.filter((x) => x.resultNames).map((x) => x.resultNames)),
95+
),
9496
model: {
9597
...model.toJSON(),
9698
method: method.toJSON(),
@@ -149,7 +151,7 @@ export class Subworkflow extends BaseSubworkflow {
149151
...super.toJSON(exclude),
150152
model: this.model.toJSON(),
151153
units: this.units.map((x) => x.toJSON()),
152-
compute: this.compute,
154+
...(this.compute ? { compute: this.compute } : {}), // {"compute": null } won't pass esse validation
153155
};
154156
}
155157

src/workflows/workflow.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NamedDefaultableRepetitionContextAndRenderInMemoryEntity } from "@exaby
33
import { calculateHashFromObject, getUUID } from "@exabyte-io/code.js/dist/utils";
44
import { ComputedEntityMixin, getDefaultComputeConfig } from "@exabyte-io/ide.js";
55
import { tree } from "@exabyte-io/mode.js";
6+
import workflowSchema from "@mat3ra/esse/lib/js/schema/workflow.json";
67
import lodash from "lodash";
78
import { mix } from "mixwith";
89
import _ from "underscore";
@@ -27,6 +28,8 @@ class BaseWorkflow extends mix(NamedDefaultableRepetitionContextAndRenderInMemor
2728
export class Workflow extends BaseWorkflow {
2829
static getDefaultComputeConfig = getDefaultComputeConfig;
2930

31+
static jsonSchema = workflowSchema;
32+
3033
constructor(config) {
3134
super(config);
3235
this._Subworkflow = Subworkflow;
@@ -152,7 +155,7 @@ export class Workflow extends BaseWorkflow {
152155
units: this._units.map((x) => x.toJSON()),
153156
subworkflows: this._subworkflows.map((x) => x.toJSON()),
154157
workflows: this.workflows.map((x) => x.toJSON()),
155-
compute: this.compute,
158+
...(this.compute ? { compute: this.compute } : {}), // {"compute": null } won't pass esse validation
156159
},
157160
exclude,
158161
);

tests/patchUnit.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("assignement unit", () => {
1313
index: 0,
1414
type: "assignment",
1515
config: {
16-
attributes: { operand: "someOtherOperand", value: 42 },
16+
attributes: { operand: "someOtherOperand", value: "42" },
1717
},
1818
},
1919
];

tests/workflow.test.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
22

3-
import { createWorkflows } from "../src/workflows";
3+
import { createWorkflows, Workflow } from "../src/workflows";
44
import { createWorkflow } from "../src/workflows/create";
55
import { workflowData as allWorkflowData } from "../src/workflows/workflows";
66

@@ -10,6 +10,15 @@ describe("workflows", () => {
1010
workflows.map((wf) => {
1111
// eslint-disable-next-line no-unused-expressions
1212
expect(wf).to.exist;
13+
// eslint-disable-next-line no-unused-expressions
14+
expect(wf.isValid()).to.be.true;
15+
16+
const wfCopy = new Workflow(wf.toJSON());
17+
18+
// eslint-disable-next-line no-unused-expressions
19+
expect(wfCopy.isValid()).to.be.true;
20+
21+
// expect(wf.validate()).to.be.true;
1322
return null;
1423
});
1524
});

0 commit comments

Comments
 (0)