@mat3ra/wode 2026.6.16-0 → 2026.6.19-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.
@@ -736,14 +736,14 @@ declare class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
736
736
  reason: string;
737
737
  } | undefined;
738
738
  findUnitKeyById(id: string): string;
739
- private findUnitWithTag;
739
+ private findAssignmentUnitWithTag;
740
740
  get hasConvergence(): boolean;
741
741
  get convergenceParam(): string | undefined;
742
742
  get convergenceResult(): string | undefined;
743
743
  convergenceSeries(scopeTrack: JobSchema["scopeTrack"]): {
744
744
  x: number;
745
- param: any;
746
- y: any;
745
+ param: unknown;
746
+ y: unknown;
747
747
  }[];
748
748
  updateMethodData(materials: Material[], metaProperties: MetaPropertyHolder[]): void;
749
749
  addConvergence({ parameter, parameterInitial, parameterIncrement, result, resultInitial, condition, operator, tolerance, maxOccurrences, externalContext, }: ConvergenceConfig): void;
@@ -186,7 +186,7 @@ class Subworkflow extends entity_1.InMemoryEntity {
186
186
  const index = this.units.findIndex((u) => u.flowchartId === id);
187
187
  return `units.${index}`;
188
188
  }
189
- findUnitWithTag(tag) {
189
+ findAssignmentUnitWithTag(tag) {
190
190
  return this.units
191
191
  .filter((unit) => unit.type === enums_1.UnitType.assignment)
192
192
  .find((unit) => { var _a; return (_a = unit.tags) === null || _a === void 0 ? void 0 : _a.includes(tag); });
@@ -196,27 +196,32 @@ class Subworkflow extends entity_1.InMemoryEntity {
196
196
  }
197
197
  get convergenceParam() {
198
198
  var _a;
199
- 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;
200
200
  }
201
201
  get convergenceResult() {
202
202
  var _a;
203
- 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;
204
204
  }
205
205
  convergenceSeries(scopeTrack) {
206
- 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)) {
207
208
  return [];
208
209
  }
209
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 = {};
210
217
  return scopeTrack
211
218
  .map((scopeItem, i) => {
212
- var _a, _b;
219
+ var _a;
220
+ Object.assign(accumulatedGlobal, (_a = scopeItem.scope) === null || _a === void 0 ? void 0 : _a.global);
213
221
  return {
214
222
  x: i,
215
- // TODO: fix types
216
- // @ts-ignore
217
- param: (_a = scopeItem.scope) === null || _a === void 0 ? void 0 : _a.global[this.convergenceParam],
218
- // @ts-ignore
219
- y: (_b = scopeItem.scope) === null || _b === void 0 ? void 0 : _b.global[this.convergenceResult],
223
+ param: accumulatedGlobal[convergenceParam],
224
+ y: accumulatedGlobal[convergenceResult],
220
225
  };
221
226
  })
222
227
  .filter(({ y }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/wode",
3
- "version": "2026.6.16-0",
3
+ "version": "2026.6.19-0",
4
4
  "description": "WOrkflow DEfinitions",
5
5
  "scripts": {
6
6
  "test": "mocha --recursive --bail --require ts-node/register 'tests/js/**/*.ts'",
@@ -279,7 +279,7 @@ class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
279
279
  return `units.${index}`;
280
280
  }
281
281
 
282
- private findUnitWithTag(tag: UnitTag) {
282
+ private findAssignmentUnitWithTag(tag: UnitTag) {
283
283
  return this.units
284
284
  .filter((unit) => unit.type === UnitType.assignment)
285
285
  .find((unit) => unit.tags?.includes(tag));
@@ -290,29 +290,35 @@ class Subworkflow extends InMemoryEntity implements SubworkflowSchema {
290
290
  }
291
291
 
292
292
  get convergenceParam() {
293
- return this.findUnitWithTag(UnitTag.hasConvergenceParam)?.operand;
293
+ return this.findAssignmentUnitWithTag(UnitTag.hasConvergenceParam)?.operand;
294
294
  }
295
295
 
296
296
  get convergenceResult() {
297
- return this.findUnitWithTag(UnitTag.hasConvergenceResult)?.operand;
297
+ return this.findAssignmentUnitWithTag(UnitTag.hasConvergenceResult)?.operand;
298
298
  }
299
299
 
300
300
  convergenceSeries(scopeTrack: JobSchema["scopeTrack"]) {
301
- if (!this.hasConvergence || !scopeTrack?.length) {
301
+ const { convergenceParam, convergenceResult } = this;
302
+
303
+ if (!convergenceParam || !convergenceResult || !scopeTrack?.length) {
302
304
  return [];
303
305
  }
304
306
 
305
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> = {};
306
314
 
307
315
  return scopeTrack
308
316
  .map((scopeItem, i) => {
317
+ Object.assign(accumulatedGlobal, scopeItem.scope?.global);
309
318
  return {
310
319
  x: i,
311
- // TODO: fix types
312
- // @ts-ignore
313
- param: scopeItem.scope?.global[this.convergenceParam],
314
- // @ts-ignore
315
- y: scopeItem.scope?.global[this.convergenceResult],
320
+ param: accumulatedGlobal[convergenceParam],
321
+ y: accumulatedGlobal[convergenceResult],
316
322
  };
317
323
  })
318
324
  .filter(({ y }) => {