@defra/forms-model 3.0.9 → 3.0.11
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/browser/components/component-types.js +201 -219
- package/dist/browser/components/component-types.js.map +1 -1
- package/dist/browser/components/conditional-component-types.js +9 -27
- package/dist/browser/components/conditional-component-types.js.map +1 -1
- package/dist/browser/components/enums.js +27 -45
- package/dist/browser/components/enums.js.map +1 -1
- package/dist/browser/components/index.js +3 -35
- package/dist/browser/components/index.js.map +1 -1
- package/dist/browser/components/types.js +1 -15
- package/dist/browser/conditions/condition-abstract.js +42 -60
- package/dist/browser/conditions/condition-abstract.js.map +1 -1
- package/dist/browser/conditions/condition-field.js +23 -41
- package/dist/browser/conditions/condition-field.js.map +1 -1
- package/dist/browser/conditions/condition-group-def.js +23 -42
- package/dist/browser/conditions/condition-group-def.js.map +1 -1
- package/dist/browser/conditions/condition-group.js +43 -61
- package/dist/browser/conditions/condition-group.js.map +1 -1
- package/dist/browser/conditions/condition-model.js +185 -196
- package/dist/browser/conditions/condition-model.js.map +1 -1
- package/dist/browser/conditions/condition-operators.js +103 -124
- package/dist/browser/conditions/condition-operators.js.map +1 -1
- package/dist/browser/conditions/condition-ref.js +29 -47
- package/dist/browser/conditions/condition-ref.js.map +1 -1
- package/dist/browser/conditions/condition-value-abstract.js +19 -37
- package/dist/browser/conditions/condition-value-abstract.js.map +1 -1
- package/dist/browser/conditions/condition-value-registration.js +15 -34
- package/dist/browser/conditions/condition-value-registration.js.map +1 -1
- package/dist/browser/conditions/condition-values.js +98 -118
- package/dist/browser/conditions/condition-values.js.map +1 -1
- package/dist/browser/conditions/condition.js +36 -51
- package/dist/browser/conditions/condition.js.map +1 -1
- package/dist/browser/conditions/enums.js +5 -23
- package/dist/browser/conditions/enums.js.map +1 -1
- package/dist/browser/conditions/helpers.js +6 -25
- package/dist/browser/conditions/helpers.js.map +1 -1
- package/dist/browser/conditions/index.js +10 -143
- package/dist/browser/conditions/index.js.map +1 -1
- package/dist/browser/conditions/inline-condition-model.js +372 -394
- package/dist/browser/conditions/inline-condition-model.js.map +1 -1
- package/dist/browser/conditions/inline-condition-operators.js +103 -124
- package/dist/browser/conditions/inline-condition-operators.js.map +1 -1
- package/dist/browser/conditions/inline-condition-values.js +123 -145
- package/dist/browser/conditions/inline-condition-values.js.map +1 -1
- package/dist/browser/conditions/types.js +1 -15
- package/dist/browser/conditions/types.js.map +1 -1
- package/dist/browser/data-model/conditions-wrapper.js +27 -45
- package/dist/browser/data-model/conditions-wrapper.js.map +1 -1
- package/dist/browser/data-model/enums.js +6 -24
- package/dist/browser/data-model/enums.js.map +1 -1
- package/dist/browser/data-model/index.js +3 -35
- package/dist/browser/data-model/index.js.map +1 -1
- package/dist/browser/data-model/input-wrapper.js +28 -46
- package/dist/browser/data-model/input-wrapper.js.map +1 -1
- package/dist/browser/data-model/types.js +7 -25
- package/dist/browser/data-model/types.js.map +1 -1
- package/dist/browser/form/form-configuration.js +16 -35
- package/dist/browser/form/form-configuration.js.map +1 -1
- package/dist/browser/form/index.js +1 -23
- package/dist/browser/form/index.js.map +1 -1
- package/dist/browser/index.js +8 -97
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/migration/index.js +1 -23
- package/dist/browser/migration/index.js.map +1 -1
- package/dist/browser/migration/migration.0-2.js +42 -60
- package/dist/browser/migration/migration.0-2.js.map +1 -1
- package/dist/browser/migration/migration.1-2.js +83 -99
- package/dist/browser/migration/migration.1-2.js.map +1 -1
- package/dist/browser/migration/types.js +1 -15
- package/dist/browser/migration/whichMigrations.js +20 -36
- package/dist/browser/migration/whichMigrations.js.map +1 -1
- package/dist/browser/schema/index.js +1 -29
- package/dist/browser/schema/index.js.map +1 -1
- package/dist/browser/schema/schema.js +231 -249
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/utils/helpers.js +22 -43
- package/dist/browser/utils/helpers.js.map +1 -1
- package/dist/browser/utils/logger.js +24 -43
- package/dist/browser/utils/logger.js.map +1 -1
- package/dist/module/components/component-types.js +1 -5
- package/dist/module/components/component-types.js.map +1 -1
- package/dist/module/components/conditional-component-types.js +1 -5
- package/dist/module/components/conditional-component-types.js.map +1 -1
- package/dist/module/components/enums.js +1 -5
- package/dist/module/components/enums.js.map +1 -1
- package/dist/module/components/index.js +3 -24
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/types.js +2 -1
- package/dist/module/conditions/condition-abstract.js +3 -8
- package/dist/module/conditions/condition-abstract.js.map +1 -1
- package/dist/module/conditions/condition-field.js +3 -8
- package/dist/module/conditions/condition-field.js.map +1 -1
- package/dist/module/conditions/condition-group-def.js +1 -6
- package/dist/module/conditions/condition-group-def.js.map +1 -1
- package/dist/module/conditions/condition-group.js +4 -9
- package/dist/module/conditions/condition-group.js.map +1 -1
- package/dist/module/conditions/condition-model.js +20 -25
- package/dist/module/conditions/condition-model.js.map +1 -1
- package/dist/module/conditions/condition-operators.js +15 -23
- package/dist/module/conditions/condition-operators.js.map +1 -1
- package/dist/module/conditions/condition-ref.js +2 -7
- package/dist/module/conditions/condition-ref.js.map +1 -1
- package/dist/module/conditions/condition-value-abstract.js +3 -8
- package/dist/module/conditions/condition-value-abstract.js.map +1 -1
- package/dist/module/conditions/condition-value-registration.js +1 -6
- package/dist/module/conditions/condition-value-registration.js.map +1 -1
- package/dist/module/conditions/condition-values.js +12 -20
- package/dist/module/conditions/condition-values.js.map +1 -1
- package/dist/module/conditions/condition.js +9 -14
- package/dist/module/conditions/condition.js.map +1 -1
- package/dist/module/conditions/enums.js +1 -5
- package/dist/module/conditions/enums.js.map +1 -1
- package/dist/module/conditions/helpers.js +2 -7
- package/dist/module/conditions/helpers.js.map +1 -1
- package/dist/module/conditions/index.js +10 -139
- package/dist/module/conditions/index.js.map +1 -1
- package/dist/module/conditions/inline-condition-model.js +15 -26
- package/dist/module/conditions/inline-condition-model.js.map +1 -1
- package/dist/module/conditions/inline-condition-operators.js +15 -23
- package/dist/module/conditions/inline-condition-operators.js.map +1 -1
- package/dist/module/conditions/inline-condition-values.js +9 -17
- package/dist/module/conditions/inline-condition-values.js.map +1 -1
- package/dist/module/conditions/types.js +2 -1
- package/dist/module/conditions/types.js.map +1 -1
- package/dist/module/data-model/conditions-wrapper.js +3 -8
- package/dist/module/data-model/conditions-wrapper.js.map +1 -1
- package/dist/module/data-model/enums.js +1 -5
- package/dist/module/data-model/enums.js.map +1 -1
- package/dist/module/data-model/index.js +3 -24
- package/dist/module/data-model/index.js.map +1 -1
- package/dist/module/data-model/input-wrapper.js +3 -8
- package/dist/module/data-model/input-wrapper.js.map +1 -1
- package/dist/module/data-model/types.js +1 -5
- package/dist/module/data-model/types.js.map +1 -1
- package/dist/module/form/form-configuration.js +1 -6
- package/dist/module/form/form-configuration.js.map +1 -1
- package/dist/module/form/index.js +1 -10
- package/dist/module/form/index.js.map +1 -1
- package/dist/module/index.js +8 -91
- package/dist/module/index.js.map +1 -1
- package/dist/module/migration/index.js +1 -10
- package/dist/module/migration/index.js.map +1 -1
- package/dist/module/migration/migration.0-2.js +1 -5
- package/dist/module/migration/migration.0-2.js.map +1 -1
- package/dist/module/migration/migration.1-2.js +3 -6
- package/dist/module/migration/migration.1-2.js.map +1 -1
- package/dist/module/migration/types.js +2 -1
- package/dist/module/migration/whichMigrations.js +5 -9
- package/dist/module/migration/whichMigrations.js.map +1 -1
- package/dist/module/schema/index.js +1 -16
- package/dist/module/schema/index.js.map +1 -1
- package/dist/module/schema/schema.js +163 -167
- package/dist/module/schema/schema.js.map +1 -1
- package/dist/module/utils/helpers.js +5 -13
- package/dist/module/utils/helpers.js.map +1 -1
- package/dist/module/utils/logger.js +1 -6
- package/dist/module/utils/logger.js.map +1 -1
- package/dist/types/components/component-types.d.ts +1 -1
- package/dist/types/components/component-types.d.ts.map +1 -1
- package/dist/types/components/conditional-component-types.d.ts +1 -1
- package/dist/types/components/conditional-component-types.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +3 -3
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/conditions/condition-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-field.d.ts +1 -1
- package/dist/types/conditions/condition-field.d.ts.map +1 -1
- package/dist/types/conditions/condition-group-def.d.ts +2 -2
- package/dist/types/conditions/condition-group-def.d.ts.map +1 -1
- package/dist/types/conditions/condition-group.d.ts +2 -2
- package/dist/types/conditions/condition-group.d.ts.map +1 -1
- package/dist/types/conditions/condition-model.d.ts +5 -5
- package/dist/types/conditions/condition-model.d.ts.map +1 -1
- package/dist/types/conditions/condition-operators.d.ts +2 -2
- package/dist/types/conditions/condition-operators.d.ts.map +1 -1
- package/dist/types/conditions/condition-ref.d.ts +2 -2
- package/dist/types/conditions/condition-ref.d.ts.map +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-values.d.ts +3 -3
- package/dist/types/conditions/condition-values.d.ts.map +1 -1
- package/dist/types/conditions/condition.d.ts +4 -4
- package/dist/types/conditions/condition.d.ts.map +1 -1
- package/dist/types/conditions/index.d.ts +10 -10
- package/dist/types/conditions/index.d.ts.map +1 -1
- package/dist/types/conditions/types.d.ts +3 -3
- package/dist/types/conditions/types.d.ts.map +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/index.d.ts +3 -3
- package/dist/types/data-model/index.d.ts.map +1 -1
- package/dist/types/data-model/input-wrapper.d.ts +2 -2
- package/dist/types/data-model/input-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/types.d.ts +3 -3
- package/dist/types/data-model/types.d.ts.map +1 -1
- package/dist/types/form/index.d.ts +1 -1
- package/dist/types/form/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/migration/index.d.ts +1 -1
- package/dist/types/migration/index.d.ts.map +1 -1
- package/dist/types/migration/migration.0-2.d.ts +1 -1
- package/dist/types/migration/migration.0-2.d.ts.map +1 -1
- package/dist/types/migration/migration.1-2.d.ts +1 -1
- package/dist/types/migration/migration.1-2.d.ts.map +1 -1
- package/dist/types/migration/whichMigrations.d.ts +1 -1
- package/dist/types/migration/whichMigrations.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts +1 -1
- package/dist/types/schema/index.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/components/component-types.ts +1 -1
- package/src/components/conditional-component-types.ts +1 -1
- package/src/components/index.ts +3 -3
- package/src/conditions/condition-abstract.ts +1 -1
- package/src/conditions/condition-field.ts +2 -2
- package/src/conditions/condition-group-def.ts +1 -1
- package/src/conditions/condition-group.ts +3 -3
- package/src/conditions/condition-model.ts +9 -9
- package/src/conditions/condition-operators.ts +6 -3
- package/src/conditions/condition-ref.ts +2 -2
- package/src/conditions/condition-value-abstract.ts +1 -1
- package/src/conditions/condition-values.ts +3 -3
- package/src/conditions/condition.ts +6 -6
- package/src/conditions/index.ts +10 -10
- package/src/conditions/inline-condition-model.ts +3 -3
- package/src/conditions/inline-condition-operators.ts +1 -1
- package/src/conditions/types.ts +3 -3
- package/src/data-model/conditions-wrapper.ts +2 -2
- package/src/data-model/index.ts +3 -3
- package/src/data-model/input-wrapper.ts +3 -3
- package/src/data-model/types.ts +3 -3
- package/src/form/index.ts +1 -1
- package/src/index.ts +11 -11
- package/src/migration/index.ts +1 -1
- package/src/migration/migration.0-2.ts +1 -1
- package/src/migration/migration.1-2.ts +2 -2
- package/src/migration/whichMigrations.ts +3 -3
- package/src/schema/index.ts +1 -1
@@ -1,214 +1,203 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
2
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
3
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
4
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
5
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
6
|
+
import { ConditionField } from "./condition-field.js";
|
7
|
+
import { ConditionGroupDef } from "./condition-group-def.js";
|
8
|
+
import { Condition } from "./condition.js";
|
9
|
+
import { ConditionRef } from "./condition-ref.js";
|
10
|
+
import { ConditionGroup } from "./condition-group.js";
|
11
|
+
import { conditionValueFrom } from "./condition-values.js";
|
12
|
+
import { Coordinator } from "./enums.js";
|
13
|
+
import { toPresentationString, toExpression } from "./helpers.js";
|
14
|
+
var _groupedConditions = /*#__PURE__*/new WeakMap();
|
15
|
+
var _userGroupedConditions = /*#__PURE__*/new WeakMap();
|
16
|
+
var _conditionName = /*#__PURE__*/new WeakMap();
|
17
|
+
export class ConditionsModel {
|
18
|
+
constructor(_conditionsObject) {
|
19
|
+
_classPrivateFieldInitSpec(this, _groupedConditions, []);
|
20
|
+
_classPrivateFieldInitSpec(this, _userGroupedConditions, []);
|
21
|
+
_classPrivateFieldInitSpec(this, _conditionName, undefined);
|
12
22
|
}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
23
|
+
clone() {
|
24
|
+
const toReturn = new ConditionsModel();
|
25
|
+
_classPrivateFieldSet(_groupedConditions, toReturn, _classPrivateFieldGet(_groupedConditions, this).map(it => it.clone()));
|
26
|
+
_classPrivateFieldSet(_userGroupedConditions, toReturn, _classPrivateFieldGet(_userGroupedConditions, this).map(it => it.clone()));
|
27
|
+
_classPrivateFieldSet(_conditionName, toReturn, _classPrivateFieldGet(_conditionName, this));
|
28
|
+
return toReturn;
|
29
|
+
}
|
30
|
+
clear() {
|
31
|
+
_classPrivateFieldSet(_userGroupedConditions, this, []);
|
32
|
+
_classPrivateFieldSet(_groupedConditions, this, []);
|
33
|
+
_classPrivateFieldSet(_conditionName, this, undefined);
|
34
|
+
return this;
|
35
|
+
}
|
36
|
+
set name(name) {
|
37
|
+
_classPrivateFieldSet(_conditionName, this, name);
|
38
|
+
}
|
39
|
+
get name() {
|
40
|
+
return _classPrivateFieldGet(_conditionName, this);
|
41
|
+
}
|
42
|
+
add(condition) {
|
43
|
+
const coordinatorExpected = _classPrivateFieldGet(_userGroupedConditions, this).length !== 0;
|
44
|
+
if (condition.getCoordinator() && !coordinatorExpected) {
|
45
|
+
throw Error('No coordinator allowed on the first condition');
|
46
|
+
} else if (!condition.getCoordinator() && coordinatorExpected) {
|
47
|
+
throw Error('Coordinator must be present on subsequent conditions');
|
48
|
+
}
|
49
|
+
_classPrivateFieldGet(_userGroupedConditions, this).push(condition);
|
50
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
51
|
+
return this;
|
52
|
+
}
|
53
|
+
replace(index, condition) {
|
54
|
+
const coordinatorExpected = index !== 0;
|
55
|
+
if (condition.getCoordinator() && !coordinatorExpected) {
|
56
|
+
throw Error('No coordinator allowed on the first condition');
|
57
|
+
} else if (!condition.getCoordinator() && coordinatorExpected) {
|
58
|
+
throw Error('Coordinator must be present on subsequent conditions');
|
59
|
+
} else if (index >= _classPrivateFieldGet(_userGroupedConditions, this).length) {
|
60
|
+
throw Error(`Cannot replace condition ${index} as no such condition exists`);
|
61
|
+
}
|
62
|
+
_classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1, condition);
|
63
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
64
|
+
return this;
|
65
|
+
}
|
66
|
+
remove(indexes) {
|
67
|
+
_classPrivateFieldSet(_userGroupedConditions, this, _classPrivateFieldGet(_userGroupedConditions, this).filter((_condition, index) => !indexes.includes(index)).map((condition, index) => index === 0 ? condition.asFirstCondition() : condition));
|
68
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
69
|
+
return this;
|
70
|
+
}
|
71
|
+
addGroups(groupDefs) {
|
72
|
+
_classPrivateFieldSet(_userGroupedConditions, this, this._group(_classPrivateFieldGet(_userGroupedConditions, this), groupDefs));
|
73
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
74
|
+
return this;
|
75
|
+
}
|
76
|
+
splitGroup(index) {
|
77
|
+
_classPrivateFieldSet(_userGroupedConditions, this, this._ungroup(_classPrivateFieldGet(_userGroupedConditions, this), index));
|
78
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
79
|
+
return this;
|
80
|
+
}
|
81
|
+
moveEarlier(index) {
|
82
|
+
if (index > 0 && index < _classPrivateFieldGet(_userGroupedConditions, this).length) {
|
83
|
+
_classPrivateFieldGet(_userGroupedConditions, this).splice(index - 1, 0, _classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1)[0]);
|
84
|
+
if (index === 1) {
|
85
|
+
this.switchCoordinators();
|
57
86
|
}
|
58
|
-
_classPrivateFieldGet(_userGroupedConditions, this).push(condition);
|
59
87
|
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
60
|
-
return this;
|
61
88
|
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
throw Error(`Cannot replace condition ${index} as no such condition exists`);
|
89
|
+
return this;
|
90
|
+
}
|
91
|
+
moveLater(index) {
|
92
|
+
if (index >= 0 && index < _classPrivateFieldGet(_userGroupedConditions, this).length - 1) {
|
93
|
+
_classPrivateFieldGet(_userGroupedConditions, this).splice(index + 1, 0, _classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1)[0]);
|
94
|
+
if (index === 0) {
|
95
|
+
this.switchCoordinators();
|
70
96
|
}
|
71
|
-
_classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1, condition);
|
72
|
-
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
73
|
-
return this;
|
74
|
-
}
|
75
|
-
remove(indexes) {
|
76
|
-
_classPrivateFieldSet(_userGroupedConditions, this, _classPrivateFieldGet(_userGroupedConditions, this).filter((_condition, index) => !indexes.includes(index)).map((condition, index) => index === 0 ? condition.asFirstCondition() : condition));
|
77
|
-
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
78
|
-
return this;
|
79
|
-
}
|
80
|
-
addGroups(groupDefs) {
|
81
|
-
_classPrivateFieldSet(_userGroupedConditions, this, this._group(_classPrivateFieldGet(_userGroupedConditions, this), groupDefs));
|
82
97
|
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
83
|
-
return this;
|
84
98
|
}
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
99
|
+
return this;
|
100
|
+
}
|
101
|
+
switchCoordinators() {
|
102
|
+
_classPrivateFieldGet(_userGroupedConditions, this)[1].setCoordinator(_classPrivateFieldGet(_userGroupedConditions, this)[0].getCoordinator());
|
103
|
+
_classPrivateFieldGet(_userGroupedConditions, this)[0].setCoordinator(undefined);
|
104
|
+
}
|
105
|
+
get asPerUserGroupings() {
|
106
|
+
return [..._classPrivateFieldGet(_userGroupedConditions, this)];
|
107
|
+
}
|
108
|
+
get hasConditions() {
|
109
|
+
return _classPrivateFieldGet(_userGroupedConditions, this).length > 0;
|
110
|
+
}
|
111
|
+
get lastIndex() {
|
112
|
+
return _classPrivateFieldGet(_userGroupedConditions, this).length - 1;
|
113
|
+
}
|
114
|
+
toPresentationString() {
|
115
|
+
return _classPrivateFieldGet(_groupedConditions, this).map(condition => toPresentationString(condition)).join(' ');
|
116
|
+
}
|
117
|
+
toExpression() {
|
118
|
+
return _classPrivateFieldGet(_groupedConditions, this).map(condition => toExpression(condition)).join(' ');
|
119
|
+
}
|
120
|
+
_applyGroups(userGroupedConditions) {
|
121
|
+
const correctedUserGroups = userGroupedConditions.map(condition => condition instanceof ConditionGroup && condition.conditions.length > 2 ? new ConditionGroup(this._group(condition.conditions, this._autoGroupDefs(condition.conditions))) : condition);
|
122
|
+
return this._group(correctedUserGroups, this._autoGroupDefs(correctedUserGroups));
|
123
|
+
}
|
124
|
+
_group(conditions, groupDefs) {
|
125
|
+
return conditions.reduce((groups, condition, index, conditions) => {
|
126
|
+
const groupDef = groupDefs.find(groupDef => groupDef.contains(index));
|
127
|
+
if (groupDef) {
|
128
|
+
if (groupDef.startsWith(index)) {
|
129
|
+
const groupConditions = groupDef.applyTo(conditions);
|
130
|
+
groups.push(new ConditionGroup(groupConditions));
|
95
131
|
}
|
96
|
-
|
132
|
+
} else {
|
133
|
+
groups.push(condition);
|
97
134
|
}
|
98
|
-
return
|
135
|
+
return groups;
|
136
|
+
}, []);
|
137
|
+
}
|
138
|
+
_ungroup(conditions, splitIndex) {
|
139
|
+
if (conditions[splitIndex].isGroup()) {
|
140
|
+
const copy = [...conditions];
|
141
|
+
copy.splice(splitIndex, 1, ...conditions[splitIndex].getGroupedConditions());
|
142
|
+
return copy;
|
99
143
|
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
144
|
+
return conditions;
|
145
|
+
}
|
146
|
+
_autoGroupDefs(conditions) {
|
147
|
+
const orPositions = [];
|
148
|
+
conditions.forEach((condition, index) => {
|
149
|
+
if (condition.getCoordinator() === Coordinator.OR) {
|
150
|
+
orPositions.push(index);
|
107
151
|
}
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
get hasConditions() {
|
118
|
-
return _classPrivateFieldGet(_userGroupedConditions, this).length > 0;
|
119
|
-
}
|
120
|
-
get lastIndex() {
|
121
|
-
return _classPrivateFieldGet(_userGroupedConditions, this).length - 1;
|
122
|
-
}
|
123
|
-
toPresentationString() {
|
124
|
-
return _classPrivateFieldGet(_groupedConditions, this).map(condition => (0, _helpers.toPresentationString)(condition)).join(' ');
|
125
|
-
}
|
126
|
-
toExpression() {
|
127
|
-
return _classPrivateFieldGet(_groupedConditions, this).map(condition => (0, _helpers.toExpression)(condition)).join(' ');
|
128
|
-
}
|
129
|
-
_applyGroups(userGroupedConditions) {
|
130
|
-
const correctedUserGroups = userGroupedConditions.map(condition => condition instanceof _conditionGroup.ConditionGroup && condition.conditions.length > 2 ? new _conditionGroup.ConditionGroup(this._group(condition.conditions, this._autoGroupDefs(condition.conditions))) : condition);
|
131
|
-
return this._group(correctedUserGroups, this._autoGroupDefs(correctedUserGroups));
|
132
|
-
}
|
133
|
-
_group(conditions, groupDefs) {
|
134
|
-
return conditions.reduce((groups, condition, index, conditions) => {
|
135
|
-
const groupDef = groupDefs.find(groupDef => groupDef.contains(index));
|
136
|
-
if (groupDef) {
|
137
|
-
if (groupDef.startsWith(index)) {
|
138
|
-
const groupConditions = groupDef.applyTo(conditions);
|
139
|
-
groups.push(new _conditionGroup.ConditionGroup(groupConditions));
|
140
|
-
}
|
141
|
-
} else {
|
142
|
-
groups.push(condition);
|
152
|
+
});
|
153
|
+
const hasOr = orPositions.length > 0;
|
154
|
+
const hasAnd = !!conditions.find(condition => condition.getCoordinator() === Coordinator.AND);
|
155
|
+
if (hasAnd && hasOr) {
|
156
|
+
let start = 0;
|
157
|
+
const groupDefs = [];
|
158
|
+
orPositions.forEach((position, index) => {
|
159
|
+
if (start < position - 1) {
|
160
|
+
groupDefs.push(new ConditionGroupDef(start, position - 1));
|
143
161
|
}
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
if (conditions[splitIndex].isGroup()) {
|
149
|
-
const copy = [...conditions];
|
150
|
-
copy.splice(splitIndex, 1, ...conditions[splitIndex].getGroupedConditions());
|
151
|
-
return copy;
|
152
|
-
}
|
153
|
-
return conditions;
|
154
|
-
}
|
155
|
-
_autoGroupDefs(conditions) {
|
156
|
-
const orPositions = [];
|
157
|
-
conditions.forEach((condition, index) => {
|
158
|
-
if (condition.getCoordinator() === _enums.Coordinator.OR) {
|
159
|
-
orPositions.push(index);
|
162
|
+
const thisIsTheLastOr = orPositions.length === index + 1;
|
163
|
+
const thereAreMoreConditions = conditions.length - 1 > position;
|
164
|
+
if (thisIsTheLastOr && thereAreMoreConditions) {
|
165
|
+
groupDefs.push(new ConditionGroupDef(position, conditions.length - 1));
|
160
166
|
}
|
167
|
+
start = position;
|
161
168
|
});
|
162
|
-
|
163
|
-
const hasAnd = !!conditions.find(condition => condition.getCoordinator() === _enums.Coordinator.AND);
|
164
|
-
if (hasAnd && hasOr) {
|
165
|
-
let start = 0;
|
166
|
-
const groupDefs = [];
|
167
|
-
orPositions.forEach((position, index) => {
|
168
|
-
if (start < position - 1) {
|
169
|
-
groupDefs.push(new _conditionGroupDef.ConditionGroupDef(start, position - 1));
|
170
|
-
}
|
171
|
-
const thisIsTheLastOr = orPositions.length === index + 1;
|
172
|
-
const thereAreMoreConditions = conditions.length - 1 > position;
|
173
|
-
if (thisIsTheLastOr && thereAreMoreConditions) {
|
174
|
-
groupDefs.push(new _conditionGroupDef.ConditionGroupDef(position, conditions.length - 1));
|
175
|
-
}
|
176
|
-
start = position;
|
177
|
-
});
|
178
|
-
return groupDefs;
|
179
|
-
}
|
180
|
-
return [];
|
181
|
-
}
|
182
|
-
toJSON() {
|
183
|
-
const name = _classPrivateFieldGet(_conditionName, this);
|
184
|
-
const conditions = _classPrivateFieldGet(_userGroupedConditions, this);
|
185
|
-
return {
|
186
|
-
name,
|
187
|
-
conditions: conditions.map(it => it.clone())
|
188
|
-
};
|
169
|
+
return groupDefs;
|
189
170
|
}
|
171
|
+
return [];
|
172
|
+
}
|
173
|
+
toJSON() {
|
174
|
+
const name = _classPrivateFieldGet(_conditionName, this);
|
175
|
+
const conditions = _classPrivateFieldGet(_userGroupedConditions, this);
|
176
|
+
return {
|
177
|
+
name,
|
178
|
+
conditions: conditions.map(it => it.clone())
|
179
|
+
};
|
180
|
+
}
|
190
181
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
}
|
182
|
+
// TODO:- why is this not a constructor?
|
183
|
+
static from(obj) {
|
184
|
+
if (obj instanceof ConditionsModel) {
|
185
|
+
return obj;
|
186
|
+
}
|
187
|
+
const toReturn = new ConditionsModel();
|
188
|
+
_classPrivateFieldSet(_conditionName, toReturn, obj.name);
|
189
|
+
_classPrivateFieldSet(_userGroupedConditions, toReturn, obj.conditions.map(condition => conditionFrom(condition)));
|
190
|
+
_classPrivateFieldSet(_groupedConditions, toReturn, toReturn._applyGroups(_classPrivateFieldGet(_userGroupedConditions, toReturn)));
|
191
|
+
return toReturn;
|
202
192
|
}
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
});
|
193
|
+
}
|
194
|
+
const conditionFrom = function conditionFrom(it) {
|
195
|
+
if ('conditions' in it) {
|
196
|
+
return new ConditionGroup(it.conditions.map(condition => conditionFrom(condition)));
|
197
|
+
}
|
198
|
+
if ('conditionName' in it) {
|
199
|
+
return new ConditionRef(it.conditionName, it.conditionDisplayName, it.coordinator);
|
200
|
+
}
|
201
|
+
return new Condition(ConditionField.from(it.field), it.operator, conditionValueFrom(it.value), it.coordinator);
|
202
|
+
};
|
214
203
|
//# sourceMappingURL=condition-model.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-model.js","names":["ConditionsModel","constructor","_conditionsObject","_classPrivateFieldInitSpec","_groupedConditions","_userGroupedConditions","_conditionName","undefined","clone","toReturn","_classPrivateFieldSet","_classPrivateFieldGet","map","it","clear","name","add","condition","coordinatorExpected","length","getCoordinator","Error","push","_applyGroups","replace","index","splice","remove","indexes","filter","_condition","includes","asFirstCondition","addGroups","groupDefs","_group","splitGroup","_ungroup","moveEarlier","switchCoordinators","moveLater","setCoordinator","asPerUserGroupings","hasConditions","lastIndex","toPresentationString","join","toExpression","userGroupedConditions","correctedUserGroups","ConditionGroup","conditions","_autoGroupDefs","reduce","groups","groupDef","find","contains","startsWith","groupConditions","applyTo","splitIndex","isGroup","copy","getGroupedConditions","orPositions","forEach","Coordinator","OR","hasOr","hasAnd","AND","start","position","ConditionGroupDef","thisIsTheLastOr","thereAreMoreConditions","toJSON","from","obj","conditionFrom","_exports","ConditionRef","conditionName","conditionDisplayName","coordinator","Condition","ConditionField","field","operator","conditionValueFrom","value"],"sources":["../../../src/conditions/condition-model.ts"],"sourcesContent":["import { ConditionField } from '~/src/conditions/condition-field'\nimport { ConditionGroupDef } from '~/src/conditions/condition-group-def'\nimport { Condition } from '~/src/conditions/condition'\nimport { ConditionRef } from '~/src/conditions/condition-ref'\nimport { ConditionGroup } from '~/src/conditions/condition-group'\nimport { conditionValueFrom } from '~/src/conditions/condition-values'\nimport { Coordinator } from '~/src/conditions/enums'\nimport { toPresentationString, toExpression } from '~/src/conditions/helpers'\nimport { type ConditionsArray } from '~/src/conditions/types'\n\ntype ConditionRawObject =\n | ConditionsModel\n | {\n name: string\n conditions: Condition[]\n }\n\nexport class ConditionsModel {\n #groupedConditions: ConditionsArray = []\n #userGroupedConditions: ConditionsArray = []\n #conditionName: string | undefined = undefined\n\n constructor(_conditionsObject?: ConditionRawObject) {}\n\n clone() {\n const toReturn = new ConditionsModel()\n toReturn.#groupedConditions = this.#groupedConditions.map((it) =>\n it.clone()\n )\n toReturn.#userGroupedConditions = this.#userGroupedConditions.map((it) =>\n it.clone()\n )\n toReturn.#conditionName = this.#conditionName\n return toReturn\n }\n\n clear() {\n this.#userGroupedConditions = []\n this.#groupedConditions = []\n this.#conditionName = undefined\n return this\n }\n\n set name(name) {\n this.#conditionName = name\n }\n\n get name() {\n return this.#conditionName\n }\n\n add(condition: Condition) {\n const coordinatorExpected = this.#userGroupedConditions.length !== 0\n\n if (condition.getCoordinator() && !coordinatorExpected) {\n throw Error('No coordinator allowed on the first condition')\n } else if (!condition.getCoordinator() && coordinatorExpected) {\n throw Error('Coordinator must be present on subsequent conditions')\n }\n\n this.#userGroupedConditions.push(condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n\n return this\n }\n\n replace(index: number, condition: Condition) {\n const coordinatorExpected = index !== 0\n\n if (condition.getCoordinator() && !coordinatorExpected) {\n throw Error('No coordinator allowed on the first condition')\n } else if (!condition.getCoordinator() && coordinatorExpected) {\n throw Error('Coordinator must be present on subsequent conditions')\n } else if (index >= this.#userGroupedConditions.length) {\n throw Error(\n `Cannot replace condition ${index} as no such condition exists`\n )\n }\n\n this.#userGroupedConditions.splice(index, 1, condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n\n return this\n }\n\n remove(indexes: number[]) {\n this.#userGroupedConditions = this.#userGroupedConditions\n .filter((_condition, index) => !indexes.includes(index))\n .map((condition, index) =>\n index === 0 ? condition.asFirstCondition() : condition\n )\n\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n addGroups(groupDefs: ConditionGroupDef[]) {\n this.#userGroupedConditions = this._group(\n this.#userGroupedConditions,\n groupDefs\n )\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n splitGroup(index: number) {\n this.#userGroupedConditions = this._ungroup(\n this.#userGroupedConditions,\n index\n )\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n moveEarlier(index: number) {\n if (index > 0 && index < this.#userGroupedConditions.length) {\n this.#userGroupedConditions.splice(\n index - 1,\n 0,\n this.#userGroupedConditions.splice(index, 1)[0]\n )\n if (index === 1) {\n this.switchCoordinators()\n }\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n }\n return this\n }\n\n moveLater(index: number) {\n if (index >= 0 && index < this.#userGroupedConditions.length - 1) {\n this.#userGroupedConditions.splice(\n index + 1,\n 0,\n this.#userGroupedConditions.splice(index, 1)[0]\n )\n if (index === 0) {\n this.switchCoordinators()\n }\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n }\n return this\n }\n\n switchCoordinators() {\n this.#userGroupedConditions[1].setCoordinator(\n this.#userGroupedConditions[0].getCoordinator()\n )\n this.#userGroupedConditions[0].setCoordinator(undefined)\n }\n\n get asPerUserGroupings() {\n return [...this.#userGroupedConditions]\n }\n\n get hasConditions() {\n return this.#userGroupedConditions.length > 0\n }\n\n get lastIndex() {\n return this.#userGroupedConditions.length - 1\n }\n\n toPresentationString() {\n return this.#groupedConditions\n .map((condition) => toPresentationString(condition))\n .join(' ')\n }\n\n toExpression() {\n return this.#groupedConditions\n .map((condition) => toExpression(condition))\n .join(' ')\n }\n\n _applyGroups(\n userGroupedConditions: (Condition | ConditionGroup | ConditionRef)[]\n ) {\n const correctedUserGroups = userGroupedConditions.map((condition) =>\n condition instanceof ConditionGroup && condition.conditions.length > 2\n ? new ConditionGroup(\n this._group(\n condition.conditions,\n this._autoGroupDefs(condition.conditions)\n )\n )\n : condition\n )\n\n return this._group(\n correctedUserGroups,\n this._autoGroupDefs(correctedUserGroups)\n )\n }\n\n _group(conditions: ConditionsArray, groupDefs: ConditionGroupDef[]) {\n return conditions.reduce((groups, condition, index, conditions) => {\n const groupDef = groupDefs.find((groupDef) => groupDef.contains(index))\n\n if (groupDef) {\n if (groupDef.startsWith(index)) {\n const groupConditions = groupDef.applyTo(conditions)\n groups.push(new ConditionGroup(groupConditions))\n }\n } else {\n groups.push(condition)\n }\n\n return groups\n }, [] as ConditionsArray)\n }\n\n _ungroup(conditions: ConditionsArray, splitIndex: number) {\n if (conditions[splitIndex].isGroup()) {\n const copy = [...conditions]\n copy.splice(\n splitIndex,\n 1,\n ...conditions[splitIndex].getGroupedConditions()\n )\n return copy\n }\n return conditions\n }\n\n _autoGroupDefs(conditions: ConditionsArray) {\n const orPositions: number[] = []\n\n conditions.forEach((condition, index) => {\n if (condition.getCoordinator() === Coordinator.OR) {\n orPositions.push(index)\n }\n })\n\n const hasOr = orPositions.length > 0\n const hasAnd = !!conditions.find(\n (condition) => condition.getCoordinator() === Coordinator.AND\n )\n\n if (hasAnd && hasOr) {\n let start = 0\n const groupDefs: ConditionGroupDef[] = []\n orPositions.forEach((position, index) => {\n if (start < position - 1) {\n groupDefs.push(new ConditionGroupDef(start, position - 1))\n }\n const thisIsTheLastOr = orPositions.length === index + 1\n const thereAreMoreConditions = conditions.length - 1 > position\n if (thisIsTheLastOr && thereAreMoreConditions) {\n groupDefs.push(new ConditionGroupDef(position, conditions.length - 1))\n }\n start = position\n })\n return groupDefs\n }\n\n return []\n }\n\n toJSON() {\n const name = this.#conditionName\n const conditions = this.#userGroupedConditions\n return {\n name,\n conditions: conditions.map((it) => it.clone())\n }\n }\n\n // TODO:- why is this not a constructor?\n static from(obj: ConditionRawObject | ConditionsModel) {\n if (obj instanceof ConditionsModel) {\n return obj\n }\n const toReturn = new ConditionsModel()\n toReturn.#conditionName = obj.name\n toReturn.#userGroupedConditions = obj.conditions.map((condition) =>\n conditionFrom(condition)\n )\n toReturn.#groupedConditions = toReturn._applyGroups(\n toReturn.#userGroupedConditions\n )\n return toReturn\n }\n}\n\ninterface ConditionFrom {\n (\n it: Condition | ConditionRef | ConditionGroup\n ): Condition | ConditionRef | ConditionGroup\n}\n\nconst conditionFrom: ConditionFrom = function (it) {\n if ('conditions' in it) {\n return new ConditionGroup(\n (it as ConditionGroup).conditions.map((condition) =>\n conditionFrom(condition)\n )\n )\n }\n\n if ('conditionName' in it) {\n return new ConditionRef(\n it.conditionName,\n it.conditionDisplayName,\n it.coordinator\n )\n }\n\n return new Condition(\n ConditionField.from(it.field),\n it.operator,\n conditionValueFrom(it.value),\n it.coordinator\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAiBO,MAAMA,eAAe,CAAC;IAK3BC,WAAWA,CAACC,iBAAsC,EAAE;MAAAC,0BAAA,OAAAC,kBAAA,EAJd,EAAE;MAAAD,0BAAA,OAAAE,sBAAA,EACE,EAAE;MAAAF,0BAAA,OAAAG,cAAA,EACPC,SAAS;IAEO;IAErDC,KAAKA,CAAA,EAAG;MACN,MAAMC,QAAQ,GAAG,IAAIT,eAAe,CAAC,CAAC;MACtCU,qBAAA,CAAAN,kBAAA,EAAAK,QAAQ,EAAsBE,qBAAA,CAAAP,kBAAA,MAAI,EAAoBQ,GAAG,CAAEC,EAAE,IAC3DA,EAAE,CAACL,KAAK,CAAC,CACX,CAAC;MACDE,qBAAA,CAAAL,sBAAA,EAAAI,QAAQ,EAA0BE,qBAAA,CAAAN,sBAAA,MAAI,EAAwBO,GAAG,CAAEC,EAAE,IACnEA,EAAE,CAACL,KAAK,CAAC,CACX,CAAC;MACDE,qBAAA,CAAAJ,cAAA,EAAAG,QAAQ,EAAAE,qBAAA,CAAAL,cAAA,EAAkB,IAAI;MAC9B,OAAOG,QAAQ;IACjB;IAEA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ChBtE,EAAE,CAACuE,oBAAoB,EACvBvE,EAAE,CAACwE,WACL,CAAC;IACH;IAEA,OAAO,IAAIC,qBAAS,CAClBC,8BAAc,CAACT,IAAI,CAACjE,EAAE,CAAC2E,KAAK,CAAC,EAC7B3E,EAAE,CAAC4E,QAAQ,EACX,IAAAC,mCAAkB,EAAC7E,EAAE,CAAC8E,KAAK,CAAC,EAC5B9E,EAAE,CAACwE,WACL,CAAC;EACH,CAAC;AAAA"}
|
1
|
+
{"version":3,"file":"condition-model.js","names":["ConditionField","ConditionGroupDef","Condition","ConditionRef","ConditionGroup","conditionValueFrom","Coordinator","toPresentationString","toExpression","_groupedConditions","WeakMap","_userGroupedConditions","_conditionName","ConditionsModel","constructor","_conditionsObject","_classPrivateFieldInitSpec","undefined","clone","toReturn","_classPrivateFieldSet","_classPrivateFieldGet","map","it","clear","name","add","condition","coordinatorExpected","length","getCoordinator","Error","push","_applyGroups","replace","index","splice","remove","indexes","filter","_condition","includes","asFirstCondition","addGroups","groupDefs","_group","splitGroup","_ungroup","moveEarlier","switchCoordinators","moveLater","setCoordinator","asPerUserGroupings","hasConditions","lastIndex","join","userGroupedConditions","correctedUserGroups","conditions","_autoGroupDefs","reduce","groups","groupDef","find","contains","startsWith","groupConditions","applyTo","splitIndex","isGroup","copy","getGroupedConditions","orPositions","forEach","OR","hasOr","hasAnd","AND","start","position","thisIsTheLastOr","thereAreMoreConditions","toJSON","from","obj","conditionFrom","conditionName","conditionDisplayName","coordinator","field","operator","value"],"sources":["../../../src/conditions/condition-model.ts"],"sourcesContent":["import { ConditionField } from '~/src/conditions/condition-field.js'\nimport { ConditionGroupDef } from '~/src/conditions/condition-group-def.js'\nimport { Condition } from '~/src/conditions/condition.js'\nimport { ConditionRef } from '~/src/conditions/condition-ref.js'\nimport { ConditionGroup } from '~/src/conditions/condition-group.js'\nimport { conditionValueFrom } from '~/src/conditions/condition-values.js'\nimport { Coordinator } from '~/src/conditions/enums.js'\nimport { toPresentationString, toExpression } from '~/src/conditions/helpers.js'\nimport { type ConditionsArray } from '~/src/conditions/types.js'\n\ntype ConditionRawObject =\n | ConditionsModel\n | {\n name: string\n conditions: Condition[]\n }\n\nexport class ConditionsModel {\n #groupedConditions: ConditionsArray = []\n #userGroupedConditions: ConditionsArray = []\n #conditionName: string | undefined = undefined\n\n constructor(_conditionsObject?: ConditionRawObject) {}\n\n clone() {\n const toReturn = new ConditionsModel()\n toReturn.#groupedConditions = this.#groupedConditions.map((it) =>\n it.clone()\n )\n toReturn.#userGroupedConditions = this.#userGroupedConditions.map((it) =>\n it.clone()\n )\n toReturn.#conditionName = this.#conditionName\n return toReturn\n }\n\n clear() {\n this.#userGroupedConditions = []\n this.#groupedConditions = []\n this.#conditionName = undefined\n return this\n }\n\n set name(name) {\n this.#conditionName = name\n }\n\n get name() {\n return this.#conditionName\n }\n\n add(condition: Condition) {\n const coordinatorExpected = this.#userGroupedConditions.length !== 0\n\n if (condition.getCoordinator() && !coordinatorExpected) {\n throw Error('No coordinator allowed on the first condition')\n } else if (!condition.getCoordinator() && coordinatorExpected) {\n throw Error('Coordinator must be present on subsequent conditions')\n }\n\n this.#userGroupedConditions.push(condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n\n return this\n }\n\n replace(index: number, condition: Condition) {\n const coordinatorExpected = index !== 0\n\n if (condition.getCoordinator() && !coordinatorExpected) {\n throw Error('No coordinator allowed on the first condition')\n } else if (!condition.getCoordinator() && coordinatorExpected) {\n throw Error('Coordinator must be present on subsequent conditions')\n } else if (index >= this.#userGroupedConditions.length) {\n throw Error(\n `Cannot replace condition ${index} as no such condition exists`\n )\n }\n\n this.#userGroupedConditions.splice(index, 1, condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n\n return this\n }\n\n remove(indexes: number[]) {\n this.#userGroupedConditions = this.#userGroupedConditions\n .filter((_condition, index) => !indexes.includes(index))\n .map((condition, index) =>\n index === 0 ? condition.asFirstCondition() : condition\n )\n\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n addGroups(groupDefs: ConditionGroupDef[]) {\n this.#userGroupedConditions = this._group(\n this.#userGroupedConditions,\n groupDefs\n )\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n splitGroup(index: number) {\n this.#userGroupedConditions = this._ungroup(\n this.#userGroupedConditions,\n index\n )\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n moveEarlier(index: number) {\n if (index > 0 && index < this.#userGroupedConditions.length) {\n this.#userGroupedConditions.splice(\n index - 1,\n 0,\n this.#userGroupedConditions.splice(index, 1)[0]\n )\n if (index === 1) {\n this.switchCoordinators()\n }\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n }\n return this\n }\n\n moveLater(index: number) {\n if (index >= 0 && index < this.#userGroupedConditions.length - 1) {\n this.#userGroupedConditions.splice(\n index + 1,\n 0,\n this.#userGroupedConditions.splice(index, 1)[0]\n )\n if (index === 0) {\n this.switchCoordinators()\n }\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n }\n return this\n }\n\n switchCoordinators() {\n this.#userGroupedConditions[1].setCoordinator(\n this.#userGroupedConditions[0].getCoordinator()\n )\n this.#userGroupedConditions[0].setCoordinator(undefined)\n }\n\n get asPerUserGroupings() {\n return [...this.#userGroupedConditions]\n }\n\n get hasConditions() {\n return this.#userGroupedConditions.length > 0\n }\n\n get lastIndex() {\n return this.#userGroupedConditions.length - 1\n }\n\n toPresentationString() {\n return this.#groupedConditions\n .map((condition) => toPresentationString(condition))\n .join(' ')\n }\n\n toExpression() {\n return this.#groupedConditions\n .map((condition) => toExpression(condition))\n .join(' ')\n }\n\n _applyGroups(\n userGroupedConditions: (Condition | ConditionGroup | ConditionRef)[]\n ) {\n const correctedUserGroups = userGroupedConditions.map((condition) =>\n condition instanceof ConditionGroup && condition.conditions.length > 2\n ? new ConditionGroup(\n this._group(\n condition.conditions,\n this._autoGroupDefs(condition.conditions)\n )\n )\n : condition\n )\n\n return this._group(\n correctedUserGroups,\n this._autoGroupDefs(correctedUserGroups)\n )\n }\n\n _group(conditions: ConditionsArray, groupDefs: ConditionGroupDef[]) {\n return conditions.reduce((groups, condition, index, conditions) => {\n const groupDef = groupDefs.find((groupDef) => groupDef.contains(index))\n\n if (groupDef) {\n if (groupDef.startsWith(index)) {\n const groupConditions = groupDef.applyTo(conditions)\n groups.push(new ConditionGroup(groupConditions))\n }\n } else {\n groups.push(condition)\n }\n\n return groups\n }, [] as ConditionsArray)\n }\n\n _ungroup(conditions: ConditionsArray, splitIndex: number) {\n if (conditions[splitIndex].isGroup()) {\n const copy = [...conditions]\n copy.splice(\n splitIndex,\n 1,\n ...conditions[splitIndex].getGroupedConditions()\n )\n return copy\n }\n return conditions\n }\n\n _autoGroupDefs(conditions: ConditionsArray) {\n const orPositions: number[] = []\n\n conditions.forEach((condition, index) => {\n if (condition.getCoordinator() === Coordinator.OR) {\n orPositions.push(index)\n }\n })\n\n const hasOr = orPositions.length > 0\n const hasAnd = !!conditions.find(\n (condition) => condition.getCoordinator() === Coordinator.AND\n )\n\n if (hasAnd && hasOr) {\n let start = 0\n const groupDefs: ConditionGroupDef[] = []\n orPositions.forEach((position, index) => {\n if (start < position - 1) {\n groupDefs.push(new ConditionGroupDef(start, position - 1))\n }\n const thisIsTheLastOr = orPositions.length === index + 1\n const thereAreMoreConditions = conditions.length - 1 > position\n if (thisIsTheLastOr && thereAreMoreConditions) {\n groupDefs.push(new ConditionGroupDef(position, conditions.length - 1))\n }\n start = position\n })\n return groupDefs\n }\n\n return []\n }\n\n toJSON() {\n const name = this.#conditionName\n const conditions = this.#userGroupedConditions\n return {\n name,\n conditions: conditions.map((it) => it.clone())\n }\n }\n\n // TODO:- why is this not a constructor?\n static from(obj: ConditionRawObject | ConditionsModel) {\n if (obj instanceof ConditionsModel) {\n return obj\n }\n const toReturn = new ConditionsModel()\n toReturn.#conditionName = obj.name\n toReturn.#userGroupedConditions = obj.conditions.map((condition) =>\n conditionFrom(condition)\n )\n toReturn.#groupedConditions = toReturn._applyGroups(\n toReturn.#userGroupedConditions\n )\n return toReturn\n }\n}\n\ninterface ConditionFrom {\n (\n it: Condition | ConditionRef | ConditionGroup\n ): Condition | ConditionRef | ConditionGroup\n}\n\nconst conditionFrom: ConditionFrom = function (it) {\n if ('conditions' in it) {\n return new ConditionGroup(\n (it as ConditionGroup).conditions.map((condition) =>\n conditionFrom(condition)\n )\n )\n }\n\n if ('conditionName' in it) {\n return new ConditionRef(\n it.conditionName,\n it.conditionDisplayName,\n it.coordinator\n )\n }\n\n return new Condition(\n ConditionField.from(it.field),\n it.operator,\n conditionValueFrom(it.value),\n it.coordinator\n )\n}\n"],"mappings":";;;;;AAAA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAC1B,SAASC,SAAS;AAClB,SAASC,YAAY;AACrB,SAASC,cAAc;AACvB,SAASC,kBAAkB;AAC3B,SAASC,WAAW;AACpB,SAASC,oBAAoB,EAAEC,YAAY;AAAqC,IAAAC,kBAAA,oBAAAC,OAAA;AAAA,IAAAC,sBAAA,oBAAAD,OAAA;AAAA,IAAAE,cAAA,oBAAAF,OAAA;AAUhF,OAAO,MAAMG,eAAe,CAAC;EAK3BC,WAAWA,CAACC,iBAAsC,EAAE;IAAAC,0BAAA,OAAAP,kBAAA,EAJd,EAAE;IAAAO,0BAAA,OAAAL,sBAAA,EACE,EAAE;IAAAK,0BAAA,OAAAJ,cAAA,EACPK,SAAS;EAEO;EAErDC,KAAKA,CAAA,EAAG;IACN,MAAMC,QAAQ,GAAG,IAAIN,eAAe,CAAC,CAAC;IACtCO,qBAAA,CAAAX,kBAAA,EAAAU,QAAQ,EAAsBE,qBAAA,CAAAZ,kBAAA,MAAI,EAAoBa,GAAG,CAAEC,EAAE,IAC3DA,EAAE,CAACL,KAAK,CAAC,CACX,CAAC;IACDE,qBAAA,CAAAT,sBAAA,EAAAQ,QAAQ,EAA0BE,qBAAA,CAAAV,sBAAA,MAAI,EAAwBW,GAAG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