@mat3ra/wode 2026.7.29-0 → 2026.8.13-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.
- package/dist/js/Subworkflow.d.ts +21 -20
- package/dist/js/Subworkflow.js +8 -7
- package/dist/js/Workflow.d.ts +11 -10
- package/dist/js/Workflow.js +7 -3
- package/dist/js/context/mixins/MaterialContextMixin.d.ts +1 -4
- package/dist/js/context/providers/CollinearMagnetizationDataManager.js +1 -1
- package/dist/js/context/providers/Hubbard/HubbardContextProvider.d.ts +6 -4
- package/dist/js/context/providers/Hubbard/HubbardContextProvider.js +12 -7
- package/dist/js/context/providers/NonCollinearMagnetizationDataManager.js +1 -1
- package/dist/js/context/providers/PointsGrid/PointsGridFormDataProvider.d.ts +6 -4
- package/dist/js/context/providers/PointsGrid/PointsGridFormDataProvider.js +10 -5
- package/dist/js/context/providers/PointsPath/PointsPathFormDataProvider.d.ts +3 -4
- package/dist/js/context/providers/PointsPath/PointsPathFormDataProvider.js +3 -2
- package/dist/js/context/providers/by_application/espresso/QEPWXInputDataManager.js +2 -1
- package/dist/js/context/providers/by_application/nwchem/NWChemInputDataManager.js +1 -1
- package/dist/js/generated/AssertionUnitSchemaMixin.d.ts +2 -2
- package/dist/js/generated/AssignmentUnitSchemaMixin.d.ts +2 -2
- package/dist/js/generated/BaseUnitSchemaMixin.d.ts +2 -2
- package/dist/js/generated/BaseUnitSchemaMixin.js +6 -18
- package/dist/js/generated/ConditionUnitSchemaMixin.d.ts +2 -2
- package/dist/js/generated/ErrorUnitSchemaMixin.d.ts +2 -2
- package/dist/js/generated/ExecutionUnitInputSchemaMixin.d.ts +2 -2
- package/dist/js/generated/ExecutionUnitSchemaMixin.d.ts +2 -2
- package/dist/js/generated/IOUnitSchemaMixin.d.ts +2 -2
- package/dist/js/generated/MapUnitSchemaMixin.d.ts +2 -2
- package/dist/js/generated/ReduceUnitSchemaMixin.d.ts +2 -2
- package/dist/js/generated/StatusTrackSchemaMixin.d.ts +5 -0
- package/dist/js/generated/{StatusSchemaMixin.js → StatusTrackSchemaMixin.js} +2 -8
- package/dist/js/generated/SubworkflowSchemaMixin.d.ts +2 -2
- package/dist/js/generated/SubworkflowUnitSchemaMixin.d.ts +2 -2
- package/dist/js/generated/WorkflowSchemaMixin.d.ts +2 -2
- package/dist/js/units/AssertionUnit.d.ts +4 -7
- package/dist/js/units/AssignmentUnit.d.ts +4 -7
- package/dist/js/units/BaseUnit.d.ts +13 -12
- package/dist/js/units/BaseUnit.js +14 -11
- package/dist/js/units/ConditionUnit.d.ts +4 -7
- package/dist/js/units/ErrorUnit.d.ts +4 -7
- package/dist/js/units/ExecutionUnit.d.ts +4 -7
- package/dist/js/units/ExecutionUnit.js +6 -6
- package/dist/js/units/ExecutionUnitInput.d.ts +3 -7
- package/dist/js/units/ExecutionUnitInput.js +12 -2
- package/dist/js/units/IOUnit.d.ts +4 -7
- package/dist/js/units/MapUnit.d.ts +4 -7
- package/dist/js/units/MapUnit.js +1 -1
- package/dist/js/units/ReduceUnit.d.ts +4 -7
- package/dist/js/units/SubworkflowUnit.d.ts +4 -7
- package/package.json +8 -9
- package/src/js/Subworkflow.ts +42 -32
- package/src/js/Workflow.ts +28 -16
- package/src/js/context/mixins/MaterialContextMixin.ts +1 -2
- package/src/js/context/providers/CollinearMagnetizationDataManager.ts +1 -1
- package/src/js/context/providers/Hubbard/HubbardContextProvider.ts +17 -8
- package/src/js/context/providers/NonCollinearMagnetizationDataManager.ts +1 -1
- package/src/js/context/providers/PointsGrid/PointsGridFormDataProvider.ts +14 -12
- package/src/js/context/providers/PointsPath/PointsPathFormDataProvider.ts +9 -6
- package/src/js/context/providers/by_application/espresso/QEPWXInputDataManager.ts +4 -3
- package/src/js/context/providers/by_application/nwchem/NWChemInputDataManager.ts +1 -1
- package/src/js/generated/AssertionUnitSchemaMixin.ts +11 -6
- package/src/js/generated/AssignmentUnitSchemaMixin.ts +12 -7
- package/src/js/generated/BaseUnitSchemaMixin.ts +17 -26
- package/src/js/generated/ConditionUnitSchemaMixin.ts +15 -10
- package/src/js/generated/ErrorUnitSchemaMixin.ts +7 -5
- package/src/js/generated/ExecutionUnitInputSchemaMixin.ts +12 -8
- package/src/js/generated/ExecutionUnitSchemaMixin.ts +14 -9
- package/src/js/generated/IOUnitSchemaMixin.ts +7 -7
- package/src/js/generated/MapUnitSchemaMixin.ts +6 -6
- package/src/js/generated/ReduceUnitSchemaMixin.ts +8 -6
- package/src/js/generated/StatusTrackSchemaMixin.ts +24 -0
- package/src/js/generated/SubworkflowSchemaMixin.ts +12 -10
- package/src/js/generated/SubworkflowUnitSchemaMixin.ts +9 -4
- package/src/js/generated/WorkflowSchemaMixin.ts +10 -10
- package/src/js/units/AssertionUnit.ts +3 -7
- package/src/js/units/AssignmentUnit.ts +4 -7
- package/src/js/units/BaseUnit.ts +39 -29
- package/src/js/units/ConditionUnit.ts +3 -7
- package/src/js/units/ErrorUnit.ts +3 -7
- package/src/js/units/ExecutionUnit.ts +10 -15
- package/src/js/units/ExecutionUnitInput.ts +16 -13
- package/src/js/units/IOUnit.ts +3 -7
- package/src/js/units/MapUnit.ts +4 -10
- package/src/js/units/ReduceUnit.ts +3 -7
- package/src/js/units/SubworkflowUnit.ts +3 -7
- package/dist/js/WorkflowDesignerMaterial.d.ts +0 -21
- package/dist/js/WorkflowDesignerMaterial.js +0 -26
- package/dist/js/generated/StatusSchemaMixin.d.ts +0 -5
- package/dist/js/repair/createErrorUnitData.d.ts +0 -3
- package/dist/js/repair/createErrorUnitData.js +0 -25
- package/dist/js/repair/formatRepairReason.d.ts +0 -1
- package/dist/js/repair/formatRepairReason.js +0 -22
- package/dist/js/repair/types.d.ts +0 -16
- package/dist/js/repair/types.js +0 -2
- package/dist/js/subworkflows/convergence/enums.js +0 -15
- package/dist/js/subworkflows/convergence/factory.js +0 -36
- package/dist/js/subworkflows/subworkflow.js +0 -285
- package/dist/js/utils/subworkflow.d.ts +0 -2
- package/dist/js/utils/subworkflow.js +0 -29
- package/dist/js/utils/underscoreStringSlugify.d.ts +0 -6
- package/dist/js/utils/underscoreStringSlugify.js +0 -32
- package/dist/js/utils.js +0 -87
- package/dist/js/workflows/workflow.d.ts +0 -4404
- package/dist/js/workflows/workflow.js +0 -315
- package/src/js/generated/StatusSchemaMixin.ts +0 -28
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Subworkflow = void 0;
|
|
7
|
-
var _ade = require("@mat3ra/ade");
|
|
8
|
-
var _entity = require("@mat3ra/code/dist/js/entity");
|
|
9
|
-
var _hash = require("@mat3ra/code/dist/js/entity/mixins/hash");
|
|
10
|
-
var _mode = require("@mat3ra/mode");
|
|
11
|
-
var _utils = require("@mat3ra/utils");
|
|
12
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
-
var _mixwith = require("mixwith");
|
|
14
|
-
var _underscore = _interopRequireDefault(require("underscore"));
|
|
15
|
-
var _enums = require("../enums");
|
|
16
|
-
var _units = require("../units");
|
|
17
|
-
var _utils2 = require("../utils");
|
|
18
|
-
var _convergence = require("./convergence");
|
|
19
|
-
var _enums2 = require("./convergence/enums");
|
|
20
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
22
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
23
|
-
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); }
|
|
24
|
-
/* eslint max-classes-per-file:0 */
|
|
25
|
-
class BaseSubworkflow extends (0, _mixwith.mix)(_entity.NamedDefaultableRepetitionImportantSettingsInMemoryEntity).with(_convergence.ConvergenceMixin, _entity.ContextAndRenderFieldsMixin, _hash.HashedEntityMixin) {}
|
|
26
|
-
class Subworkflow extends BaseSubworkflow {
|
|
27
|
-
constructor(config, _Application = _ade.Application, _ModelFactory = _mode.ModelFactory, _UnitFactory = _units.UnitFactory) {
|
|
28
|
-
super(config);
|
|
29
|
-
this._Application = _Application;
|
|
30
|
-
this._ModelFactory = _ModelFactory;
|
|
31
|
-
this._UnitFactory = _UnitFactory;
|
|
32
|
-
this.initialize();
|
|
33
|
-
}
|
|
34
|
-
initialize() {
|
|
35
|
-
this._application = new this._Application(this.prop("application"));
|
|
36
|
-
this._model = this._ModelFactory.create({
|
|
37
|
-
...this.prop("model"),
|
|
38
|
-
application: this.prop("application")
|
|
39
|
-
});
|
|
40
|
-
this._units = (0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(this.prop("units", [])), this.id).map(cfg => this._UnitFactory.create(Object.assign(cfg, {
|
|
41
|
-
application: this.application.toJSON()
|
|
42
|
-
})));
|
|
43
|
-
}
|
|
44
|
-
static generateSubworkflowId(name, application = null, model = null, method = null) {
|
|
45
|
-
const appName = application ? application.name || application : "";
|
|
46
|
-
const modelInfo = model ? `${(model.toJSON?.() || model).type}-${(model.toJSON?.() || model).subtype || ""}` : "";
|
|
47
|
-
const methodInfo = method ? `${(method.toJSON?.() || method).type}-${(method.toJSON?.() || method).subtype || ""}` : "";
|
|
48
|
-
const seed = [`subworkflow-${name}`, appName, modelInfo, methodInfo].filter(p => p).join("-");
|
|
49
|
-
if (this.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(seed);
|
|
50
|
-
return _utils.Utils.uuid.getUUID();
|
|
51
|
-
}
|
|
52
|
-
static get defaultConfig() {
|
|
53
|
-
const defaultName = "New Subworkflow";
|
|
54
|
-
return {
|
|
55
|
-
_id: this.generateSubworkflowId(defaultName),
|
|
56
|
-
name: defaultName,
|
|
57
|
-
application: _ade.Application.defaultConfig,
|
|
58
|
-
model: _mode.Model.defaultConfig,
|
|
59
|
-
properties: [],
|
|
60
|
-
units: []
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/*
|
|
65
|
-
* @returns {SubworkflowUnit}
|
|
66
|
-
*/
|
|
67
|
-
getAsUnit() {
|
|
68
|
-
return this._UnitFactory.create({
|
|
69
|
-
type: _enums.UNIT_TYPES.subworkflow,
|
|
70
|
-
_id: this.id,
|
|
71
|
-
name: this.name
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/*
|
|
76
|
-
* @summary Used to generate initial application tree, therefore omit setting application.
|
|
77
|
-
*/
|
|
78
|
-
static fromArguments(application, model, method, name, units = [], config = {}, Cls = Subworkflow) {
|
|
79
|
-
const nameForIdGeneration = config.attributes?.name || name;
|
|
80
|
-
const {
|
|
81
|
-
functions,
|
|
82
|
-
attributes,
|
|
83
|
-
...cleanConfig
|
|
84
|
-
} = config;
|
|
85
|
-
|
|
86
|
-
// Set the method on the model so it can be properly serialized
|
|
87
|
-
model.setMethod(method);
|
|
88
|
-
return new Cls({
|
|
89
|
-
...cleanConfig,
|
|
90
|
-
_id: Cls.generateSubworkflowId(nameForIdGeneration, application, model, method),
|
|
91
|
-
name,
|
|
92
|
-
application: application.toJSON(),
|
|
93
|
-
properties: _lodash.default.sortedUniq(_lodash.default.flatten(units.filter(x => x.resultNames).map(x => x.resultNames))),
|
|
94
|
-
model: {
|
|
95
|
-
...model.toJSON(),
|
|
96
|
-
method: method.toJSON()
|
|
97
|
-
},
|
|
98
|
-
units: units.map(unit => unit.toJSON ? unit.toJSON() : unit)
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
get application() {
|
|
102
|
-
return this._application;
|
|
103
|
-
}
|
|
104
|
-
setApplication(application) {
|
|
105
|
-
// TODO: adjust the logic above to take into account whether units need re-rendering after version change etc.
|
|
106
|
-
// reset units if application name changes
|
|
107
|
-
const previousApplicationName = this.application.name;
|
|
108
|
-
this._application = application;
|
|
109
|
-
if (previousApplicationName !== application.name) {
|
|
110
|
-
// TODO: figure out how to set a default unit per new application instead of removing all
|
|
111
|
-
this.setUnits([]);
|
|
112
|
-
} else {
|
|
113
|
-
// propagate new application version to all units
|
|
114
|
-
this.units.filter(unit => typeof unit.setApplication === "function").forEach(unit => unit.setApplication(application, true));
|
|
115
|
-
}
|
|
116
|
-
this.setProp("application", application.toJSON());
|
|
117
|
-
// set model to the default one for the application selected
|
|
118
|
-
this.setModel(this._ModelFactory.createFromApplication({
|
|
119
|
-
application: this.prop("application")
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
get model() {
|
|
123
|
-
return this._model;
|
|
124
|
-
}
|
|
125
|
-
setModel(model) {
|
|
126
|
-
this._model = model;
|
|
127
|
-
}
|
|
128
|
-
get units() {
|
|
129
|
-
return this._units;
|
|
130
|
-
}
|
|
131
|
-
setUnits(units) {
|
|
132
|
-
this._units = units;
|
|
133
|
-
}
|
|
134
|
-
toJSON(exclude = []) {
|
|
135
|
-
return {
|
|
136
|
-
...super.toJSON(exclude),
|
|
137
|
-
model: this.model.toJSON(),
|
|
138
|
-
units: this.units.map(x => x.toJSON()),
|
|
139
|
-
...(this.compute ? {
|
|
140
|
-
compute: this.compute
|
|
141
|
-
} : {}) // {"compute": null } won't pass esse validation
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
get contextProviders() {
|
|
145
|
-
const unitsWithContextProviders = this.units.filter(u => u.allContextProviders && u.allContextProviders.length);
|
|
146
|
-
const allContextProviders = _underscore.default.flatten(unitsWithContextProviders.map(u => u.allContextProviders));
|
|
147
|
-
const subworkflowContextProviders = allContextProviders.filter(p => p.isSubworkflowContextProvider);
|
|
148
|
-
return _underscore.default.uniq(subworkflowContextProviders, p => p.name);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Extracts a reduced version of the entity config to be stored inside redux state.
|
|
153
|
-
* This is used to track changes to context, monitors, properties, etc. when multiple materials are in state.
|
|
154
|
-
*/
|
|
155
|
-
extractReducedExternalDependentConfig() {
|
|
156
|
-
return {
|
|
157
|
-
id: this.id,
|
|
158
|
-
context: this.context || {},
|
|
159
|
-
units: this.units.map(unit => unit.extractReducedExternalDependentConfig())
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Applies the reduced config obtained from extractReducedExternalDependentConfig on the entity.
|
|
165
|
-
*/
|
|
166
|
-
applyReducedExternalDependentConfig(config) {
|
|
167
|
-
this.context = config.context || {};
|
|
168
|
-
this.units.forEach(unit => {
|
|
169
|
-
const unitConfig = (config.units || []).find(c => c.id === unit.flowchartId);
|
|
170
|
-
unit.applyReducedExternalDependentConfig(unitConfig || {});
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
get contextFromAssignmentUnits() {
|
|
174
|
-
const ctx = {};
|
|
175
|
-
this.units.filter(u => u.type === _enums.UNIT_TYPES.assignment).forEach(u => {
|
|
176
|
-
ctx[u.operand] = u.value;
|
|
177
|
-
});
|
|
178
|
-
return ctx;
|
|
179
|
-
}
|
|
180
|
-
render(context = {}) {
|
|
181
|
-
const ctx = {
|
|
182
|
-
...context,
|
|
183
|
-
application: this.application,
|
|
184
|
-
methodData: this.model.Method.data,
|
|
185
|
-
model: this.model.toJSON(),
|
|
186
|
-
// context below is assembled from context providers and passed to units to override theirs
|
|
187
|
-
...this.context,
|
|
188
|
-
subworkflowContext: this.contextFromAssignmentUnits
|
|
189
|
-
};
|
|
190
|
-
this.units.forEach(u => u.render(ctx));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* TODO: reuse workflow function instead
|
|
195
|
-
* @param unit {Unit}
|
|
196
|
-
* @param head {Boolean}
|
|
197
|
-
* @param index {Number}
|
|
198
|
-
*/
|
|
199
|
-
addUnit(unit, index = -1) {
|
|
200
|
-
const {
|
|
201
|
-
units
|
|
202
|
-
} = this;
|
|
203
|
-
if (units.length === 0) {
|
|
204
|
-
unit.head = true;
|
|
205
|
-
this.setUnits([unit]);
|
|
206
|
-
} else {
|
|
207
|
-
if (index >= 0) units.splice(index, 0, unit);else units.push(unit);
|
|
208
|
-
this.setUnits((0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(units)));
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
removeUnit(flowchartId) {
|
|
212
|
-
const previousUnit = this.units.find(x => x.next === flowchartId);
|
|
213
|
-
if (previousUnit) previousUnit.unsetProp("next");
|
|
214
|
-
// TODO: remove the setNextLinks and setUnitsHead and handle the logic via flowchart designer
|
|
215
|
-
this.setUnits((0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(this.units.filter(x => x.flowchartId !== flowchartId))));
|
|
216
|
-
}
|
|
217
|
-
get properties() {
|
|
218
|
-
return _lodash.default.flatten(this.units.map(x => x.resultNames));
|
|
219
|
-
}
|
|
220
|
-
getUnit(flowchartId) {
|
|
221
|
-
return this.units.find(x => x.flowchartId === flowchartId);
|
|
222
|
-
}
|
|
223
|
-
unitIndex(flowchartId) {
|
|
224
|
-
return _lodash.default.findIndex(this.units, unit => {
|
|
225
|
-
return unit.flowchartId === flowchartId;
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
replaceUnit(index, unit) {
|
|
229
|
-
this.units[index] = unit;
|
|
230
|
-
this.setUnits((0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(this.units)));
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// eslint-disable-next-line class-methods-use-this
|
|
234
|
-
get scopeVariables() {
|
|
235
|
-
return [_enums2.ConvergenceParameterName.N_k, _enums2.ConvergenceParameterName.N_k_nonuniform];
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// eslint-disable-next-line class-methods-use-this
|
|
239
|
-
get scalarResults() {
|
|
240
|
-
return ["total_energy", "pressure"];
|
|
241
|
-
}
|
|
242
|
-
get isMultiMaterial() {
|
|
243
|
-
return this.prop("isMultiMaterial", false);
|
|
244
|
-
}
|
|
245
|
-
get isDraft() {
|
|
246
|
-
return this.prop("isDraft", false);
|
|
247
|
-
}
|
|
248
|
-
setIsDraft(bool) {
|
|
249
|
-
return this.setProp("isDraft", bool);
|
|
250
|
-
}
|
|
251
|
-
get methodData() {
|
|
252
|
-
return this.model.Method.data;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* @summary
|
|
257
|
-
* Returns object for hashing of the workflow. Meaningful fields are units, app and model.
|
|
258
|
-
* units must be sorted topologically before hashing (already sorted).
|
|
259
|
-
*/
|
|
260
|
-
getHashObject() {
|
|
261
|
-
const config = this.toJSON();
|
|
262
|
-
const meaningfulFields = {
|
|
263
|
-
application: new _ade.Application(config.application).calculateHash(),
|
|
264
|
-
model: new _mode.Model(config.model).calculateHash(),
|
|
265
|
-
units: _underscore.default.map(this.units, u => u.calculateHash()).join()
|
|
266
|
-
};
|
|
267
|
-
return meaningfulFields;
|
|
268
|
-
}
|
|
269
|
-
findUnitById(id) {
|
|
270
|
-
// TODO: come back and refactor after converting flowchartId to id
|
|
271
|
-
return this.units.find(u => u.flowchartId === id);
|
|
272
|
-
}
|
|
273
|
-
findUnitKeyById(id) {
|
|
274
|
-
const index = this.units.findIndex(u => u.flowchartId === id);
|
|
275
|
-
return `units.${index}`;
|
|
276
|
-
}
|
|
277
|
-
findUnitWithTag(tag) {
|
|
278
|
-
return this.units.find(unit => unit.tags.includes(tag));
|
|
279
|
-
}
|
|
280
|
-
get hasConvergence() {
|
|
281
|
-
return !!this.convergenceParam && !!this.convergenceResult && !!this.convergenceSeries;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
exports.Subworkflow = Subworkflow;
|
|
285
|
-
_defineProperty(Subworkflow, "usePredefinedIds", false);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateHash = calculateHash;
|
|
4
|
-
const mode_1 = require("@mat3ra/mode");
|
|
5
|
-
const utils_1 = require("@mat3ra/utils");
|
|
6
|
-
const units_1 = require("./units");
|
|
7
|
-
function calculateModelHash(config) {
|
|
8
|
-
const modelInstance = mode_1.ModelFactory.create({
|
|
9
|
-
...config.model,
|
|
10
|
-
application: config.application,
|
|
11
|
-
});
|
|
12
|
-
const { model } = config;
|
|
13
|
-
if (modelInstance.Method.omitInHashCalculation) {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
|
-
const { data: _data, ...method } = model.method;
|
|
16
|
-
return utils_1.Utils.hash.calculateHashFromObject({
|
|
17
|
-
...model,
|
|
18
|
-
method,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return utils_1.Utils.hash.calculateHashFromObject(model);
|
|
22
|
-
}
|
|
23
|
-
function calculateHash(config) {
|
|
24
|
-
return utils_1.Utils.hash.calculateHashFromObject({
|
|
25
|
-
application: config.application,
|
|
26
|
-
model: calculateModelHash(config),
|
|
27
|
-
units: config.units.map(units_1.calculateHash).join(),
|
|
28
|
-
});
|
|
29
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Same behavior as `underscore.string` slugify (v3.3.x): cleanDiacritics, replace
|
|
3
|
-
* non-word chars except whitespace and hyphen, lowercase, dasherize, trim hyphens.
|
|
4
|
-
* @see https://github.com/esamattis/underscore.string/blob/master/slugify.js
|
|
5
|
-
*/
|
|
6
|
-
export declare function underscoreStringSlugify(value: unknown): string;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Same behavior as `underscore.string` slugify (v3.3.x): cleanDiacritics, replace
|
|
4
|
-
* non-word chars except whitespace and hyphen, lowercase, dasherize, trim hyphens.
|
|
5
|
-
* @see https://github.com/esamattis/underscore.string/blob/master/slugify.js
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.underscoreStringSlugify = underscoreStringSlugify;
|
|
9
|
-
function cleanDiacritics(str) {
|
|
10
|
-
let from = "ąàáäâãåæăćčĉęèéëêĝĥìíïîĵłľńňòóöőôõðøśșşšŝťțţŭùúüűûñÿýçżźž";
|
|
11
|
-
let to = "aaaaaaaaaccceeeeeghiiiijllnnoooooooossssstttuuuuuunyyczzz";
|
|
12
|
-
from += from.toUpperCase();
|
|
13
|
-
to += to.toUpperCase();
|
|
14
|
-
const toChars = to.split("");
|
|
15
|
-
from += "ß";
|
|
16
|
-
toChars.push("ss");
|
|
17
|
-
return str.replace(/./g, (ch) => {
|
|
18
|
-
const i = from.indexOf(ch);
|
|
19
|
-
return i === -1 ? ch : toChars[i];
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function dasherize(str) {
|
|
23
|
-
return str
|
|
24
|
-
.trim()
|
|
25
|
-
.replace(/([A-Z])/g, "-$1")
|
|
26
|
-
.replace(/[-_\s]+/g, "-")
|
|
27
|
-
.toLowerCase();
|
|
28
|
-
}
|
|
29
|
-
function underscoreStringSlugify(value) {
|
|
30
|
-
const str = value == null ? "" : String(value);
|
|
31
|
-
return dasherize(cleanDiacritics(str).replace(/[^\w\s-]/g, "-").toLowerCase()).replace(/^-+|-+$/g, "");
|
|
32
|
-
}
|
package/dist/js/utils.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.applyConfig = applyConfig;
|
|
7
|
-
exports.findUnit = findUnit;
|
|
8
|
-
exports.setNextLinks = setNextLinks;
|
|
9
|
-
exports.setUnitsHead = setUnitsHead;
|
|
10
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
/**
|
|
13
|
-
* @summary set the head of an array of units
|
|
14
|
-
* @param units
|
|
15
|
-
* @returns {Unit[]}
|
|
16
|
-
*/
|
|
17
|
-
function setUnitsHead(units) {
|
|
18
|
-
if (units.length > 0) {
|
|
19
|
-
units[0].head = true;
|
|
20
|
-
_lodash.default.tail(units).map(x => x.head = false);
|
|
21
|
-
}
|
|
22
|
-
return units;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @summary Re-establishes the linked `next => flowchartId` logic in an array of units
|
|
27
|
-
* @params units {Unit[]}
|
|
28
|
-
* @returns units {Unit[]}
|
|
29
|
-
*/
|
|
30
|
-
function setNextLinks(units) {
|
|
31
|
-
const flowchartIds = units.map(u => u.flowchartId);
|
|
32
|
-
for (let i = 0; i < units.length - 1; i++) {
|
|
33
|
-
if (!units[i].next || !flowchartIds.includes(units[i].next)) {
|
|
34
|
-
// newly added units don't have next set yet, or removed units created broken links => fix it
|
|
35
|
-
units[i].next = units[i + 1].flowchartId;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return units;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @summary Apply configuration data to an object
|
|
43
|
-
* @param obj {*} object / class containing methods or attributes to be set
|
|
44
|
-
* @param config { functions: {}, attributes: {} } functions to call and attributes to set
|
|
45
|
-
* @param callBuild {boolean} if true; call build between applying functions and attributes
|
|
46
|
-
* @returns {*} updated object
|
|
47
|
-
*/
|
|
48
|
-
function applyConfig({
|
|
49
|
-
obj,
|
|
50
|
-
config = {},
|
|
51
|
-
callBuild = false
|
|
52
|
-
}) {
|
|
53
|
-
const {
|
|
54
|
-
functions = {},
|
|
55
|
-
attributes = {}
|
|
56
|
-
} = config;
|
|
57
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
58
|
-
for (const [func, args] of Object.entries(functions)) {
|
|
59
|
-
// eslint-disable-next-line no-nested-ternary
|
|
60
|
-
if (obj[func]) {
|
|
61
|
-
if (args) obj[func](args);else obj[func]();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const modified = callBuild ? obj.build() : obj;
|
|
65
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
66
|
-
for (const [key, values] of Object.entries(attributes)) {
|
|
67
|
-
modified[key] = values;
|
|
68
|
-
}
|
|
69
|
-
return modified;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @summary Safely extract unit object from subworkflow data
|
|
74
|
-
* @param subworkflowData {Object} subworkflow data
|
|
75
|
-
* @param index {number} index of subworkflow unit
|
|
76
|
-
* @param type {string} type of subworkflow unit
|
|
77
|
-
* @returns {Object|null} subworkflow unit object (not a unit class instance!)
|
|
78
|
-
*/
|
|
79
|
-
function findUnit({
|
|
80
|
-
subworkflowData,
|
|
81
|
-
index,
|
|
82
|
-
type
|
|
83
|
-
}) {
|
|
84
|
-
const unit = subworkflowData.units[index];
|
|
85
|
-
if (unit.type !== type) throw new Error("findUnit() error: unit type does not match!");
|
|
86
|
-
return unit;
|
|
87
|
-
}
|