@mat3ra/wode 2026.6.5-0 → 2026.6.18-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/js/Subworkflow.d.ts +49 -12
  2. package/dist/js/Subworkflow.js +20 -12
  3. package/dist/js/Workflow.d.ts +2 -1
  4. package/dist/js/context/mixins/MaterialContextMixin.d.ts +1 -1
  5. package/dist/js/enums.d.ts +3 -1
  6. package/dist/js/enums.js +2 -0
  7. package/dist/js/generated/ErrorUnitSchemaMixin.d.ts +5 -0
  8. package/dist/js/generated/ErrorUnitSchemaMixin.js +21 -0
  9. package/dist/js/index.d.ts +3 -2
  10. package/dist/js/index.js +4 -1
  11. package/dist/js/repair/createErrorUnitData.d.ts +3 -0
  12. package/dist/js/repair/createErrorUnitData.js +25 -0
  13. package/dist/js/repair/formatRepairReason.d.ts +1 -0
  14. package/dist/js/repair/formatRepairReason.js +22 -0
  15. package/dist/js/repair/types.d.ts +16 -0
  16. package/dist/js/repair/types.js +2 -0
  17. package/dist/js/units/ErrorUnit.d.ts +16 -0
  18. package/dist/js/units/ErrorUnit.js +31 -0
  19. package/dist/js/units/factory.d.ts +13 -8
  20. package/dist/js/units/factory.js +5 -0
  21. package/dist/js/units/index.d.ts +2 -1
  22. package/dist/js/units/index.js +3 -1
  23. package/dist/js/utils/index.d.ts +1 -0
  24. package/dist/js/utils/index.js +2 -1
  25. package/dist/js/utils/repair.d.ts +2 -0
  26. package/dist/js/utils/repair.js +140 -0
  27. package/dist/js/workflows/default.d.ts +1 -1
  28. package/dist/js/workflows/types.d.ts +4 -0
  29. package/dist/js/workflows/types.js +2 -0
  30. package/package.json +5 -3
  31. package/src/js/Subworkflow.ts +23 -12
  32. package/src/js/Workflow.ts +2 -5
  33. package/src/js/context/mixins/MaterialContextMixin.ts +1 -1
  34. package/src/js/enums.ts +2 -0
  35. package/src/js/generated/ErrorUnitSchemaMixin.ts +28 -0
  36. package/src/js/index.ts +3 -0
  37. package/src/js/units/ErrorUnit.ts +42 -0
  38. package/src/js/units/factory.ts +35 -11
  39. package/src/js/units/index.ts +2 -0
  40. package/src/js/utils/index.ts +1 -0
  41. package/src/js/utils/repair.ts +171 -0
  42. package/src/js/workflows/default.ts +1 -1
  43. package/src/js/workflows/types.ts +5 -0
@@ -44,9 +44,9 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
44
44
  static get defaultConfig(): {
45
45
  _id: any;
46
46
  name: string;
47
- application: import("@mat3ra/esse/dist/js/types").ApplicationSchema | undefined;
47
+ application: import("@mat3ra/esse/dist/js/types").ApplicationSchema;
48
48
  model: {
49
- functional: string;
49
+ functional: "pbe";
50
50
  method: {
51
51
  readonly type: "pseudopotential";
52
52
  readonly subtype: "us";
@@ -461,7 +461,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
461
461
  contextProviderName: "vasp-neb";
462
462
  };
463
463
  extraData: {
464
- materialHash: string;
464
+ materialHash?: string;
465
465
  };
466
466
  isEdited: boolean;
467
467
  } | {
@@ -483,7 +483,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
483
483
  preferGridMetric?: boolean;
484
484
  };
485
485
  extraData: {
486
- materialHash: string;
486
+ materialHash?: string;
487
487
  };
488
488
  isEdited: boolean;
489
489
  } | {
@@ -496,7 +496,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
496
496
  steps: number;
497
497
  }[]];
498
498
  extraData: {
499
- materialHash: string;
499
+ materialHash?: string;
500
500
  };
501
501
  isEdited: boolean;
502
502
  } | {
@@ -522,7 +522,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
522
522
  hubbardUValue?: number;
523
523
  }[];
524
524
  extraData: {
525
- materialHash: string;
525
+ materialHash?: string;
526
526
  };
527
527
  isEdited: boolean;
528
528
  } | {
@@ -575,7 +575,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
575
575
  targetFermiEnergy?: number;
576
576
  };
577
577
  extraData: {
578
- materialHash: string;
578
+ materialHash?: string;
579
579
  };
580
580
  isEdited: boolean;
581
581
  } | {
@@ -615,7 +615,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
615
615
  totalMagnetization: number;
616
616
  };
617
617
  extraData: {
618
- materialHash: string;
618
+ materialHash?: string;
619
619
  };
620
620
  isEdited: boolean;
621
621
  } | {
@@ -650,7 +650,7 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
650
650
  };
651
651
  };
652
652
  extraData: {
653
- materialHash: string;
653
+ materialHash?: string;
654
654
  };
655
655
  isEdited: boolean;
656
656
  })[];
@@ -697,16 +697,53 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
697
697
  }[];
698
698
  operand: string;
699
699
  value: string | boolean | number;
700
+ } | {
701
+ _id?: string;
702
+ slug?: string;
703
+ systemName?: string;
704
+ schemaVersion?: string;
705
+ name: string;
706
+ isDefault?: boolean;
707
+ preProcessors: {
708
+ name: string;
709
+ [k: string]: unknown;
710
+ }[];
711
+ postProcessors: {
712
+ name: string;
713
+ [k: string]: unknown;
714
+ }[];
715
+ monitors: {
716
+ name: string;
717
+ [k: string]: unknown;
718
+ }[];
719
+ results: {
720
+ name: string;
721
+ [k: string]: unknown;
722
+ }[];
723
+ tags?: string[];
724
+ status?: "idle" | "active" | "warning" | "error" | "finished";
725
+ statusTrack?: {
726
+ trackedAt: number;
727
+ status: string;
728
+ repetition?: number;
729
+ }[];
730
+ isDraft?: boolean;
731
+ type: "error";
732
+ head?: boolean;
733
+ flowchartId: string;
734
+ next?: string;
735
+ enableRender?: boolean;
736
+ reason: string;
700
737
  } | undefined;
701
738
  findUnitKeyById(id: string): string;
702
- private findUnitWithTag;
739
+ private findAssignmentUnitWithTag;
703
740
  get hasConvergence(): boolean;
704
741
  get convergenceParam(): string | undefined;
705
742
  get convergenceResult(): string | undefined;
706
743
  convergenceSeries(scopeTrack: JobSchema["scopeTrack"]): {
707
744
  x: number;
708
- param: any;
709
- y: any;
745
+ param: unknown;
746
+ y: unknown;
710
747
  }[];
711
748
  updateMethodData(materials: Material[], metaProperties: MetaPropertyHolder[]): void;
712
749
  addConvergence({ parameter, parameterInitial, parameterIncrement, result, resultInitial, condition, operator, tolerance, maxOccurrences, externalContext, }: ConvergenceConfig): void;
@@ -35,11 +35,14 @@ class Subworkflow extends entity_1.InMemoryEntity {
35
35
  }
36
36
  static get defaultConfig() {
37
37
  const defaultName = "New Subworkflow";
38
+ const application = new standata_1.ApplicationRegistry().getDefaultApplication();
39
+ if (!application) {
40
+ throw new Error("No default application found");
41
+ }
38
42
  return {
39
43
  _id: utils_1.Utils.uuid.getUUID(),
40
44
  name: defaultName,
41
- application: new standata_1.ApplicationRegistry().getDefaultApplication(),
42
- // TODO: confirm if `functional` is required field. If not, update ESSE schema
45
+ application,
43
46
  // `Model.defaultConfig` from @mat3ra/mode may omit `functional`; ESSE subworkflow schema requires it once schemas are registered.
44
47
  model: { ...mode_1.Model.defaultConfig, functional: "pbe" },
45
48
  properties: [],
@@ -183,7 +186,7 @@ class Subworkflow extends entity_1.InMemoryEntity {
183
186
  const index = this.units.findIndex((u) => u.flowchartId === id);
184
187
  return `units.${index}`;
185
188
  }
186
- findUnitWithTag(tag) {
189
+ findAssignmentUnitWithTag(tag) {
187
190
  return this.units
188
191
  .filter((unit) => unit.type === enums_1.UnitType.assignment)
189
192
  .find((unit) => { var _a; return (_a = unit.tags) === null || _a === void 0 ? void 0 : _a.includes(tag); });
@@ -193,27 +196,32 @@ class Subworkflow extends entity_1.InMemoryEntity {
193
196
  }
194
197
  get convergenceParam() {
195
198
  var _a;
196
- return (_a = this.findUnitWithTag(enums_1.UnitTag.hasConvergenceParam)) === null || _a === void 0 ? void 0 : _a.operand;
199
+ return (_a = this.findAssignmentUnitWithTag(enums_1.UnitTag.hasConvergenceParam)) === null || _a === void 0 ? void 0 : _a.operand;
197
200
  }
198
201
  get convergenceResult() {
199
202
  var _a;
200
- return (_a = this.findUnitWithTag(enums_1.UnitTag.hasConvergenceResult)) === null || _a === void 0 ? void 0 : _a.operand;
203
+ return (_a = this.findAssignmentUnitWithTag(enums_1.UnitTag.hasConvergenceResult)) === null || _a === void 0 ? void 0 : _a.operand;
201
204
  }
202
205
  convergenceSeries(scopeTrack) {
203
- if (!this.hasConvergence || !(scopeTrack === null || scopeTrack === void 0 ? void 0 : scopeTrack.length)) {
206
+ const { convergenceParam, convergenceResult } = this;
207
+ if (!convergenceParam || !convergenceResult || !(scopeTrack === null || scopeTrack === void 0 ? void 0 : scopeTrack.length)) {
204
208
  return [];
205
209
  }
206
210
  let prevResult;
211
+ // `scopeTrack` stores per-repetition diffs: each item only carries the global/local keys
212
+ // that were added or changed in that repetition (see UnitEndpoint.saveUnitStatus). Accumulate
213
+ // the global scope across items so each iteration reads the full scope, not just its delta.
214
+ // This also stays correct for legacy full-snapshot scopeTrack data, since re-applying a full
215
+ // snapshot is idempotent.
216
+ const accumulatedGlobal = {};
207
217
  return scopeTrack
208
218
  .map((scopeItem, i) => {
209
- var _a, _b;
219
+ var _a;
220
+ Object.assign(accumulatedGlobal, (_a = scopeItem.scope) === null || _a === void 0 ? void 0 : _a.global);
210
221
  return {
211
222
  x: i,
212
- // TODO: fix types
213
- // @ts-ignore
214
- param: (_a = scopeItem.scope) === null || _a === void 0 ? void 0 : _a.global[this.convergenceParam],
215
- // @ts-ignore
216
- y: (_b = scopeItem.scope) === null || _b === void 0 ? void 0 : _b.global[this.convergenceResult],
223
+ param: accumulatedGlobal[convergenceParam],
224
+ y: accumulatedGlobal[convergenceResult],
217
225
  };
218
226
  })
219
227
  .filter(({ y }) => {
@@ -4,7 +4,7 @@ import { type HasDescription } from "@mat3ra/code/dist/js/entity/mixins/HasDescr
4
4
  import { type HashedEntity } from "@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin";
5
5
  import { Taggable } from "@mat3ra/code/dist/js/entity/mixins/TaggableMixin";
6
6
  import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
7
- import type { ApplicationSchema, WorkflowSchema } from "@mat3ra/esse/dist/js/types";
7
+ import type { ApplicationSchema } from "@mat3ra/esse/dist/js/types";
8
8
  import { ComputedEntityMixin } from "@mat3ra/ide/dist/js/compute";
9
9
  import type { Material } from "@mat3ra/made";
10
10
  import type { MetaPropertyHolder } from "@mat3ra/prode";
@@ -17,6 +17,7 @@ import { type WorkflowSchemaMixin } from "./generated/WorkflowSchemaMixin";
17
17
  import Subworkflow from "./Subworkflow";
18
18
  import { MapUnit } from "./units";
19
19
  import { type AnyWorkflowUnit } from "./units/factory";
20
+ import type { WorkflowSchema } from "./workflows/types";
20
21
  interface Workflow extends Defaultable, NamedInMemoryEntity, WorkflowSchemaMixin, Taggable, HashedEntity, ComputedEntityMixin, HasDescription {
21
22
  compute: WorkflowSchema["compute"];
22
23
  }
@@ -7,7 +7,7 @@ export type MaterialContextMixin = {
7
7
  readonly isMaterialUpdated: boolean;
8
8
  material: OrderedMaterial;
9
9
  extraData?: {
10
- materialHash: string;
10
+ materialHash?: string;
11
11
  };
12
12
  initMaterialContextMixin(externalContext: MaterialExternalContext): void;
13
13
  updateMaterialHash(): void;
@@ -9,6 +9,7 @@ export declare const UNIT_TYPES: {
9
9
  readonly subworkflow: "subworkflow";
10
10
  readonly io: "io";
11
11
  readonly assertion: "assertion";
12
+ readonly error: "error";
12
13
  };
13
14
  export declare enum UnitType {
14
15
  convergence = "convergence",
@@ -20,7 +21,8 @@ export declare enum UnitType {
20
21
  condition = "condition",
21
22
  subworkflow = "subworkflow",
22
23
  io = "io",
23
- assertion = "assertion"
24
+ assertion = "assertion",
25
+ error = "error"
24
26
  }
25
27
  export declare enum UnitTag {
26
28
  hasConvergenceParam = "hasConvergenceParam",
package/dist/js/enums.js CHANGED
@@ -14,6 +14,7 @@ exports.UNIT_TYPES = {
14
14
  subworkflow: "subworkflow",
15
15
  io: "io",
16
16
  assertion: "assertion",
17
+ error: "error",
17
18
  };
18
19
  var UnitType;
19
20
  (function (UnitType) {
@@ -27,6 +28,7 @@ var UnitType;
27
28
  UnitType["subworkflow"] = "subworkflow";
28
29
  UnitType["io"] = "io";
29
30
  UnitType["assertion"] = "assertion";
31
+ UnitType["error"] = "error";
30
32
  })(UnitType || (exports.UnitType = UnitType = {}));
31
33
  var UnitTag;
32
34
  (function (UnitTag) {
@@ -0,0 +1,5 @@
1
+ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { ErrorUnitMixinSchema } from "@mat3ra/esse/dist/js/types";
3
+ export type ErrorUnitSchemaMixin = ErrorUnitMixinSchema;
4
+ export type ErrorUnitInMemoryEntity = InMemoryEntity & ErrorUnitSchemaMixin;
5
+ export declare function errorUnitSchemaMixin<T extends InMemoryEntity>(item: InMemoryEntity): asserts item is T & ErrorUnitSchemaMixin;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.errorUnitSchemaMixin = errorUnitSchemaMixin;
4
+ function errorUnitSchemaMixin(item) {
5
+ // @ts-expect-error
6
+ const properties = {
7
+ get type() {
8
+ return this.prop("type");
9
+ },
10
+ set type(value) {
11
+ this.setProp("type", value);
12
+ },
13
+ get reason() {
14
+ return this.requiredProp("reason");
15
+ },
16
+ set reason(value) {
17
+ this.setProp("reason", value);
18
+ },
19
+ };
20
+ Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
21
+ }
@@ -2,7 +2,7 @@ import PointsPathFormDataProvider from "./context/providers/PointsPath/PointsPat
2
2
  import { globalSettings } from "./context/providers/settings";
3
3
  import { TAB_NAVIGATION_CONFIG, UNIT_NAME_INVALID_CHARS, WORKFLOW_STATUSES } from "./enums";
4
4
  import Subworkflow from "./Subworkflow";
5
- import { AssertionUnit, AssignmentUnit, BaseUnit, ConditionUnit, ExecutionUnit, IOUnit, MapUnit, ReduceUnit, SubworkflowUnit } from "./units";
5
+ import { AssertionUnit, AssignmentUnit, BaseUnit, ConditionUnit, ErrorUnit, ExecutionUnit, IOUnit, MapUnit, ReduceUnit, SubworkflowUnit } from "./units";
6
6
  import { UnitFactory } from "./units/factory";
7
7
  import { defaultMapConfig } from "./units/MapUnit";
8
8
  import * as utils from "./utils";
@@ -10,4 +10,5 @@ import Workflow from "./Workflow";
10
10
  export type { OrderedMaterial } from "./context/mixins/MaterialContextMixin";
11
11
  export type { MaterialsSet } from "./context/mixins/MaterialsSetContextMixin";
12
12
  export type { AnySubworkflowUnit, DefaultSubworkflowUnitType } from "./units/factory";
13
- 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, };
13
+ export { repairWorkflow } from "./utils/repair";
14
+ 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, };
package/dist/js/index.js CHANGED
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- 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;
39
+ 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;
40
40
  const PointsPathFormDataProvider_1 = __importDefault(require("./context/providers/PointsPath/PointsPathFormDataProvider"));
41
41
  exports.PointsPathFormDataProvider = PointsPathFormDataProvider_1.default;
42
42
  const settings_1 = require("./context/providers/settings");
@@ -52,6 +52,7 @@ Object.defineProperty(exports, "AssertionUnit", { enumerable: true, get: functio
52
52
  Object.defineProperty(exports, "AssignmentUnit", { enumerable: true, get: function () { return units_1.AssignmentUnit; } });
53
53
  Object.defineProperty(exports, "BaseUnit", { enumerable: true, get: function () { return units_1.BaseUnit; } });
54
54
  Object.defineProperty(exports, "ConditionUnit", { enumerable: true, get: function () { return units_1.ConditionUnit; } });
55
+ Object.defineProperty(exports, "ErrorUnit", { enumerable: true, get: function () { return units_1.ErrorUnit; } });
55
56
  Object.defineProperty(exports, "ExecutionUnit", { enumerable: true, get: function () { return units_1.ExecutionUnit; } });
56
57
  Object.defineProperty(exports, "IOUnit", { enumerable: true, get: function () { return units_1.IOUnit; } });
57
58
  Object.defineProperty(exports, "MapUnit", { enumerable: true, get: function () { return units_1.MapUnit; } });
@@ -65,3 +66,5 @@ const utils = __importStar(require("./utils"));
65
66
  exports.utils = utils;
66
67
  const Workflow_1 = __importDefault(require("./Workflow"));
67
68
  exports.Workflow = Workflow_1.default;
69
+ var repair_1 = require("./utils/repair");
70
+ Object.defineProperty(exports, "repairWorkflow", { enumerable: true, get: function () { return repair_1.repairWorkflow; } });
@@ -0,0 +1,3 @@
1
+ import type { ErrorUnitSchema } from "@mat3ra/esse/dist/js/types";
2
+ import type { AnySubworkflowUnitSchema } from "../units/factory";
3
+ export declare function createErrorUnitData(unitData: AnySubworkflowUnitSchema | Record<string, unknown>, reason: string): ErrorUnitSchema;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createErrorUnitData = createErrorUnitData;
4
+ const utils_1 = require("@mat3ra/utils");
5
+ const enums_1 = require("../enums");
6
+ function createErrorUnitData(unitData, reason) {
7
+ const original = structuredClone(unitData);
8
+ return {
9
+ results: [],
10
+ preProcessors: [],
11
+ postProcessors: [],
12
+ monitors: [],
13
+ name: typeof original.name === "string" ? original.name : enums_1.UnitType.error,
14
+ type: enums_1.UnitType.error,
15
+ status: enums_1.UnitStatus.error,
16
+ flowchartId: typeof original.flowchartId === "string" ? original.flowchartId : utils_1.Utils.uuid.getUUID(),
17
+ originalUnit: original,
18
+ reason,
19
+ ...(typeof original._id === "string" ? { _id: original._id } : {}),
20
+ ...(typeof original.next === "string" ? { next: original.next } : {}),
21
+ ...(original.head === true ? { head: true } : {}),
22
+ ...(Array.isArray(original.statusTrack) ? { statusTrack: original.statusTrack } : {}),
23
+ ...(Array.isArray(original.tags) ? { tags: original.tags } : {}),
24
+ };
25
+ }
@@ -0,0 +1 @@
1
+ export declare function formatRepairReason(error: unknown): string;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatRepairReason = formatRepairReason;
4
+ function formatRepairReason(error) {
5
+ var _a;
6
+ if (error && typeof error === "object") {
7
+ const entityError = error;
8
+ if (((_a = entityError.details) === null || _a === void 0 ? void 0 : _a.error) !== undefined) {
9
+ return JSON.stringify(entityError.details.error);
10
+ }
11
+ if (typeof entityError.message === "string" && entityError.message.length > 0) {
12
+ return entityError.message;
13
+ }
14
+ if (typeof entityError.code === "string" && entityError.code.length > 0) {
15
+ return entityError.code;
16
+ }
17
+ }
18
+ if (error instanceof Error) {
19
+ return error.message;
20
+ }
21
+ return String(error);
22
+ }
@@ -0,0 +1,16 @@
1
+ import type { SubworkflowSchema, WorkflowSchema } from "@mat3ra/esse/dist/js/types";
2
+ export type SubworkflowUnitRepairRecord = {
3
+ subworkflowId: string;
4
+ flowchartId: string;
5
+ reason: string;
6
+ };
7
+ export type SubworkflowRepairResult = {
8
+ document: SubworkflowSchema;
9
+ changed: boolean;
10
+ repairs: SubworkflowUnitRepairRecord[];
11
+ };
12
+ export type WorkflowRepairResult = {
13
+ document: WorkflowSchema;
14
+ changed: boolean;
15
+ repairs: SubworkflowUnitRepairRecord[];
16
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
2
+ import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
3
+ import type { ErrorUnitSchema } from "@mat3ra/esse/dist/js/types";
4
+ import { type ErrorUnitSchemaMixin } from "../generated/ErrorUnitSchemaMixin";
5
+ import BaseUnit from "./BaseUnit";
6
+ type Schema = ErrorUnitSchema;
7
+ type Base = typeof BaseUnit<Schema> & Constructor<ErrorUnitSchemaMixin>;
8
+ export type ErrorUnitConfig = Partial<Schema>;
9
+ declare const ErrorUnit_base: Base;
10
+ declare class ErrorUnit extends ErrorUnit_base implements Schema {
11
+ toJSON: () => Schema & AnyObject;
12
+ _json: Schema & AnyObject;
13
+ static get jsonSchema(): import("json-schema").JSONSchema7 | undefined;
14
+ constructor(config: ErrorUnitConfig);
15
+ }
16
+ export default ErrorUnit;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
7
+ const enums_1 = require("../enums");
8
+ const ErrorUnitSchemaMixin_1 = require("../generated/ErrorUnitSchemaMixin");
9
+ const BaseUnit_1 = __importDefault(require("./BaseUnit"));
10
+ class ErrorUnit extends BaseUnit_1.default {
11
+ static get jsonSchema() {
12
+ return JSONSchemasInterface_1.default.getSchemaById("workflow/unit/error");
13
+ }
14
+ constructor(config) {
15
+ var _a;
16
+ const schema = {
17
+ name: enums_1.UnitType.error,
18
+ results: [],
19
+ preProcessors: [],
20
+ postProcessors: [],
21
+ monitors: [],
22
+ reason: "",
23
+ ...config,
24
+ type: enums_1.UnitType.error,
25
+ status: (_a = config.status) !== null && _a !== void 0 ? _a : enums_1.UnitStatus.error,
26
+ };
27
+ super(schema);
28
+ }
29
+ }
30
+ (0, ErrorUnitSchemaMixin_1.errorUnitSchemaMixin)(ErrorUnit.prototype);
31
+ exports.default = ErrorUnit;
@@ -1,21 +1,23 @@
1
- import type { AssertionUnitSchema, AssignmentUnitSchema, ConditionUnitSchema, DataIOUnitSchema, ExecutionUnitSchema, MapUnitSchema, ReduceUnitSchema, SubworkflowUnitSchema, WorkflowUnitSchema } from "@mat3ra/esse/dist/js/types";
1
+ import type { ApplicationSchema, AssertionUnitSchema, AssignmentUnitSchema, ConditionUnitSchema, DataIOUnitSchema, ErrorUnitSchema, ExecutionUnitSchema, MapUnitSchema, ReduceUnitSchema, SubworkflowUnitSchema, WorkflowUnitSchema } from "@mat3ra/esse/dist/js/types";
2
2
  import AssertionUnit, { type AssertionUnitConfig } from "./AssertionUnit";
3
3
  import AssignmentUnit, { type AssignmentUnitConfig } from "./AssignmentUnit";
4
4
  import ConditionUnit, { type ConditionUnitConfig } from "./ConditionUnit";
5
+ import ErrorUnit, { type ErrorUnitConfig } from "./ErrorUnit";
5
6
  import ExecutionUnit, { type ExecutionUnitConfig } from "./ExecutionUnit";
6
7
  import IOUnit, { type IOUnitConfig } from "./IOUnit";
7
8
  import MapUnit from "./MapUnit";
8
9
  import ReduceUnit from "./ReduceUnit";
9
10
  import SubworkflowUnit from "./SubworkflowUnit";
10
- export type AnyWorkflowUnit = MapUnit | SubworkflowUnit | ReduceUnit;
11
- export type AnyWorkflowUnitSchema = MapUnitSchema | SubworkflowUnitSchema | ReduceUnitSchema;
12
- export type AnySubworkflowUnit = ExecutionUnit | AssignmentUnit | ConditionUnit | IOUnit | AssertionUnit;
13
- export type AnySubworkflowUnitSchema = ExecutionUnitSchema | AssertionUnitSchema | AssignmentUnitSchema | ConditionUnitSchema | DataIOUnitSchema;
11
+ export type AnyWorkflowUnit = MapUnit | SubworkflowUnit | ReduceUnit | ErrorUnit;
12
+ export type AnyWorkflowUnitSchema = MapUnitSchema | SubworkflowUnitSchema | ReduceUnitSchema | ErrorUnitSchema;
13
+ export type AnySubworkflowUnit = ExecutionUnit | AssignmentUnit | ConditionUnit | IOUnit | AssertionUnit | ErrorUnit;
14
+ export type AnySubworkflowUnitSchema = ExecutionUnitSchema | AssertionUnitSchema | AssignmentUnitSchema | ConditionUnitSchema | DataIOUnitSchema | ErrorUnitSchema;
14
15
  type ExcutionConfig = ExecutionUnitConfig & Pick<ExecutionUnitSchema, "type">;
15
16
  type AssignmentConfig = AssignmentUnitConfig & Pick<AssignmentUnitSchema, "type">;
16
17
  type ConditionConfig = ConditionUnitConfig & Pick<ConditionUnitSchema, "type">;
17
18
  type IOConfig = IOUnitConfig & Pick<DataIOUnitSchema, "type">;
18
19
  type AssertionConfig = AssertionUnitConfig & Pick<AssertionUnitSchema, "type">;
20
+ type ErrorConfig = ErrorUnitConfig & Pick<ErrorUnitSchema, "type">;
19
21
  /** Subworkflow unit kinds supported by {@link UnitFactory.createDefaultSubworkflowUnit}. */
20
22
  export type DefaultSubworkflowUnitType = "execution" | "assignment" | "condition" | "io" | "assertion";
21
23
  export declare class UnitFactory {
@@ -23,9 +25,12 @@ export declare class UnitFactory {
23
25
  * Create a new subworkflow unit with fresh `flowchartId` and constructor defaults.
24
26
  * For execution units, pass the subworkflow (or parent) `application` JSON.
25
27
  */
26
- static createDefaultSubworkflowUnit(type: "execution", application: ExecutionUnitSchema["application"]): AnySubworkflowUnit;
27
- static createDefaultSubworkflowUnit(type: "assignment" | "condition" | "io" | "assertion"): AnySubworkflowUnit;
28
+ static createDefaultSubworkflowUnit(type: "execution", application: ApplicationSchema): ExecutionUnit;
29
+ static createDefaultSubworkflowUnit(type: "assignment"): AssignmentUnit;
30
+ static createDefaultSubworkflowUnit(type: "condition"): ConditionUnit;
31
+ static createDefaultSubworkflowUnit(type: "io"): IOUnit;
32
+ static createDefaultSubworkflowUnit(type: "assertion"): AssertionUnit;
28
33
  static createInWorkflow(config: WorkflowUnitSchema): AnyWorkflowUnit;
29
- static createInSubworkflow(config: ExcutionConfig | AssignmentConfig | ConditionConfig | IOConfig | AssertionConfig): AnySubworkflowUnit;
34
+ static createInSubworkflow(config: ExcutionConfig | AssignmentConfig | ConditionConfig | IOConfig | AssertionConfig | ErrorConfig): AnySubworkflowUnit;
30
35
  }
31
36
  export {};
@@ -8,6 +8,7 @@ const enums_1 = require("../enums");
8
8
  const AssertionUnit_1 = __importDefault(require("./AssertionUnit"));
9
9
  const AssignmentUnit_1 = __importDefault(require("./AssignmentUnit"));
10
10
  const ConditionUnit_1 = __importDefault(require("./ConditionUnit"));
11
+ const ErrorUnit_1 = __importDefault(require("./ErrorUnit"));
11
12
  const ExecutionUnit_1 = __importDefault(require("./ExecutionUnit"));
12
13
  const IOUnit_1 = __importDefault(require("./IOUnit"));
13
14
  const MapUnit_1 = __importDefault(require("./MapUnit"));
@@ -47,6 +48,8 @@ class UnitFactory {
47
48
  return new SubworkflowUnit_1.default(config);
48
49
  case enums_1.UnitType.reduce:
49
50
  return new ReduceUnit_1.default(config);
51
+ case enums_1.UnitType.error:
52
+ return new ErrorUnit_1.default(config);
50
53
  default:
51
54
  throw new Error(`Unknown unit type: ${config.type}`);
52
55
  }
@@ -63,6 +66,8 @@ class UnitFactory {
63
66
  return new IOUnit_1.default(config);
64
67
  case enums_1.UnitType.assertion:
65
68
  return new AssertionUnit_1.default(config);
69
+ case enums_1.UnitType.error:
70
+ return new ErrorUnit_1.default(config);
66
71
  default:
67
72
  throw new Error(`Unknown unit type: ${config.type}`);
68
73
  }
@@ -2,6 +2,7 @@ import AssertionUnit from "./AssertionUnit";
2
2
  import AssignmentUnit from "./AssignmentUnit";
3
3
  import BaseUnit from "./BaseUnit";
4
4
  import ConditionUnit from "./ConditionUnit";
5
+ import ErrorUnit from "./ErrorUnit";
5
6
  import ExecutionUnit from "./ExecutionUnit";
6
7
  import { UnitFactory } from "./factory";
7
8
  import IOUnit from "./IOUnit";
@@ -10,5 +11,5 @@ import ReduceUnit from "./ReduceUnit";
10
11
  import SubworkflowUnit from "./SubworkflowUnit";
11
12
  export type { ReduceUnitConfig } from "./ReduceUnit";
12
13
  export type { SubworkflowUnitConfig } from "./SubworkflowUnit";
13
- export { BaseUnit, AssertionUnit, AssignmentUnit, ConditionUnit, ExecutionUnit, IOUnit, MapUnit, ReduceUnit, SubworkflowUnit, UnitFactory, };
14
+ export { BaseUnit, AssertionUnit, AssignmentUnit, ConditionUnit, ErrorUnit, ExecutionUnit, IOUnit, MapUnit, ReduceUnit, SubworkflowUnit, UnitFactory, };
14
15
  export type { DefaultSubworkflowUnitType } from "./factory";
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UnitFactory = exports.SubworkflowUnit = exports.ReduceUnit = exports.MapUnit = exports.IOUnit = exports.ExecutionUnit = exports.ConditionUnit = exports.AssignmentUnit = exports.AssertionUnit = exports.BaseUnit = void 0;
6
+ exports.UnitFactory = exports.SubworkflowUnit = exports.ReduceUnit = exports.MapUnit = exports.IOUnit = exports.ExecutionUnit = exports.ErrorUnit = exports.ConditionUnit = exports.AssignmentUnit = exports.AssertionUnit = exports.BaseUnit = void 0;
7
7
  const AssertionUnit_1 = __importDefault(require("./AssertionUnit"));
8
8
  exports.AssertionUnit = AssertionUnit_1.default;
9
9
  const AssignmentUnit_1 = __importDefault(require("./AssignmentUnit"));
@@ -12,6 +12,8 @@ const BaseUnit_1 = __importDefault(require("./BaseUnit"));
12
12
  exports.BaseUnit = BaseUnit_1.default;
13
13
  const ConditionUnit_1 = __importDefault(require("./ConditionUnit"));
14
14
  exports.ConditionUnit = ConditionUnit_1.default;
15
+ const ErrorUnit_1 = __importDefault(require("./ErrorUnit"));
16
+ exports.ErrorUnit = ErrorUnit_1.default;
15
17
  const ExecutionUnit_1 = __importDefault(require("./ExecutionUnit"));
16
18
  exports.ExecutionUnit = ExecutionUnit_1.default;
17
19
  const factory_1 = require("./factory");
@@ -1,3 +1,4 @@
1
1
  export * as units from "./units";
2
2
  export * as workflow from "./workflow";
3
3
  export * as baseUnits from "./baseUnits";
4
+ export * as repair from "./repair";
@@ -33,7 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.baseUnits = exports.workflow = exports.units = void 0;
36
+ exports.repair = exports.baseUnits = exports.workflow = exports.units = void 0;
37
37
  exports.units = __importStar(require("./units"));
38
38
  exports.workflow = __importStar(require("./workflow"));
39
39
  exports.baseUnits = __importStar(require("./baseUnits"));
40
+ exports.repair = __importStar(require("./repair"));
@@ -0,0 +1,2 @@
1
+ import type { WorkflowSchema } from "../workflows/types";
2
+ export declare function repairWorkflow<T extends WorkflowSchema>(workflowData: T): T;