Skip to content

Commit b16ce7d

Browse files
authored
Merge pull request #135 from Exabyte-io/feature/SOF-7843
Feature/sof 7843
2 parents 866cbef + 9537b9b commit b16ce7d

File tree

15 files changed

+369
-1003
lines changed

15 files changed

+369
-1003
lines changed

dist/js/subworkflows/subworkflow.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
66
exports.Subworkflow = void 0;
77
var _ade = require("@mat3ra/ade");
88
var _entity = require("@mat3ra/code/dist/js/entity");
9+
var _hash = require("@mat3ra/code/dist/js/entity/mixins/hash");
910
var _mode = require("@mat3ra/mode");
1011
var _utils = require("@mat3ra/utils");
1112
var _lodash = _interopRequireDefault(require("lodash"));
@@ -20,7 +21,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
2021
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
2122
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2223
/* eslint max-classes-per-file:0 */
23-
class BaseSubworkflow extends (0, _mixwith.mix)(_entity.NamedDefaultableRepetitionImportantSettingsInMemoryEntity).with(_convergence.ConvergenceMixin, _entity.ContextAndRenderFieldsMixin) {}
24+
class BaseSubworkflow extends (0, _mixwith.mix)(_entity.NamedDefaultableRepetitionImportantSettingsInMemoryEntity).with(_convergence.ConvergenceMixin, _entity.ContextAndRenderFieldsMixin, _hash.HashedEntityMixin) {}
2425
class Subworkflow extends BaseSubworkflow {
2526
constructor(config, _Application = _ade.Application, _ModelFactory = _mode.ModelFactory, _UnitFactory = _units.UnitFactory) {
2627
super(config);
@@ -251,25 +252,18 @@ class Subworkflow extends BaseSubworkflow {
251252
}
252253

253254
/**
254-
* @summary Calculates hash of the subworkflow. Meaningful fields are units, app and model.
255+
* @summary
256+
* Returns object for hashing of the workflow. Meaningful fields are units, app and model.
255257
* units must be sorted topologically before hashing (already sorted).
256258
*/
257-
calculateHash() {
259+
getHashObject() {
258260
const config = this.toJSON();
259261
const meaningfulFields = {
260-
application: _utils.Utils.specific.removeTimestampableKeysFromConfig(config.application),
261-
model: this._calculateModelHash(),
262+
application: new _ade.Application(config.application).calculateHash(),
263+
model: new _mode.Model(config.model).calculateHash(),
262264
units: _underscore.default.map(this.units, u => u.calculateHash()).join()
263265
};
264-
return _utils.Utils.hash.calculateHashFromObject(meaningfulFields);
265-
}
266-
_calculateModelHash() {
267-
const {
268-
model
269-
} = this.toJSON();
270-
// ignore empty data object
271-
if (this.model.Method.omitInHashCalculation) delete model.method.data;
272-
return _utils.Utils.hash.calculateHashFromObject(model);
266+
return meaningfulFields;
273267
}
274268
findUnitById(id) {
275269
// TODO: come back and refactor after converting flowchartId to id

dist/js/workflows/workflow.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
55
});
66
exports.Workflow = void 0;
77
var _entity = require("@mat3ra/code/dist/js/entity");
8+
var _hash = require("@mat3ra/code/dist/js/entity/mixins/hash");
89
var _workflow = _interopRequireDefault(require("@mat3ra/esse/dist/js/schema/workflow.json"));
910
var _ide = require("@mat3ra/ide");
1011
var _mode = require("@mat3ra/mode");
@@ -27,7 +28,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
2728
const {
2829
MODEL_NAMES
2930
} = _mode.tree;
30-
class BaseWorkflow extends (0, _mixwith.mix)(_entity.NamedDefaultableRepetitionContextAndRenderInMemoryEntity).with(_ide.ComputedEntityMixin, _relaxation.RelaxationLogicMixin) {}
31+
class BaseWorkflow extends (0, _mixwith.mix)(_entity.NamedDefaultableRepetitionContextAndRenderInMemoryEntity).with(_ide.ComputedEntityMixin, _relaxation.RelaxationLogicMixin, _hash.HashedEntityMixin) {}
3132
class Workflow extends BaseWorkflow {
3233
constructor(config, _Subworkflow = _subworkflow.Subworkflow, _UnitFactory = _factory.UnitFactory, _Workflow = Workflow, _MapUnit = _units.MapUnit) {
3334
if (!config._id) {
@@ -292,16 +293,16 @@ class Workflow extends BaseWorkflow {
292293
}
293294

294295
/**
295-
* @summary Calculates hash of the workflow. Meaningful fields are units and subworkflows.
296+
* @summary
297+
* Returns object for hashing of the workflow. Meaningful fields are units and subworkflows.
296298
* units and subworkflows must be sorted topologically before hashing (already sorted).
297299
*/
298-
calculateHash() {
299-
const meaningfulFields = {
300+
getHashObject() {
301+
return {
300302
units: _underscore.default.map(this.units, u => u.calculateHash()).join(),
301303
subworkflows: _underscore.default.map(this.subworkflows, sw => sw.calculateHash()).join(),
302304
workflows: _underscore.default.map(this.workflows, w => w.calculateHash()).join()
303305
};
304-
return _utils.Utils.hash.calculateHashFromObject(meaningfulFields);
305306
}
306307
}
307308
exports.Workflow = Workflow;

0 commit comments

Comments
 (0)