Skip to content

Commit c0c2bed

Browse files
committed
chore: update source files and configuration
1 parent 8c3f3e3 commit c0c2bed

File tree

117 files changed

+4354
-3183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+4354
-3183
lines changed

package-lock.json

Lines changed: 135 additions & 208 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"test": "nyc --reporter=text mocha --recursive --bail --require @babel/register/lib --require tests/js/setup.js tests/js",
77
"lint": "eslint src/js tests/js && prettier --write src/js tests/js",
88
"lint:fix": "eslint --fix --cache src/js tests/js && prettier --write src/js tests/js",
9-
"transpile": "babel --out-dir dist/js src/js",
9+
"transpile": "tsc --project tsconfig.json",
1010
"prettier": "prettier --check src/js tests/js",
11-
"prepare": "husky install || exit 0"
11+
"prepare": "husky install || exit 0",
12+
"generate-mixins": "ts-node scripts/generate-mixins.ts"
1213
},
1314
"repository": {
1415
"type": "git",
@@ -29,44 +30,47 @@
2930
"license": "Apache-2.0",
3031
"homepage": "https://github.com/Exabyte-io/wode",
3132
"dependencies": {
32-
"@babel/cli": "7.16.0",
33-
"@babel/core": "7.16.0",
34-
"@babel/eslint-parser": "7.16.3",
35-
"@babel/plugin-proposal-class-properties": "7.16.0",
36-
"@babel/preset-env": "7.16.4",
37-
"@babel/preset-react": "7.16.7",
38-
"@babel/register": "^7.16.0",
39-
"@babel/runtime-corejs3": "7.16.8",
4033
"@exabyte-io/periodic-table.js": "2022.6.8-0",
34+
"@types/json-schema": "^7.0.15",
35+
"@types/nunjucks": "^3.2.6",
36+
"@types/react-jsonschema-form": "^1.7.13",
4137
"crypto-js": "^4.2.0",
4238
"js-yaml": "^4.1.0",
4339
"lodash": "^4.17.21",
4440
"mixwith": "^0.1.1",
41+
"nunjucks": "^3.2.4",
42+
"ts-node": "^10.9.2",
43+
"typescript": "^5.6.6",
4544
"underscore": "^1.13.3",
4645
"underscore.string": "^3.3.4",
4746
"v20": "^0.1.0"
4847
},
4948
"devDependencies": {
50-
"@mat3ra/ade": "2025.11.26-0",
5149
"@exabyte-io/eslint-config": "2025.5.13-0",
50+
"@mat3ra/ade": "git+https://github.com/Exabyte-io/ade#6d494337d83e1b22fe272ff74cc1b6842a7c6561",
51+
"@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#cb3fa59e2cc143d744f9019322208d928ff8de88",
52+
"@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#3a7eab6a28db4a85711795e84ace3c74f7681577",
5253
"@mat3ra/ide": "2025.11.19-0",
54+
"@mat3ra/made": "git+https://github.com/Exabyte-io/made.git#47b3e12a859c45fa72079ed4ddd1675a6a32b4fe",
5355
"@mat3ra/mode": "2025.11.13-0",
54-
"@mat3ra/utils": "2025.9.20-0",
55-
"@mat3ra/code": "2025.10.24-0",
56-
"@mat3ra/esse": "2025.11.26-0",
57-
"@mat3ra/made": "2025.7.15-0",
5856
"@mat3ra/standata": "git+https://github.com/Exabyte-io/standata.git#3c5b6365a6a5fcfbbd4e5da3a30cd5dd4c0301ee",
57+
"@mat3ra/tsconfig": "2024.6.3-0",
58+
"@mat3ra/utils": "2025.9.20-0",
59+
"@types/crypto-js": "^4.2.2",
5960
"chai": "^4.3.4",
60-
"eslint": "7.32.0",
61-
"eslint-config-airbnb": "19.0.2",
61+
"eslint": "^7.32.0",
62+
"eslint-config-airbnb": "^19.0.2",
6263
"eslint-config-prettier": "^8.5.0",
63-
"eslint-import-resolver-exports": "^1.0.0-beta.2",
64-
"eslint-plugin-import": "2.25.3",
65-
"eslint-plugin-jsdoc": "37.1.0",
66-
"eslint-plugin-jsx-a11y": "6.5.1",
64+
"eslint-import-resolver-exports": "^1.0.0-beta.5",
65+
"eslint-import-resolver-meteor": "^0.4.0",
66+
"eslint-import-resolver-node": "^0.3.9",
67+
"eslint-plugin-import": "^2.25.3",
68+
"eslint-plugin-jsdoc": "^37.1.0",
69+
"eslint-plugin-jsx-a11y": "^6.5.1",
70+
"eslint-plugin-mui-path-imports": "0.0.15",
6771
"eslint-plugin-prettier": "^4.2.1",
68-
"eslint-plugin-react": "7.30.0",
69-
"eslint-plugin-simple-import-sort": "7.0.0",
72+
"eslint-plugin-react": "^7.30.0",
73+
"eslint-plugin-simple-import-sort": "^7.0.0",
7074
"husky": "^7.0.4",
7175
"lint-staged": "^12.1.2",
7276
"mocha": "^9.1.3",
@@ -75,19 +79,25 @@
7579
},
7680
"peerDependencies": {
7781
"@mat3ra/ade": "*",
82+
"@mat3ra/code": "*",
83+
"@mat3ra/esse": "*",
7884
"@mat3ra/ide": "*",
85+
"@mat3ra/made": "*",
7986
"@mat3ra/mode": "*",
8087
"@mat3ra/standata": "*",
81-
"@mat3ra/utils": "*",
82-
"@mat3ra/code": "*",
83-
"@mat3ra/esse": "*",
84-
"@mat3ra/made": "*"
88+
"@mat3ra/utils": "*"
8589
},
8690
"engines": {
8791
"node": ">=20.0.0"
8892
},
8993
"lint-staged": {
90-
"src/js/**/*.js": ["eslint --cache --fix", "prettier --write"],
91-
"tests/js/**/*.js": ["eslint --cache --fix", "prettier --write"]
94+
"src/js/**/*.js": [
95+
"eslint --cache --fix",
96+
"prettier --write"
97+
],
98+
"tests/js/**/*.js": [
99+
"eslint --cache --fix",
100+
"prettier --write"
101+
]
92102
}
93103
}

scripts/generate-mixins.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script to generate mixin properties from JSON schema
5+
*
6+
* This script generates mixin functions for property/holder, property/meta_holder,
7+
* and property/proto_holder schemas automatically.
8+
*
9+
* Usage:
10+
* npx ts-node scripts/generate-mixin-properties.ts
11+
*/
12+
13+
import generateSchemaMixin from "@mat3ra/code/dist/js/generateSchemaMixin";
14+
import allSchemas from "@mat3ra/esse/dist/js/schemas.json";
15+
import type { JSONSchema7 } from "json-schema";
16+
17+
/**
18+
* Output file paths for each schema
19+
*/
20+
const OUTPUT_PATHS = {
21+
"workflow/unit/mixins/base": "src/js/generated/BaseUnitSchemaMixin.ts",
22+
"system/status": "src/js/generated/StatusSchemaMixin.ts",
23+
"workflow/unit/mixins/assertion": "src/js/generated/AssertionUnitSchemaMixin.ts",
24+
"workflow/unit/mixins/assignment": "src/js/generated/AssignmentUnitSchemaMixin.ts",
25+
"workflow/unit/mixins/condition": "src/js/generated/ConditionUnitSchemaMixin.ts",
26+
"workflow/unit/mixins/execution": "src/js/generated/ExecutionUnitSchemaMixin.ts",
27+
"workflow/unit/mixins/io": "src/js/generated/IOUnitSchemaMixin.ts",
28+
"workflow/unit/mixins/map": "src/js/generated/MapUnitSchemaMixin.ts",
29+
"workflow/unit/mixins/processing": "src/js/generated/ProcessingUnitSchemaMixin.ts",
30+
"workflow/unit/mixins/reduce": "src/js/generated/ReduceUnitSchemaMixin.ts",
31+
"workflow/unit/mixins/subworkflow": "src/js/generated/SubworkflowUnitSchemaMixin.ts",
32+
"workflow/unit/input/-inputItem": "src/js/generated/ExecutionUnitInputSchemaMixin.ts",
33+
"workflow/subworkflow/mixin": "src/js/generated/SubworkflowSchemaMixin.ts",
34+
};
35+
36+
function main() {
37+
// Type assertion to handle schema compatibility - the schemas from esse may have slightly different types
38+
const result = generateSchemaMixin(allSchemas as JSONSchema7[], OUTPUT_PATHS);
39+
40+
if (result.errorCount > 0) {
41+
process.exit(1);
42+
}
43+
}
44+
45+
// Run the script if it's executed directly
46+
main();

src/js/ExecutionUnitInput.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { Template } from "@mat3ra/ade";
2+
import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
3+
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
4+
import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface";
5+
import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
6+
import type { TemplateSchema } from "@mat3ra/esse/dist/js/types";
7+
import nunjucks from "nunjucks";
8+
9+
import { providers } from "./context/providers";
10+
import type { ContextItem, ContextProviderConfig } from "./context/providers/base/ContextProvider";
11+
import type ContextProvider from "./context/providers/base/ContextProvider";
12+
import type { ExecutionUnitInputSchemaMixin } from "./generated/ExecutionUnitInputSchemaMixin";
13+
14+
type Schema = ExecutionUnitInputSchemaMixin;
15+
16+
type Base = typeof InMemoryEntity & Constructor<ExecutionUnitInputSchemaMixin>;
17+
18+
type ConstructorConfig = Schema | (Omit<Schema, "template"> & { template: Template });
19+
20+
export default class ExecutionUnitInput extends (InMemoryEntity as Base) implements Schema {
21+
declare _json: Schema & AnyObject;
22+
23+
declare toJSON: () => Schema & AnyObject;
24+
25+
declare toJSONQuick: () => Schema & AnyObject;
26+
27+
static get jsonSchema() {
28+
return JSONSchemasInterface.getSchemaById("workflow/unit/input/-inputItem");
29+
}
30+
31+
contextProvidersInstances: ContextProvider[] = [];
32+
33+
readonly templateInstance: Template;
34+
35+
static createFromTemplate(template: Template | TemplateSchema) {
36+
return new ExecutionUnitInput({
37+
template,
38+
rendered: template.content,
39+
isManuallyChanged: false,
40+
});
41+
}
42+
43+
constructor(config: ConstructorConfig) {
44+
const { template } = config;
45+
const templateInstance = template instanceof Template ? template : new Template(template);
46+
47+
super({ ...config, template: templateInstance.toJSON() });
48+
49+
this.templateInstance = templateInstance;
50+
}
51+
52+
setContext(context: ContextItem[]) {
53+
this.contextProvidersInstances = this.template.contextProviders.map(({ name }) => {
54+
if (!providers) {
55+
throw new Error("Providers config not set");
56+
}
57+
58+
const ContextProvider = providers[name as keyof typeof providers];
59+
const contextItem = context.find((c) => c.name === name);
60+
61+
if (!contextItem) {
62+
throw new Error(`Context item for provider ${name} not found`);
63+
}
64+
65+
return new ContextProvider(contextItem);
66+
});
67+
68+
return this;
69+
}
70+
71+
render() {
72+
if (this.isManuallyChanged) {
73+
return this;
74+
}
75+
76+
const fullContext = this.getFullContext();
77+
const rendered = nunjucks.compile(this.template.content).render(fullContext);
78+
79+
this.rendered = rendered || this.template.content;
80+
81+
return this;
82+
}
83+
84+
getFullContext() {
85+
return this.contextProvidersInstances.map((contextProvider) => {
86+
return contextProvider.getContextItem();
87+
});
88+
}
89+
}

src/js/RuntimeItemsUILogicMixin.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2+
import type { RuntimeItems } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin";
3+
import type { NameResultSchema } from "@mat3ra/code/dist/js/utils/object";
4+
import type { RuntimeItemsSchema } from "@mat3ra/esse/dist/js/types";
5+
6+
type ItemKey = "results" | "monitors" | "preProcessors" | "postProcessors";
7+
8+
export type RuntimeItemsUILogic = {
9+
setRuntimeItemsToDefaultValues(): void;
10+
_initRuntimeItems(config?: Partial<RuntimeItemsSchema>): void;
11+
toggleRuntimeItem(key: ItemKey, data: NameResultSchema, isAdding: boolean): void;
12+
toggleResult(data: NameResultSchema, isAdding: boolean): void;
13+
toggleMonitor(data: NameResultSchema, isAdding: boolean): void;
14+
togglePreProcessor(data: NameResultSchema, isAdding: boolean): void;
15+
togglePostProcessor(data: NameResultSchema, isAdding: boolean): void;
16+
getResultByName(name: string): NameResultSchema | undefined;
17+
get resultNames(): string[];
18+
get monitorNames(): string[];
19+
get postProcessorNames(): string[];
20+
get preProcessorNames(): string[];
21+
};
22+
23+
type RuntimeItemsUILogicPrivate = {
24+
toggleRuntimeItem(key: ItemKey, data: NameResultSchema, isAdding: boolean): void;
25+
};
26+
27+
type Base = InMemoryEntity &
28+
RuntimeItems & {
29+
defaultResults: NameResultSchema[];
30+
defaultMonitors: NameResultSchema[];
31+
defaultPreProcessors: NameResultSchema[];
32+
defaultPostProcessors: NameResultSchema[];
33+
};
34+
35+
// @ts-expect-error
36+
const propertiesMixn: Base & RuntimeItemsUILogic & RuntimeItemsUILogicPrivate = {
37+
setRuntimeItemsToDefaultValues() {
38+
this.results = this.defaultResults;
39+
this.monitors = this.defaultMonitors;
40+
this.preProcessors = this.defaultPreProcessors;
41+
this.postProcessors = this.defaultPostProcessors;
42+
},
43+
_initRuntimeItems(config) {
44+
this.results = config?.results || this.defaultResults;
45+
this.monitors = config?.monitors || this.defaultMonitors;
46+
this.preProcessors = config?.preProcessors || this.defaultPreProcessors;
47+
this.postProcessors = config?.postProcessors || this.defaultPostProcessors;
48+
},
49+
toggleRuntimeItem(key: ItemKey, data: NameResultSchema, isAdding: boolean) {
50+
if (isAdding) {
51+
this[key] = [...this[key], data];
52+
} else {
53+
this[key] = this[key].filter((x) => x.name !== data.name);
54+
}
55+
},
56+
toggleResult(data: NameResultSchema, isAdding: boolean) {
57+
this.toggleRuntimeItem("results", data, isAdding);
58+
},
59+
toggleMonitor(data: NameResultSchema, isAdding: boolean) {
60+
this.toggleRuntimeItem("monitors", data, isAdding);
61+
},
62+
togglePreProcessor(data: NameResultSchema, isAdding: boolean) {
63+
this.toggleRuntimeItem("preProcessors", data, isAdding);
64+
},
65+
togglePostProcessor(data: NameResultSchema, isAdding: boolean) {
66+
this.toggleRuntimeItem("postProcessors", data, isAdding);
67+
},
68+
get resultNames() {
69+
return this.results.map((r) => r.name);
70+
},
71+
get monitorNames() {
72+
return this.monitors.map((r) => r?.name);
73+
},
74+
get postProcessorNames() {
75+
return this.postProcessors.map((r) => r.name);
76+
},
77+
get preProcessorNames() {
78+
return this.preProcessors.map((r) => r.name);
79+
},
80+
getResultByName(name: string) {
81+
return this.results.find((r) => r.name === name);
82+
},
83+
};
84+
85+
export function runtimeItemsUILogicMixin<T extends Base>(item: T) {
86+
Object.defineProperties(item, Object.getOwnPropertyDescriptors(propertiesMixn));
87+
}

src/js/context/context.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)