@mat3ra/wode 2025.11.3-0 → 2025.11.4-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.
@@ -40,9 +40,12 @@ class Subworkflow extends BaseSubworkflow {
40
40
  application: this.application.toJSON()
41
41
  })));
42
42
  }
43
- static generateSubworkflowId(...args) {
44
- args[0] = `subworkflow-${args[0]}`;
45
- if (this.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(...args);
43
+ static generateSubworkflowId(name, application = null, model = null, method = null) {
44
+ const appName = application ? application.name || application : "";
45
+ const modelInfo = model ? `${(model.toJSON?.() || model).type}-${(model.toJSON?.() || model).subtype || ""}` : "";
46
+ const methodInfo = method ? `${(method.toJSON?.() || method).type}-${(method.toJSON?.() || method).subtype || ""}` : "";
47
+ const seed = [`subworkflow-${name}`, appName, modelInfo, methodInfo].filter(p => p).join("-");
48
+ if (this.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(seed);
46
49
  return _utils.Utils.uuid.getUUID();
47
50
  }
48
51
  static get defaultConfig() {
@@ -80,7 +83,7 @@ class Subworkflow extends BaseSubworkflow {
80
83
  } = config;
81
84
  return new Cls({
82
85
  ...cleanConfig,
83
- _id: Cls.generateSubworkflowId(nameForIdGeneration),
86
+ _id: Cls.generateSubworkflowId(nameForIdGeneration, application, model, method),
84
87
  name,
85
88
  application: application.toJSON(),
86
89
  properties: _lodash.default.sortedUniq(_lodash.default.flatten(units.filter(x => x.resultNames).map(x => x.resultNames))),
@@ -205,7 +205,7 @@ class ExecutionUnit extends _base.BaseUnit {
205
205
  };
206
206
  }
207
207
  toJSON() {
208
- return this.clean({
208
+ const json = this.clean({
209
209
  ...super.toJSON(),
210
210
  executable: this.executable.toJSON(),
211
211
  flavor: this.flavor.toJSON(),
@@ -215,6 +215,10 @@ class ExecutionUnit extends _base.BaseUnit {
215
215
  // TODO: figure out the problem with storing context below
216
216
  // context: this.storedContext,
217
217
  });
218
+
219
+ // Remove results from executable
220
+ if (json.executable?.results) delete json.executable.results;
221
+ return json;
218
222
  }
219
223
  }
220
224
  exports.ExecutionUnit = ExecutionUnit;
@@ -30,7 +30,9 @@ const {
30
30
  class BaseWorkflow extends (0, _mixwith.mix)(_entity.NamedDefaultableRepetitionContextAndRenderInMemoryEntity).with(_ide.ComputedEntityMixin, _relaxation.RelaxationLogicMixin) {}
31
31
  class Workflow extends BaseWorkflow {
32
32
  constructor(config, _Subworkflow = _subworkflow.Subworkflow, _UnitFactory = _factory.UnitFactory, _Workflow = Workflow, _MapUnit = _units.MapUnit) {
33
- if (!config._id) config._id = Workflow.generateWorkflowId(config.name);
33
+ if (!config._id) {
34
+ config._id = Workflow.generateWorkflowId(config.name, config.properties, config.subworkflows, config.applicationName);
35
+ }
34
36
  super(config);
35
37
  this._Subworkflow = _Subworkflow;
36
38
  this._UnitFactory = _UnitFactory;
@@ -48,9 +50,11 @@ class Workflow extends BaseWorkflow {
48
50
  static get defaultConfig() {
49
51
  return _default.default;
50
52
  }
51
- static generateWorkflowId(...args) {
52
- args[0] = `workflow-${args[0]}`;
53
- if (this.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(...args);
53
+ static generateWorkflowId(name, properties = null, subworkflows = null, applicationName = null) {
54
+ const propsInfo = properties?.length ? properties.sort().join(",") : "";
55
+ const swInfo = subworkflows?.length ? subworkflows.map(sw => sw.name || "unknown").join(",") : "";
56
+ const seed = [`workflow-${name}`, applicationName, propsInfo, swInfo].filter(p => p).join("-");
57
+ if (this.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(seed);
54
58
  return _utils.Utils.uuid.getUUID();
55
59
  }
56
60
  static fromSubworkflow(subworkflow, ClsConstructor = Workflow) {
@@ -58,7 +62,8 @@ class Workflow extends BaseWorkflow {
58
62
  name: subworkflow.name,
59
63
  subworkflows: [subworkflow.toJSON()],
60
64
  units: (0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)([subworkflow.getAsUnit().toJSON()])),
61
- properties: subworkflow.properties
65
+ properties: subworkflow.properties,
66
+ applicationName: subworkflow.application.name
62
67
  };
63
68
  return new ClsConstructor(config);
64
69
  }
@@ -243,7 +248,7 @@ class Workflow extends BaseWorkflow {
243
248
  const workflowConfig = _default.default;
244
249
  // eslint-disable-next-line no-case-declarations
245
250
  const mapUnit = new this._MapUnit();
246
- workflowConfig._id = this._Workflow.generateWorkflowId(workflowConfig.name);
251
+ workflowConfig._id = this._Workflow.generateWorkflowId(workflowConfig.name, workflowConfig.properties, workflowConfig.subworkflows, this.applicationName);
247
252
  this.prop("workflows").push(workflowConfig);
248
253
  this._workflows = this.prop("workflows").map(x => new this._Workflow(x));
249
254
  mapUnit.setWorkflowId(workflowConfig._id);
@@ -258,7 +263,9 @@ class Workflow extends BaseWorkflow {
258
263
  }
259
264
  addMapUnit(mapUnit, mapWorkflow) {
260
265
  const mapWorkflowConfig = mapWorkflow.toJSON();
261
- if (!mapWorkflowConfig._id) mapWorkflowConfig._id = this._Workflow.generateWorkflowId(mapWorkflowConfig.name);
266
+ if (!mapWorkflowConfig._id) {
267
+ mapWorkflowConfig._id = this._Workflow.generateWorkflowId(mapWorkflowConfig.name, mapWorkflowConfig.properties, mapWorkflowConfig.subworkflows, mapWorkflow.applicationName || this.applicationName);
268
+ }
262
269
  mapUnit.setWorkflowId(mapWorkflowConfig._id);
263
270
  this.addUnit(mapUnit);
264
271
  this._json.workflows.push(mapWorkflowConfig);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/wode",
3
- "version": "2025.11.3-0",
3
+ "version": "2025.11.4-0",
4
4
  "description": "WOrkflow DEfinitions",
5
5
  "scripts": {
6
6
  "test": "nyc --reporter=text mocha --recursive --bail --require @babel/register/lib --require tests/setup.js tests",
@@ -50,9 +50,18 @@ export class Subworkflow extends BaseSubworkflow {
50
50
  );
51
51
  }
52
52
 
53
- static generateSubworkflowId(...args) {
54
- args[0] = `subworkflow-${args[0]}`;
55
- if (this.usePredefinedIds) return Utils.uuid.getUUIDFromNamespace(...args);
53
+ static generateSubworkflowId(name, application = null, model = null, method = null) {
54
+ const appName = application ? application.name || application : "";
55
+ const modelInfo = model
56
+ ? `${(model.toJSON?.() || model).type}-${(model.toJSON?.() || model).subtype || ""}`
57
+ : "";
58
+ const methodInfo = method
59
+ ? `${(method.toJSON?.() || method).type}-${(method.toJSON?.() || method).subtype || ""}`
60
+ : "";
61
+ const seed = [`subworkflow-${name}`, appName, modelInfo, methodInfo]
62
+ .filter((p) => p)
63
+ .join("-");
64
+ if (this.usePredefinedIds) return Utils.uuid.getUUIDFromNamespace(seed);
56
65
  return Utils.uuid.getUUID();
57
66
  }
58
67
 
@@ -96,7 +105,7 @@ export class Subworkflow extends BaseSubworkflow {
96
105
 
97
106
  return new Cls({
98
107
  ...cleanConfig,
99
- _id: Cls.generateSubworkflowId(nameForIdGeneration),
108
+ _id: Cls.generateSubworkflowId(nameForIdGeneration, application, model, method),
100
109
  name,
101
110
  application: application.toJSON(),
102
111
  properties: lodash.sortedUniq(
@@ -249,7 +249,7 @@ export class ExecutionUnit extends BaseUnit {
249
249
  }
250
250
 
251
251
  toJSON() {
252
- return this.clean({
252
+ const json = this.clean({
253
253
  ...super.toJSON(),
254
254
  executable: this.executable.toJSON(),
255
255
  flavor: this.flavor.toJSON(),
@@ -259,5 +259,10 @@ export class ExecutionUnit extends BaseUnit {
259
259
  // TODO: figure out the problem with storing context below
260
260
  // context: this.storedContext,
261
261
  });
262
+
263
+ // Remove results from executable
264
+ if (json.executable?.results) delete json.executable.results;
265
+
266
+ return json;
262
267
  }
263
268
  }
@@ -38,7 +38,14 @@ export class Workflow extends BaseWorkflow {
38
38
  _Workflow = Workflow,
39
39
  _MapUnit = MapUnit,
40
40
  ) {
41
- if (!config._id) config._id = Workflow.generateWorkflowId(config.name);
41
+ if (!config._id) {
42
+ config._id = Workflow.generateWorkflowId(
43
+ config.name,
44
+ config.properties,
45
+ config.subworkflows,
46
+ config.applicationName,
47
+ );
48
+ }
42
49
  super(config);
43
50
  this._Subworkflow = _Subworkflow;
44
51
  this._UnitFactory = _UnitFactory;
@@ -59,9 +66,20 @@ export class Workflow extends BaseWorkflow {
59
66
  return defaultWorkflowConfig;
60
67
  }
61
68
 
62
- static generateWorkflowId(...args) {
63
- args[0] = `workflow-${args[0]}`;
64
- if (this.usePredefinedIds) return Utils.uuid.getUUIDFromNamespace(...args);
69
+ static generateWorkflowId(
70
+ name,
71
+ properties = null,
72
+ subworkflows = null,
73
+ applicationName = null,
74
+ ) {
75
+ const propsInfo = properties?.length ? properties.sort().join(",") : "";
76
+ const swInfo = subworkflows?.length
77
+ ? subworkflows.map((sw) => sw.name || "unknown").join(",")
78
+ : "";
79
+ const seed = [`workflow-${name}`, applicationName, propsInfo, swInfo]
80
+ .filter((p) => p)
81
+ .join("-");
82
+ if (this.usePredefinedIds) return Utils.uuid.getUUIDFromNamespace(seed);
65
83
  return Utils.uuid.getUUID();
66
84
  }
67
85
 
@@ -71,6 +89,7 @@ export class Workflow extends BaseWorkflow {
71
89
  subworkflows: [subworkflow.toJSON()],
72
90
  units: setNextLinks(setUnitsHead([subworkflow.getAsUnit().toJSON()])),
73
91
  properties: subworkflow.properties,
92
+ applicationName: subworkflow.application.name,
74
93
  };
75
94
  return new ClsConstructor(config);
76
95
  }
@@ -292,7 +311,12 @@ export class Workflow extends BaseWorkflow {
292
311
  const workflowConfig = defaultWorkflowConfig;
293
312
  // eslint-disable-next-line no-case-declarations
294
313
  const mapUnit = new this._MapUnit();
295
- workflowConfig._id = this._Workflow.generateWorkflowId(workflowConfig.name);
314
+ workflowConfig._id = this._Workflow.generateWorkflowId(
315
+ workflowConfig.name,
316
+ workflowConfig.properties,
317
+ workflowConfig.subworkflows,
318
+ this.applicationName,
319
+ );
296
320
  this.prop("workflows").push(workflowConfig);
297
321
  this._workflows = this.prop("workflows").map((x) => new this._Workflow(x));
298
322
  mapUnit.setWorkflowId(workflowConfig._id);
@@ -308,8 +332,14 @@ export class Workflow extends BaseWorkflow {
308
332
 
309
333
  addMapUnit(mapUnit, mapWorkflow) {
310
334
  const mapWorkflowConfig = mapWorkflow.toJSON();
311
- if (!mapWorkflowConfig._id)
312
- mapWorkflowConfig._id = this._Workflow.generateWorkflowId(mapWorkflowConfig.name);
335
+ if (!mapWorkflowConfig._id) {
336
+ mapWorkflowConfig._id = this._Workflow.generateWorkflowId(
337
+ mapWorkflowConfig.name,
338
+ mapWorkflowConfig.properties,
339
+ mapWorkflowConfig.subworkflows,
340
+ mapWorkflow.applicationName || this.applicationName,
341
+ );
342
+ }
313
343
  mapUnit.setWorkflowId(mapWorkflowConfig._id);
314
344
  this.addUnit(mapUnit);
315
345
  this._json.workflows.push(mapWorkflowConfig);