Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
mat3ra-wode-0.0.0.tgz
node_modules/
.eslintcache
.nyc_output/
Expand Down
55 changes: 46 additions & 9 deletions dist/js/Subworkflow.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
static get defaultConfig(): {
_id: any;
name: string;
application: import("@mat3ra/esse/dist/js/types").ApplicationSchema | undefined;
application: import("@mat3ra/esse/dist/js/types").ApplicationSchema;
model: {
functional: string;
functional: "pbe";
method: {
readonly type: "pseudopotential";
readonly subtype: "us";
Expand Down Expand Up @@ -461,7 +461,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
contextProviderName: "vasp-neb";
};
extraData: {
materialHash: string;
materialHash?: string;
};
isEdited: boolean;
} | {
Expand All @@ -483,7 +483,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
preferGridMetric?: boolean;
};
extraData: {
materialHash: string;
materialHash?: string;
};
isEdited: boolean;
} | {
Expand All @@ -496,7 +496,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
steps: number;
}[]];
extraData: {
materialHash: string;
materialHash?: string;
};
isEdited: boolean;
} | {
Expand All @@ -522,7 +522,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
hubbardUValue?: number;
}[];
extraData: {
materialHash: string;
materialHash?: string;
};
isEdited: boolean;
} | {
Expand Down Expand Up @@ -575,7 +575,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
targetFermiEnergy?: number;
};
extraData: {
materialHash: string;
materialHash?: string;
};
isEdited: boolean;
} | {
Expand Down Expand Up @@ -615,7 +615,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
totalMagnetization: number;
};
extraData: {
materialHash: string;
materialHash?: string;
};
isEdited: boolean;
} | {
Expand Down Expand Up @@ -650,7 +650,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
};
};
extraData: {
materialHash: string;
materialHash?: string;
};
isEdited: boolean;
})[];
Expand Down Expand Up @@ -697,6 +697,43 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
}[];
operand: string;
value: string | boolean | number;
} | {
_id?: string;
slug?: string;
systemName?: string;
schemaVersion?: string;
name: string;
isDefault?: boolean;
preProcessors: {
name: string;
[k: string]: unknown;
}[];
postProcessors: {
name: string;
[k: string]: unknown;
}[];
monitors: {
name: string;
[k: string]: unknown;
}[];
results: {
name: string;
[k: string]: unknown;
}[];
tags?: string[];
status?: "idle" | "active" | "warning" | "error" | "finished";
statusTrack?: {
trackedAt: number;
status: string;
repetition?: number;
}[];
isDraft?: boolean;
type: "error";
head?: boolean;
flowchartId: string;
next?: string;
enableRender?: boolean;
reason: string;
} | undefined;
findUnitKeyById(id: string): string;
private findUnitWithTag;
Expand Down
7 changes: 5 additions & 2 deletions dist/js/Subworkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ class Subworkflow extends entity_1.InMemoryEntity {
}
static get defaultConfig() {
const defaultName = "New Subworkflow";
const application = new standata_1.ApplicationRegistry().getDefaultApplication();
if (!application) {
throw new Error("No default application found");
}
return {
_id: utils_1.Utils.uuid.getUUID(),
name: defaultName,
application: new standata_1.ApplicationRegistry().getDefaultApplication(),
// TODO: confirm if `functional` is required field. If not, update ESSE schema
application,
// `Model.defaultConfig` from @mat3ra/mode may omit `functional`; ESSE subworkflow schema requires it once schemas are registered.
model: { ...mode_1.Model.defaultConfig, functional: "pbe" },
properties: [],
Expand Down
3 changes: 2 additions & 1 deletion dist/js/Workflow.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type HasDescription } from "@mat3ra/code/dist/js/entity/mixins/HasDescr
import { type HashedEntity } from "@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin";
import { Taggable } from "@mat3ra/code/dist/js/entity/mixins/TaggableMixin";
import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
import type { ApplicationSchema, WorkflowSchema } from "@mat3ra/esse/dist/js/types";
import type { ApplicationSchema } from "@mat3ra/esse/dist/js/types";
import { ComputedEntityMixin } from "@mat3ra/ide/dist/js/compute";
import type { Material } from "@mat3ra/made";
import type { MetaPropertyHolder } from "@mat3ra/prode";
Expand All @@ -17,6 +17,7 @@ import { type WorkflowSchemaMixin } from "./generated/WorkflowSchemaMixin";
import Subworkflow from "./Subworkflow";
import { MapUnit } from "./units";
import { type AnyWorkflowUnit } from "./units/factory";
import type { WorkflowSchema } from "./workflows/types";
interface Workflow extends Defaultable, NamedInMemoryEntity, WorkflowSchemaMixin, Taggable, HashedEntity, ComputedEntityMixin, HasDescription {
compute: WorkflowSchema["compute"];
}
Expand Down
2 changes: 1 addition & 1 deletion dist/js/context/mixins/MaterialContextMixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type MaterialContextMixin = {
readonly isMaterialUpdated: boolean;
material: OrderedMaterial;
extraData?: {
materialHash: string;
materialHash?: string;
};
initMaterialContextMixin(externalContext: MaterialExternalContext): void;
updateMaterialHash(): void;
Expand Down
4 changes: 3 additions & 1 deletion dist/js/enums.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export declare const UNIT_TYPES: {
readonly subworkflow: "subworkflow";
readonly io: "io";
readonly assertion: "assertion";
readonly error: "error";
};
export declare enum UnitType {
convergence = "convergence",
Expand All @@ -20,7 +21,8 @@ export declare enum UnitType {
condition = "condition",
subworkflow = "subworkflow",
io = "io",
assertion = "assertion"
assertion = "assertion",
error = "error"
}
export declare enum UnitTag {
hasConvergenceParam = "hasConvergenceParam",
Expand Down
2 changes: 2 additions & 0 deletions dist/js/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports.UNIT_TYPES = {
subworkflow: "subworkflow",
io: "io",
assertion: "assertion",
error: "error",
};
var UnitType;
(function (UnitType) {
Expand All @@ -27,6 +28,7 @@ var UnitType;
UnitType["subworkflow"] = "subworkflow";
UnitType["io"] = "io";
UnitType["assertion"] = "assertion";
UnitType["error"] = "error";
})(UnitType || (exports.UnitType = UnitType = {}));
var UnitTag;
(function (UnitTag) {
Expand Down
5 changes: 5 additions & 0 deletions dist/js/generated/ErrorUnitSchemaMixin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
import type { ErrorUnitMixinSchema } from "@mat3ra/esse/dist/js/types";
export type ErrorUnitSchemaMixin = ErrorUnitMixinSchema;
export type ErrorUnitInMemoryEntity = InMemoryEntity & ErrorUnitSchemaMixin;
export declare function errorUnitSchemaMixin<T extends InMemoryEntity>(item: InMemoryEntity): asserts item is T & ErrorUnitSchemaMixin;
21 changes: 21 additions & 0 deletions dist/js/generated/ErrorUnitSchemaMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorUnitSchemaMixin = errorUnitSchemaMixin;
function errorUnitSchemaMixin(item) {
// @ts-expect-error
const properties = {
get type() {
return this.prop("type");
},
set type(value) {
this.setProp("type", value);
},
get reason() {
return this.requiredProp("reason");
},
set reason(value) {
this.setProp("reason", value);
},
};
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
}
5 changes: 3 additions & 2 deletions dist/js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import PointsPathFormDataProvider from "./context/providers/PointsPath/PointsPat
import { globalSettings } from "./context/providers/settings";
import { TAB_NAVIGATION_CONFIG, UNIT_NAME_INVALID_CHARS, WORKFLOW_STATUSES } from "./enums";
import Subworkflow from "./Subworkflow";
import { AssertionUnit, AssignmentUnit, BaseUnit, ConditionUnit, ExecutionUnit, IOUnit, MapUnit, ReduceUnit, SubworkflowUnit } from "./units";
import { AssertionUnit, AssignmentUnit, BaseUnit, ConditionUnit, ErrorUnit, ExecutionUnit, IOUnit, MapUnit, ReduceUnit, SubworkflowUnit } from "./units";
import { UnitFactory } from "./units/factory";
import { defaultMapConfig } from "./units/MapUnit";
import * as utils from "./utils";
import Workflow from "./Workflow";
export type { OrderedMaterial } from "./context/mixins/MaterialContextMixin";
export type { MaterialsSet } from "./context/mixins/MaterialsSetContextMixin";
export type { AnySubworkflowUnit, DefaultSubworkflowUnitType } from "./units/factory";
export { Subworkflow, Workflow, UnitFactory, TAB_NAVIGATION_CONFIG, UNIT_NAME_INVALID_CHARS, WORKFLOW_STATUSES, BaseUnit, ExecutionUnit, AssertionUnit, AssignmentUnit, ConditionUnit, IOUnit, MapUnit, ReduceUnit, SubworkflowUnit, defaultMapConfig, PointsPathFormDataProvider, globalSettings, utils, };
export { repairWorkflow } from "./utils/repair";
export { Subworkflow, Workflow, UnitFactory, TAB_NAVIGATION_CONFIG, UNIT_NAME_INVALID_CHARS, WORKFLOW_STATUSES, BaseUnit, ExecutionUnit, AssertionUnit, AssignmentUnit, ConditionUnit, ErrorUnit, IOUnit, MapUnit, ReduceUnit, SubworkflowUnit, defaultMapConfig, PointsPathFormDataProvider, globalSettings, utils, };
5 changes: 4 additions & 1 deletion dist/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.utils = exports.globalSettings = exports.PointsPathFormDataProvider = exports.defaultMapConfig = exports.SubworkflowUnit = exports.ReduceUnit = exports.MapUnit = exports.IOUnit = exports.ConditionUnit = exports.AssignmentUnit = exports.AssertionUnit = exports.ExecutionUnit = exports.BaseUnit = exports.WORKFLOW_STATUSES = exports.UNIT_NAME_INVALID_CHARS = exports.TAB_NAVIGATION_CONFIG = exports.UnitFactory = exports.Workflow = exports.Subworkflow = void 0;
exports.utils = exports.globalSettings = exports.PointsPathFormDataProvider = exports.defaultMapConfig = exports.SubworkflowUnit = exports.ReduceUnit = exports.MapUnit = exports.IOUnit = exports.ErrorUnit = exports.ConditionUnit = exports.AssignmentUnit = exports.AssertionUnit = exports.ExecutionUnit = exports.BaseUnit = exports.WORKFLOW_STATUSES = exports.UNIT_NAME_INVALID_CHARS = exports.TAB_NAVIGATION_CONFIG = exports.UnitFactory = exports.Workflow = exports.Subworkflow = exports.repairWorkflow = void 0;
const PointsPathFormDataProvider_1 = __importDefault(require("./context/providers/PointsPath/PointsPathFormDataProvider"));
exports.PointsPathFormDataProvider = PointsPathFormDataProvider_1.default;
const settings_1 = require("./context/providers/settings");
Expand All @@ -52,6 +52,7 @@ Object.defineProperty(exports, "AssertionUnit", { enumerable: true, get: functio
Object.defineProperty(exports, "AssignmentUnit", { enumerable: true, get: function () { return units_1.AssignmentUnit; } });
Object.defineProperty(exports, "BaseUnit", { enumerable: true, get: function () { return units_1.BaseUnit; } });
Object.defineProperty(exports, "ConditionUnit", { enumerable: true, get: function () { return units_1.ConditionUnit; } });
Object.defineProperty(exports, "ErrorUnit", { enumerable: true, get: function () { return units_1.ErrorUnit; } });
Object.defineProperty(exports, "ExecutionUnit", { enumerable: true, get: function () { return units_1.ExecutionUnit; } });
Object.defineProperty(exports, "IOUnit", { enumerable: true, get: function () { return units_1.IOUnit; } });
Object.defineProperty(exports, "MapUnit", { enumerable: true, get: function () { return units_1.MapUnit; } });
Expand All @@ -65,3 +66,5 @@ const utils = __importStar(require("./utils"));
exports.utils = utils;
const Workflow_1 = __importDefault(require("./Workflow"));
exports.Workflow = Workflow_1.default;
var repair_1 = require("./utils/repair");
Object.defineProperty(exports, "repairWorkflow", { enumerable: true, get: function () { return repair_1.repairWorkflow; } });
3 changes: 3 additions & 0 deletions dist/js/repair/createErrorUnitData.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { ErrorUnitSchema } from "@mat3ra/esse/dist/js/types";
import type { AnySubworkflowUnitSchema } from "../units/factory";
export declare function createErrorUnitData(unitData: AnySubworkflowUnitSchema | Record<string, unknown>, reason: string): ErrorUnitSchema;
25 changes: 25 additions & 0 deletions dist/js/repair/createErrorUnitData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createErrorUnitData = createErrorUnitData;
const utils_1 = require("@mat3ra/utils");
const enums_1 = require("../enums");
function createErrorUnitData(unitData, reason) {
const original = structuredClone(unitData);
return {
results: [],
preProcessors: [],
postProcessors: [],
monitors: [],
name: typeof original.name === "string" ? original.name : enums_1.UnitType.error,
type: enums_1.UnitType.error,
status: enums_1.UnitStatus.error,
flowchartId: typeof original.flowchartId === "string" ? original.flowchartId : utils_1.Utils.uuid.getUUID(),
originalUnit: original,
reason,
...(typeof original._id === "string" ? { _id: original._id } : {}),
...(typeof original.next === "string" ? { next: original.next } : {}),
...(original.head === true ? { head: true } : {}),
...(Array.isArray(original.statusTrack) ? { statusTrack: original.statusTrack } : {}),
...(Array.isArray(original.tags) ? { tags: original.tags } : {}),
};
}
1 change: 1 addition & 0 deletions dist/js/repair/formatRepairReason.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare function formatRepairReason(error: unknown): string;
22 changes: 22 additions & 0 deletions dist/js/repair/formatRepairReason.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatRepairReason = formatRepairReason;
function formatRepairReason(error) {
var _a;
if (error && typeof error === "object") {
const entityError = error;
if (((_a = entityError.details) === null || _a === void 0 ? void 0 : _a.error) !== undefined) {
return JSON.stringify(entityError.details.error);
}
if (typeof entityError.message === "string" && entityError.message.length > 0) {
return entityError.message;
}
if (typeof entityError.code === "string" && entityError.code.length > 0) {
return entityError.code;
}
}
if (error instanceof Error) {
return error.message;
}
return String(error);
}
16 changes: 16 additions & 0 deletions dist/js/repair/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { SubworkflowSchema, WorkflowSchema } from "@mat3ra/esse/dist/js/types";
export type SubworkflowUnitRepairRecord = {
subworkflowId: string;
flowchartId: string;
reason: string;
};
export type SubworkflowRepairResult = {
document: SubworkflowSchema;
changed: boolean;
repairs: SubworkflowUnitRepairRecord[];
};
export type WorkflowRepairResult = {
document: WorkflowSchema;
changed: boolean;
repairs: SubworkflowUnitRepairRecord[];
};
2 changes: 2 additions & 0 deletions dist/js/repair/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
16 changes: 16 additions & 0 deletions dist/js/units/ErrorUnit.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
import type { ErrorUnitSchema } from "@mat3ra/esse/dist/js/types";
import { type ErrorUnitSchemaMixin } from "../generated/ErrorUnitSchemaMixin";
import BaseUnit from "./BaseUnit";
type Schema = ErrorUnitSchema;
type Base = typeof BaseUnit<Schema> & Constructor<ErrorUnitSchemaMixin>;
export type ErrorUnitConfig = Partial<Schema>;
declare const ErrorUnit_base: Base;
declare class ErrorUnit extends ErrorUnit_base implements Schema {
toJSON: () => Schema & AnyObject;
_json: Schema & AnyObject;
static get jsonSchema(): import("json-schema").JSONSchema7 | undefined;
constructor(config: ErrorUnitConfig);
}
export default ErrorUnit;
31 changes: 31 additions & 0 deletions dist/js/units/ErrorUnit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
const enums_1 = require("../enums");
const ErrorUnitSchemaMixin_1 = require("../generated/ErrorUnitSchemaMixin");
const BaseUnit_1 = __importDefault(require("./BaseUnit"));
class ErrorUnit extends BaseUnit_1.default {
static get jsonSchema() {
return JSONSchemasInterface_1.default.getSchemaById("workflow/unit/error");
}
constructor(config) {
var _a;
const schema = {
name: enums_1.UnitType.error,
results: [],
preProcessors: [],
postProcessors: [],
monitors: [],
reason: "",
...config,
type: enums_1.UnitType.error,
status: (_a = config.status) !== null && _a !== void 0 ? _a : enums_1.UnitStatus.error,
};
super(schema);
}
}
(0, ErrorUnitSchemaMixin_1.errorUnitSchemaMixin)(ErrorUnit.prototype);
exports.default = ErrorUnit;
Loading
Loading