@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
@@ -0,0 +1,140 @@
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
+ exports.repairWorkflow = repairWorkflow;
7
+ const in_memory_1 = require("@mat3ra/code/dist/js/entity/in_memory");
8
+ const utils_1 = require("@mat3ra/utils");
9
+ const enums_1 = require("../enums");
10
+ const Subworkflow_1 = __importDefault(require("../Subworkflow"));
11
+ const ConditionUnit_1 = __importDefault(require("../units/ConditionUnit"));
12
+ const ExecutionUnit_1 = __importDefault(require("../units/ExecutionUnit"));
13
+ function toErrorUnitSchema(unitData, error) {
14
+ var _a, _b, _c, _d;
15
+ let reasonPayload;
16
+ if (error instanceof in_memory_1.EntityError && error.details) {
17
+ reasonPayload = {
18
+ error: error.details.error,
19
+ json: unitData,
20
+ };
21
+ }
22
+ else if (error instanceof Error) {
23
+ reasonPayload = {
24
+ error: { message: error.message, name: error.name },
25
+ json: unitData,
26
+ };
27
+ }
28
+ else {
29
+ reasonPayload = {
30
+ error,
31
+ json: unitData,
32
+ };
33
+ }
34
+ return {
35
+ results: [],
36
+ preProcessors: [],
37
+ postProcessors: [],
38
+ monitors: [],
39
+ name: (_a = unitData.name) !== null && _a !== void 0 ? _a : enums_1.UnitType.error,
40
+ type: enums_1.UnitType.error,
41
+ status: enums_1.UnitStatus.error,
42
+ flowchartId: (_b = unitData.flowchartId) !== null && _b !== void 0 ? _b : utils_1.Utils.uuid.getUUID(),
43
+ reason: JSON.stringify(reasonPayload),
44
+ next: (_c = unitData.next) !== null && _c !== void 0 ? _c : "",
45
+ head: (_d = unitData.head) !== null && _d !== void 0 ? _d : false,
46
+ };
47
+ }
48
+ function repairExecutionUnit(unitData) {
49
+ try {
50
+ return new ExecutionUnit_1.default(unitData).toJSON();
51
+ }
52
+ catch (error) {
53
+ return toErrorUnitSchema(unitData, error);
54
+ }
55
+ }
56
+ function repairConditionUnit(unitData) {
57
+ try {
58
+ return new ConditionUnit_1.default(unitData).toJSON();
59
+ }
60
+ catch (error) {
61
+ return toErrorUnitSchema(unitData, error);
62
+ }
63
+ }
64
+ function getSubworkflowValidationError(subworkflow) {
65
+ // Two checks, same order as the old isValid() path (construct + validate), but split so we
66
+ // keep AJV errors when hydration would fail first:
67
+ // 1. validateData — JSON Schema on raw persisted subworkflow (no Application/ModelFactory/units).
68
+ // Surfaces structured AJV errors (e.g. missing model) before the constructor runs.
69
+ // 2. new Subworkflow().validate() — hydration (app, model, units) then schema on the instance.
70
+ // Catches schema-valid JSON that still cannot be built (unknown model, bad units, etc.).
71
+ try {
72
+ Subworkflow_1.default.validateData({ ...subworkflow });
73
+ new Subworkflow_1.default(subworkflow).validate();
74
+ return null;
75
+ }
76
+ catch (error) {
77
+ if (error instanceof in_memory_1.EntityError || error instanceof Error) {
78
+ return error;
79
+ }
80
+ return new Error(String(error));
81
+ }
82
+ }
83
+ function repairSubworkflow(subworkflowData) {
84
+ const units = subworkflowData.units.map((unit) => {
85
+ if (unit.type === enums_1.UnitType.execution) {
86
+ return repairExecutionUnit(unit);
87
+ }
88
+ if (unit.type === enums_1.UnitType.condition) {
89
+ return repairConditionUnit(unit);
90
+ }
91
+ return unit;
92
+ });
93
+ return { ...subworkflowData, units };
94
+ }
95
+ function repairWorkflow(workflowData) {
96
+ const subworkflows = workflowData.subworkflows.map((subworkflow) => {
97
+ return repairSubworkflow(subworkflow);
98
+ });
99
+ const invalidSubworkflows = subworkflows
100
+ .map((subworkflow) => {
101
+ const error = getSubworkflowValidationError(subworkflow);
102
+ return error ? { subworkflow, error } : null;
103
+ })
104
+ .filter((entry) => entry !== null);
105
+ const units = workflowData.units.map((unit) => {
106
+ const invalidEntry = invalidSubworkflows.find(({ subworkflow }) => subworkflow._id === unit._id);
107
+ if (invalidEntry) {
108
+ const { subworkflow, error } = invalidEntry;
109
+ const errorUnit = toErrorUnitSchema(unit, error);
110
+ const reasonPayload = {
111
+ ...JSON.parse(errorUnit.reason),
112
+ json: { unit, subworkflow },
113
+ };
114
+ return {
115
+ ...errorUnit,
116
+ _id: unit._id,
117
+ name: unit.name || errorUnit.name,
118
+ flowchartId: unit.flowchartId,
119
+ reason: JSON.stringify(reasonPayload),
120
+ preProcessors: unit.preProcessors || [],
121
+ postProcessors: unit.postProcessors || [],
122
+ monitors: unit.monitors || [],
123
+ results: unit.results || [],
124
+ };
125
+ }
126
+ return unit;
127
+ });
128
+ const validSubworkflows = subworkflows.filter((subworkflow) => {
129
+ return !invalidSubworkflows.some(({ subworkflow: invalid }) => invalid._id === subworkflow._id);
130
+ });
131
+ const workflows = workflowData.workflows.map((nested) => {
132
+ return repairWorkflow(nested);
133
+ });
134
+ return {
135
+ ...workflowData,
136
+ subworkflows: validSubworkflows,
137
+ workflows,
138
+ units,
139
+ };
140
+ }
@@ -1,3 +1,3 @@
1
- import type { WorkflowSchema } from "@mat3ra/esse/dist/js/types";
1
+ import type { WorkflowSchema } from "./types";
2
2
  declare const defaultWorkflowConfig: WorkflowSchema;
3
3
  export default defaultWorkflowConfig;
@@ -0,0 +1,4 @@
1
+ import type { WorkflowSchema as EsseWorkflowSchema } from "@mat3ra/esse/dist/js/types";
2
+ export type WorkflowSchema = EsseWorkflowSchema & {
3
+ workflows: WorkflowSchema[];
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/wode",
3
- "version": "2026.6.5-0",
3
+ "version": "2026.6.18-0",
4
4
  "description": "WOrkflow DEfinitions",
5
5
  "scripts": {
6
6
  "test": "mocha --recursive --bail --require ts-node/register 'tests/js/**/*.ts'",
@@ -42,7 +42,7 @@
42
42
  "@exabyte-io/eslint-config": "2025.5.13-0",
43
43
  "@mat3ra/ade": "2026.5.28-0",
44
44
  "@mat3ra/code": "2026.5.27-0",
45
- "@mat3ra/esse": "2026.5.28-0",
45
+ "@mat3ra/esse": "2026.6.16-0",
46
46
  "@mat3ra/ide": "2026.5.28-0",
47
47
  "@mat3ra/made": "2026.5.28-0",
48
48
  "@mat3ra/mode": "2026.5.29-1",
@@ -50,6 +50,8 @@
50
50
  "@mat3ra/standata": "2026.5.28-0",
51
51
  "@mat3ra/tsconfig": "^2024.6.3-0",
52
52
  "@mat3ra/utils": "2025.9.20-0",
53
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
54
+ "@typescript-eslint/parser": "^5.62.0",
53
55
  "@types/nunjucks": "^3.2.6",
54
56
  "chai": "^4.3.4",
55
57
  "eslint": "^7.32.0",
@@ -76,7 +78,7 @@
76
78
  "peerDependencies": {
77
79
  "@mat3ra/ade": "*",
78
80
  "@mat3ra/code": "*",
79
- "@mat3ra/esse": "*",
81
+ "@mat3ra/esse": "file:../esse/mat3ra-esse-0.0.0.tgz",
80
82
  "@mat3ra/ide": "*",
81
83
  "@mat3ra/made": "*",
82
84
  "@mat3ra/mode": "*",
@@ -100,13 +100,18 @@ class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
100
100
 
101
101
  static get defaultConfig() {
102
102
  const defaultName = "New Subworkflow";
103
+ const application = new ApplicationRegistry().getDefaultApplication();
104
+
105
+ if (!application) {
106
+ throw new Error("No default application found");
107
+ }
108
+
103
109
  return {
104
110
  _id: Utils.uuid.getUUID(),
105
111
  name: defaultName,
106
- application: new ApplicationRegistry().getDefaultApplication(),
107
- // TODO: confirm if `functional` is required field. If not, update ESSE schema
112
+ application,
108
113
  // `Model.defaultConfig` from @mat3ra/mode may omit `functional`; ESSE subworkflow schema requires it once schemas are registered.
109
- model: { ...Model.defaultConfig, functional: "pbe" },
114
+ model: { ...Model.defaultConfig, functional: "pbe" as const },
110
115
  properties: [],
111
116
  units: [],
112
117
  };
@@ -274,7 +279,7 @@ class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
274
279
  return `units.${index}`;
275
280
  }
276
281
 
277
- private findUnitWithTag(tag: UnitTag) {
282
+ private findAssignmentUnitWithTag(tag: UnitTag) {
278
283
  return this.units
279
284
  .filter((unit) => unit.type === UnitType.assignment)
280
285
  .find((unit) => unit.tags?.includes(tag));
@@ -285,29 +290,35 @@ class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
285
290
  }
286
291
 
287
292
  get convergenceParam() {
288
- return this.findUnitWithTag(UnitTag.hasConvergenceParam)?.operand;
293
+ return this.findAssignmentUnitWithTag(UnitTag.hasConvergenceParam)?.operand;
289
294
  }
290
295
 
291
296
  get convergenceResult() {
292
- return this.findUnitWithTag(UnitTag.hasConvergenceResult)?.operand;
297
+ return this.findAssignmentUnitWithTag(UnitTag.hasConvergenceResult)?.operand;
293
298
  }
294
299
 
295
300
  convergenceSeries(scopeTrack: JobSchema["scopeTrack"]) {
296
- if (!this.hasConvergence || !scopeTrack?.length) {
301
+ const { convergenceParam, convergenceResult } = this;
302
+
303
+ if (!convergenceParam || !convergenceResult || !scopeTrack?.length) {
297
304
  return [];
298
305
  }
299
306
 
300
307
  let prevResult: unknown;
308
+ // `scopeTrack` stores per-repetition diffs: each item only carries the global/local keys
309
+ // that were added or changed in that repetition (see UnitEndpoint.saveUnitStatus). Accumulate
310
+ // the global scope across items so each iteration reads the full scope, not just its delta.
311
+ // This also stays correct for legacy full-snapshot scopeTrack data, since re-applying a full
312
+ // snapshot is idempotent.
313
+ const accumulatedGlobal: Record<string, unknown> = {};
301
314
 
302
315
  return scopeTrack
303
316
  .map((scopeItem, i) => {
317
+ Object.assign(accumulatedGlobal, scopeItem.scope?.global);
304
318
  return {
305
319
  x: i,
306
- // TODO: fix types
307
- // @ts-ignore
308
- param: scopeItem.scope?.global[this.convergenceParam],
309
- // @ts-ignore
310
- y: scopeItem.scope?.global[this.convergenceResult],
320
+ param: accumulatedGlobal[convergenceParam],
321
+ y: accumulatedGlobal[convergenceResult],
311
322
  };
312
323
  })
313
324
  .filter(({ y }) => {
@@ -15,11 +15,7 @@ import { namedEntityMixin } from "@mat3ra/code/dist/js/entity/mixins/NamedEntity
15
15
  import { Taggable, taggableMixin } from "@mat3ra/code/dist/js/entity/mixins/TaggableMixin";
16
16
  import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface";
17
17
  import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
18
- import type {
19
- ApplicationSchema,
20
- SubworkflowSchema,
21
- WorkflowSchema,
22
- } from "@mat3ra/esse/dist/js/types";
18
+ import type { ApplicationSchema, SubworkflowSchema } from "@mat3ra/esse/dist/js/types";
23
19
  import { ComputedEntityMixin, computedEntityMixin } from "@mat3ra/ide/dist/js/compute";
24
20
  import type { Material } from "@mat3ra/made";
25
21
  import type { MetaPropertyHolder } from "@mat3ra/prode";
@@ -45,6 +41,7 @@ import {
45
41
  getUsedModels,
46
42
  } from "./utils/workflow";
47
43
  import defaultWorkflowConfig from "./workflows/default";
44
+ import type { WorkflowSchema } from "./workflows/types";
48
45
 
49
46
  interface Workflow
50
47
  extends Defaultable,
@@ -9,7 +9,7 @@ export type MaterialContextMixin = {
9
9
  readonly isMaterialCreatedDefault: boolean;
10
10
  readonly isMaterialUpdated: boolean;
11
11
  material: OrderedMaterial;
12
- extraData?: { materialHash: string };
12
+ extraData?: { materialHash?: string };
13
13
  initMaterialContextMixin(externalContext: MaterialExternalContext): void;
14
14
  updateMaterialHash(): void;
15
15
  };
package/src/js/enums.ts CHANGED
@@ -11,6 +11,7 @@ export const UNIT_TYPES = {
11
11
  subworkflow: "subworkflow",
12
12
  io: "io",
13
13
  assertion: "assertion",
14
+ error: "error",
14
15
  } as const;
15
16
 
16
17
  export enum UnitType {
@@ -24,6 +25,7 @@ export enum UnitType {
24
25
  subworkflow = "subworkflow",
25
26
  io = "io",
26
27
  assertion = "assertion",
28
+ error = "error",
27
29
  }
28
30
 
29
31
  export enum UnitTag {
@@ -0,0 +1,28 @@
1
+ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { ErrorUnitMixinSchema } from "@mat3ra/esse/dist/js/types";
3
+
4
+ export type ErrorUnitSchemaMixin = ErrorUnitMixinSchema;
5
+
6
+ export type ErrorUnitInMemoryEntity = InMemoryEntity & ErrorUnitSchemaMixin;
7
+
8
+ export function errorUnitSchemaMixin<T extends InMemoryEntity>(
9
+ item: InMemoryEntity,
10
+ ): asserts item is T & ErrorUnitSchemaMixin {
11
+ // @ts-expect-error
12
+ const properties: InMemoryEntity & ErrorUnitSchemaMixin = {
13
+ get type() {
14
+ return this.prop<ErrorUnitMixinSchema["type"]>("type");
15
+ },
16
+ set type(value: ErrorUnitMixinSchema["type"]) {
17
+ this.setProp("type", value);
18
+ },
19
+ get reason() {
20
+ return this.requiredProp<ErrorUnitMixinSchema["reason"]>("reason");
21
+ },
22
+ set reason(value: ErrorUnitMixinSchema["reason"]) {
23
+ this.setProp("reason", value);
24
+ },
25
+ };
26
+
27
+ Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
28
+ }
package/src/js/index.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  AssignmentUnit,
8
8
  BaseUnit,
9
9
  ConditionUnit,
10
+ ErrorUnit,
10
11
  ExecutionUnit,
11
12
  IOUnit,
12
13
  MapUnit,
@@ -21,6 +22,7 @@ import Workflow from "./Workflow";
21
22
  export type { OrderedMaterial } from "./context/mixins/MaterialContextMixin";
22
23
  export type { MaterialsSet } from "./context/mixins/MaterialsSetContextMixin";
23
24
  export type { AnySubworkflowUnit, DefaultSubworkflowUnitType } from "./units/factory";
25
+ export { repairWorkflow } from "./utils/repair";
24
26
  export {
25
27
  Subworkflow,
26
28
  Workflow,
@@ -33,6 +35,7 @@ export {
33
35
  AssertionUnit,
34
36
  AssignmentUnit,
35
37
  ConditionUnit,
38
+ ErrorUnit,
36
39
  IOUnit,
37
40
  MapUnit,
38
41
  ReduceUnit,
@@ -0,0 +1,42 @@
1
+ import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
2
+ import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface";
3
+ import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
4
+ import type { ErrorUnitSchema } from "@mat3ra/esse/dist/js/types";
5
+
6
+ import { UnitStatus, UnitType } from "../enums";
7
+ import { type ErrorUnitSchemaMixin, errorUnitSchemaMixin } from "../generated/ErrorUnitSchemaMixin";
8
+ import BaseUnit from "./BaseUnit";
9
+
10
+ type Schema = ErrorUnitSchema;
11
+ type Base = typeof BaseUnit<Schema> & Constructor<ErrorUnitSchemaMixin>;
12
+
13
+ export type ErrorUnitConfig = Partial<Schema>;
14
+
15
+ class ErrorUnit extends (BaseUnit as Base) implements Schema {
16
+ declare toJSON: () => Schema & AnyObject;
17
+
18
+ declare _json: Schema & AnyObject;
19
+
20
+ static get jsonSchema() {
21
+ return JSONSchemasInterface.getSchemaById("workflow/unit/error");
22
+ }
23
+
24
+ constructor(config: ErrorUnitConfig) {
25
+ const schema = {
26
+ name: UnitType.error,
27
+ results: [],
28
+ preProcessors: [],
29
+ postProcessors: [],
30
+ monitors: [],
31
+ reason: "",
32
+ ...config,
33
+ type: UnitType.error as Schema["type"],
34
+ status: config.status ?? UnitStatus.error,
35
+ };
36
+ super(schema);
37
+ }
38
+ }
39
+
40
+ errorUnitSchemaMixin(ErrorUnit.prototype);
41
+
42
+ export default ErrorUnit;
@@ -1,8 +1,10 @@
1
1
  import type {
2
+ ApplicationSchema,
2
3
  AssertionUnitSchema,
3
4
  AssignmentUnitSchema,
4
5
  ConditionUnitSchema,
5
6
  DataIOUnitSchema,
7
+ ErrorUnitSchema,
6
8
  ExecutionUnitSchema,
7
9
  MapUnitSchema,
8
10
  ReduceUnitSchema,
@@ -14,35 +16,43 @@ import { UnitType } from "../enums";
14
16
  import AssertionUnit, { type AssertionUnitConfig } from "./AssertionUnit";
15
17
  import AssignmentUnit, { type AssignmentUnitConfig } from "./AssignmentUnit";
16
18
  import ConditionUnit, { type ConditionUnitConfig } from "./ConditionUnit";
19
+ import ErrorUnit, { type ErrorUnitConfig } from "./ErrorUnit";
17
20
  import ExecutionUnit, { type ExecutionUnitConfig } from "./ExecutionUnit";
18
21
  import IOUnit, { type IOUnitConfig } from "./IOUnit";
19
22
  import MapUnit from "./MapUnit";
20
23
  import ReduceUnit from "./ReduceUnit";
21
24
  import SubworkflowUnit from "./SubworkflowUnit";
22
25
 
23
- export type AnyWorkflowUnit = MapUnit | SubworkflowUnit | ReduceUnit;
26
+ export type AnyWorkflowUnit = MapUnit | SubworkflowUnit | ReduceUnit | ErrorUnit;
24
27
 
25
- export type AnyWorkflowUnitSchema = MapUnitSchema | SubworkflowUnitSchema | ReduceUnitSchema;
28
+ export type AnyWorkflowUnitSchema =
29
+ | MapUnitSchema
30
+ | SubworkflowUnitSchema
31
+ | ReduceUnitSchema
32
+ | ErrorUnitSchema;
26
33
 
27
34
  export type AnySubworkflowUnit =
28
35
  | ExecutionUnit
29
36
  | AssignmentUnit
30
37
  | ConditionUnit
31
38
  | IOUnit
32
- | AssertionUnit;
39
+ | AssertionUnit
40
+ | ErrorUnit;
33
41
 
34
42
  export type AnySubworkflowUnitSchema =
35
43
  | ExecutionUnitSchema
36
44
  | AssertionUnitSchema
37
45
  | AssignmentUnitSchema
38
46
  | ConditionUnitSchema
39
- | DataIOUnitSchema;
47
+ | DataIOUnitSchema
48
+ | ErrorUnitSchema;
40
49
 
41
50
  type ExcutionConfig = ExecutionUnitConfig & Pick<ExecutionUnitSchema, "type">;
42
51
  type AssignmentConfig = AssignmentUnitConfig & Pick<AssignmentUnitSchema, "type">;
43
52
  type ConditionConfig = ConditionUnitConfig & Pick<ConditionUnitSchema, "type">;
44
53
  type IOConfig = IOUnitConfig & Pick<DataIOUnitSchema, "type">;
45
54
  type AssertionConfig = AssertionUnitConfig & Pick<AssertionUnitSchema, "type">;
55
+ type ErrorConfig = ErrorUnitConfig & Pick<ErrorUnitSchema, "type">;
46
56
 
47
57
  /** Subworkflow unit kinds supported by {@link UnitFactory.createDefaultSubworkflowUnit}. */
48
58
  export type DefaultSubworkflowUnitType =
@@ -59,16 +69,20 @@ export class UnitFactory {
59
69
  */
60
70
  static createDefaultSubworkflowUnit(
61
71
  type: "execution",
62
- application: ExecutionUnitSchema["application"],
63
- ): AnySubworkflowUnit;
72
+ application: ApplicationSchema,
73
+ ): ExecutionUnit;
64
74
 
65
- static createDefaultSubworkflowUnit(
66
- type: "assignment" | "condition" | "io" | "assertion",
67
- ): AnySubworkflowUnit;
75
+ static createDefaultSubworkflowUnit(type: "assignment"): AssignmentUnit;
76
+
77
+ static createDefaultSubworkflowUnit(type: "condition"): ConditionUnit;
78
+
79
+ static createDefaultSubworkflowUnit(type: "io"): IOUnit;
80
+
81
+ static createDefaultSubworkflowUnit(type: "assertion"): AssertionUnit;
68
82
 
69
83
  static createDefaultSubworkflowUnit(
70
84
  type: DefaultSubworkflowUnitType,
71
- application?: ExecutionUnitSchema["application"],
85
+ application?: ApplicationSchema,
72
86
  ): AnySubworkflowUnit {
73
87
  if (type === "execution") {
74
88
  if (application === undefined) {
@@ -105,13 +119,21 @@ export class UnitFactory {
105
119
  return new SubworkflowUnit(config);
106
120
  case UnitType.reduce:
107
121
  return new ReduceUnit(config);
122
+ case UnitType.error:
123
+ return new ErrorUnit(config);
108
124
  default:
109
125
  throw new Error(`Unknown unit type: ${config.type}`);
110
126
  }
111
127
  }
112
128
 
113
129
  static createInSubworkflow(
114
- config: ExcutionConfig | AssignmentConfig | ConditionConfig | IOConfig | AssertionConfig,
130
+ config:
131
+ | ExcutionConfig
132
+ | AssignmentConfig
133
+ | ConditionConfig
134
+ | IOConfig
135
+ | AssertionConfig
136
+ | ErrorConfig,
115
137
  ): AnySubworkflowUnit {
116
138
  switch (config.type) {
117
139
  case UnitType.execution:
@@ -124,6 +146,8 @@ export class UnitFactory {
124
146
  return new IOUnit(config);
125
147
  case UnitType.assertion:
126
148
  return new AssertionUnit(config);
149
+ case UnitType.error:
150
+ return new ErrorUnit(config);
127
151
  default:
128
152
  throw new Error(`Unknown unit type: ${config.type}`);
129
153
  }
@@ -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";
@@ -16,6 +17,7 @@ export {
16
17
  AssertionUnit,
17
18
  AssignmentUnit,
18
19
  ConditionUnit,
20
+ ErrorUnit,
19
21
  ExecutionUnit,
20
22
  IOUnit,
21
23
  MapUnit,
@@ -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";