@defra/forms-model 3.0.2
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/LICENCE +8 -0
- package/README.md +22 -0
- package/dist/browser/components/component-types.d.ts +3 -0
- package/dist/browser/components/component-types.d.ts.map +1 -0
- package/dist/browser/components/component-types.js +220 -0
- package/dist/browser/components/component-types.js.map +1 -0
- package/dist/browser/components/conditional-component-types.d.ts +3 -0
- package/dist/browser/components/conditional-component-types.d.ts.map +1 -0
- package/dist/browser/components/conditional-component-types.js +28 -0
- package/dist/browser/components/conditional-component-types.js.map +1 -0
- package/dist/browser/components/index.d.ts +4 -0
- package/dist/browser/components/index.d.ts.map +1 -0
- package/dist/browser/components/index.js +45 -0
- package/dist/browser/components/index.js.map +1 -0
- package/dist/browser/components/types.d.ts +244 -0
- package/dist/browser/components/types.d.ts.map +1 -0
- package/dist/browser/components/types.js +56 -0
- package/dist/browser/components/types.js.map +1 -0
- package/dist/browser/conditions/condition-abstract.d.ts +16 -0
- package/dist/browser/conditions/condition-abstract.d.ts.map +1 -0
- package/dist/browser/conditions/condition-abstract.js +62 -0
- package/dist/browser/conditions/condition-abstract.js.map +1 -0
- package/dist/browser/conditions/condition-field.d.ts +13 -0
- package/dist/browser/conditions/condition-field.d.ts.map +1 -0
- package/dist/browser/conditions/condition-field.js +45 -0
- package/dist/browser/conditions/condition-field.js.map +1 -0
- package/dist/browser/conditions/condition-group-def.d.ts +10 -0
- package/dist/browser/conditions/condition-group-def.d.ts.map +1 -0
- package/dist/browser/conditions/condition-group-def.js +45 -0
- package/dist/browser/conditions/condition-group-def.js.map +1 -0
- package/dist/browser/conditions/condition-group.d.ts +15 -0
- package/dist/browser/conditions/condition-group.d.ts.map +1 -0
- package/dist/browser/conditions/condition-group.js +64 -0
- package/dist/browser/conditions/condition-group.js.map +1 -0
- package/dist/browser/conditions/condition-model.d.ts +41 -0
- package/dist/browser/conditions/condition-model.d.ts.map +1 -0
- package/dist/browser/conditions/condition-model.js +214 -0
- package/dist/browser/conditions/condition-model.js.map +1 -0
- package/dist/browser/conditions/condition-operators.d.ts +248 -0
- package/dist/browser/conditions/condition-operators.d.ts.map +1 -0
- package/dist/browser/conditions/condition-operators.js +132 -0
- package/dist/browser/conditions/condition-operators.js.map +1 -0
- package/dist/browser/conditions/condition-ref.d.ts +12 -0
- package/dist/browser/conditions/condition-ref.d.ts.map +1 -0
- package/dist/browser/conditions/condition-ref.js +51 -0
- package/dist/browser/conditions/condition-ref.js.map +1 -0
- package/dist/browser/conditions/condition-value-abstract.d.ts +8 -0
- package/dist/browser/conditions/condition-value-abstract.d.ts.map +1 -0
- package/dist/browser/conditions/condition-value-abstract.js +41 -0
- package/dist/browser/conditions/condition-value-abstract.js.map +1 -0
- package/dist/browser/conditions/condition-value-registration.d.ts +10 -0
- package/dist/browser/conditions/condition-value-registration.d.ts.map +1 -0
- package/dist/browser/conditions/condition-value-registration.js +37 -0
- package/dist/browser/conditions/condition-value-registration.js.map +1 -0
- package/dist/browser/conditions/condition-values.d.ts +38 -0
- package/dist/browser/conditions/condition-values.d.ts.map +1 -0
- package/dist/browser/conditions/condition-values.js +127 -0
- package/dist/browser/conditions/condition-values.js.map +1 -0
- package/dist/browser/conditions/condition.d.ts +15 -0
- package/dist/browser/conditions/condition.d.ts.map +1 -0
- package/dist/browser/conditions/condition.js +56 -0
- package/dist/browser/conditions/condition.js.map +1 -0
- package/dist/browser/conditions/helpers.d.ts +3 -0
- package/dist/browser/conditions/helpers.d.ts.map +1 -0
- package/dist/browser/conditions/helpers.js +26 -0
- package/dist/browser/conditions/helpers.js.map +1 -0
- package/dist/browser/conditions/index.d.ts +11 -0
- package/dist/browser/conditions/index.d.ts.map +1 -0
- package/dist/browser/conditions/index.js +144 -0
- package/dist/browser/conditions/index.js.map +1 -0
- package/dist/browser/conditions/inline-condition-model.d.ts +86 -0
- package/dist/browser/conditions/inline-condition-model.d.ts.map +1 -0
- package/dist/browser/conditions/inline-condition-model.js +418 -0
- package/dist/browser/conditions/inline-condition-model.js.map +1 -0
- package/dist/browser/conditions/inline-condition-operators.d.ts +175 -0
- package/dist/browser/conditions/inline-condition-operators.d.ts.map +1 -0
- package/dist/browser/conditions/inline-condition-operators.js +132 -0
- package/dist/browser/conditions/inline-condition-operators.js.map +1 -0
- package/dist/browser/conditions/inline-condition-values.d.ts +93 -0
- package/dist/browser/conditions/inline-condition-values.d.ts.map +1 -0
- package/dist/browser/conditions/inline-condition-values.js +159 -0
- package/dist/browser/conditions/inline-condition-values.js.map +1 -0
- package/dist/browser/conditions/types.d.ts +38 -0
- package/dist/browser/conditions/types.d.ts.map +1 -0
- package/dist/browser/conditions/types.js +24 -0
- package/dist/browser/conditions/types.js.map +1 -0
- package/dist/browser/data-model/conditions-wrapper.d.ts +19 -0
- package/dist/browser/data-model/conditions-wrapper.d.ts.map +1 -0
- package/dist/browser/data-model/conditions-wrapper.js +49 -0
- package/dist/browser/data-model/conditions-wrapper.js.map +1 -0
- package/dist/browser/data-model/index.d.ts +4 -0
- package/dist/browser/data-model/index.d.ts.map +1 -0
- package/dist/browser/data-model/index.js +66 -0
- package/dist/browser/data-model/index.js.map +1 -0
- package/dist/browser/data-model/input-wrapper.d.ts +16 -0
- package/dist/browser/data-model/input-wrapper.d.ts.map +1 -0
- package/dist/browser/data-model/input-wrapper.js +49 -0
- package/dist/browser/data-model/input-wrapper.js.map +1 -0
- package/dist/browser/data-model/types.d.ts +153 -0
- package/dist/browser/data-model/types.d.ts.map +1 -0
- package/dist/browser/data-model/types.js +34 -0
- package/dist/browser/data-model/types.js.map +1 -0
- package/dist/browser/form/form-configuration.d.ts +8 -0
- package/dist/browser/form/form-configuration.d.ts.map +1 -0
- package/dist/browser/form/form-configuration.js +38 -0
- package/dist/browser/form/form-configuration.js.map +1 -0
- package/dist/browser/form/index.d.ts +2 -0
- package/dist/browser/form/index.d.ts.map +1 -0
- package/dist/browser/form/index.js +24 -0
- package/dist/browser/form/index.js.map +1 -0
- package/dist/browser/index.d.ts +12 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +138 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/migration/index.d.ts +2 -0
- package/dist/browser/migration/index.d.ts.map +1 -0
- package/dist/browser/migration/index.js +24 -0
- package/dist/browser/migration/index.js.map +1 -0
- package/dist/browser/migration/migration.0-2.d.ts +3 -0
- package/dist/browser/migration/migration.0-2.d.ts.map +1 -0
- package/dist/browser/migration/migration.0-2.js +65 -0
- package/dist/browser/migration/migration.0-2.js.map +1 -0
- package/dist/browser/migration/migration.1-2.d.ts +3 -0
- package/dist/browser/migration/migration.1-2.d.ts.map +1 -0
- package/dist/browser/migration/migration.1-2.js +108 -0
- package/dist/browser/migration/migration.1-2.js.map +1 -0
- package/dist/browser/migration/types.d.ts +2 -0
- package/dist/browser/migration/types.d.ts.map +1 -0
- package/dist/browser/migration/types.js +16 -0
- package/dist/browser/migration/types.js.map +1 -0
- package/dist/browser/migration/whichMigrations.d.ts +7 -0
- package/dist/browser/migration/whichMigrations.d.ts.map +1 -0
- package/dist/browser/migration/whichMigrations.js +38 -0
- package/dist/browser/migration/whichMigrations.js.map +1 -0
- package/dist/browser/schema/index.d.ts +2 -0
- package/dist/browser/schema/index.d.ts.map +1 -0
- package/dist/browser/schema/index.js +30 -0
- package/dist/browser/schema/index.js.map +1 -0
- package/dist/browser/schema/schema.d.ts +20 -0
- package/dist/browser/schema/schema.d.ts.map +1 -0
- package/dist/browser/schema/schema.js +255 -0
- package/dist/browser/schema/schema.js.map +1 -0
- package/dist/browser/utils/helpers.d.ts +9 -0
- package/dist/browser/utils/helpers.d.ts.map +1 -0
- package/dist/browser/utils/helpers.js +48 -0
- package/dist/browser/utils/helpers.js.map +1 -0
- package/dist/browser/utils/logger.d.ts +11 -0
- package/dist/browser/utils/logger.d.ts.map +1 -0
- package/dist/browser/utils/logger.js +46 -0
- package/dist/browser/utils/logger.js.map +1 -0
- package/dist/module/components/component-types.d.ts +3 -0
- package/dist/module/components/component-types.d.ts.map +1 -0
- package/dist/module/components/component-types.js +206 -0
- package/dist/module/components/component-types.js.map +1 -0
- package/dist/module/components/conditional-component-types.d.ts +3 -0
- package/dist/module/components/conditional-component-types.d.ts.map +1 -0
- package/dist/module/components/conditional-component-types.js +14 -0
- package/dist/module/components/conditional-component-types.js.map +1 -0
- package/dist/module/components/index.d.ts +4 -0
- package/dist/module/components/index.d.ts.map +1 -0
- package/dist/module/components/index.js +34 -0
- package/dist/module/components/index.js.map +1 -0
- package/dist/module/components/types.d.ts +244 -0
- package/dist/module/components/types.d.ts.map +1 -0
- package/dist/module/components/types.js +42 -0
- package/dist/module/components/types.js.map +1 -0
- package/dist/module/conditions/condition-abstract.d.ts +16 -0
- package/dist/module/conditions/condition-abstract.d.ts.map +1 -0
- package/dist/module/conditions/condition-abstract.js +45 -0
- package/dist/module/conditions/condition-abstract.js.map +1 -0
- package/dist/module/conditions/condition-field.d.ts +13 -0
- package/dist/module/conditions/condition-field.d.ts.map +1 -0
- package/dist/module/conditions/condition-field.js +26 -0
- package/dist/module/conditions/condition-field.js.map +1 -0
- package/dist/module/conditions/condition-group-def.d.ts +10 -0
- package/dist/module/conditions/condition-group-def.d.ts.map +1 -0
- package/dist/module/conditions/condition-group-def.js +26 -0
- package/dist/module/conditions/condition-group-def.js.map +1 -0
- package/dist/module/conditions/condition-group.d.ts +15 -0
- package/dist/module/conditions/condition-group.d.ts.map +1 -0
- package/dist/module/conditions/condition-group.js +47 -0
- package/dist/module/conditions/condition-group.js.map +1 -0
- package/dist/module/conditions/condition-model.d.ts +41 -0
- package/dist/module/conditions/condition-model.d.ts.map +1 -0
- package/dist/module/conditions/condition-model.js +199 -0
- package/dist/module/conditions/condition-model.js.map +1 -0
- package/dist/module/conditions/condition-operators.d.ts +248 -0
- package/dist/module/conditions/condition-operators.d.ts.map +1 -0
- package/dist/module/conditions/condition-operators.js +119 -0
- package/dist/module/conditions/condition-operators.js.map +1 -0
- package/dist/module/conditions/condition-ref.d.ts +12 -0
- package/dist/module/conditions/condition-ref.d.ts.map +1 -0
- package/dist/module/conditions/condition-ref.js +33 -0
- package/dist/module/conditions/condition-ref.js.map +1 -0
- package/dist/module/conditions/condition-value-abstract.d.ts +8 -0
- package/dist/module/conditions/condition-value-abstract.d.ts.map +1 -0
- package/dist/module/conditions/condition-value-abstract.js +24 -0
- package/dist/module/conditions/condition-value-abstract.js.map +1 -0
- package/dist/module/conditions/condition-value-registration.d.ts +10 -0
- package/dist/module/conditions/condition-value-registration.d.ts.map +1 -0
- package/dist/module/conditions/condition-value-registration.js +19 -0
- package/dist/module/conditions/condition-value-registration.js.map +1 -0
- package/dist/module/conditions/condition-values.d.ts +38 -0
- package/dist/module/conditions/condition-values.d.ts.map +1 -0
- package/dist/module/conditions/condition-values.js +106 -0
- package/dist/module/conditions/condition-values.js.map +1 -0
- package/dist/module/conditions/condition.d.ts +15 -0
- package/dist/module/conditions/condition.d.ts.map +1 -0
- package/dist/module/conditions/condition.js +40 -0
- package/dist/module/conditions/condition.js.map +1 -0
- package/dist/module/conditions/helpers.d.ts +3 -0
- package/dist/module/conditions/helpers.d.ts.map +1 -0
- package/dist/module/conditions/helpers.js +12 -0
- package/dist/module/conditions/helpers.js.map +1 -0
- package/dist/module/conditions/index.d.ts +11 -0
- package/dist/module/conditions/index.d.ts.map +1 -0
- package/dist/module/conditions/index.js +140 -0
- package/dist/module/conditions/index.js.map +1 -0
- package/dist/module/conditions/inline-condition-model.d.ts +86 -0
- package/dist/module/conditions/inline-condition-model.d.ts.map +1 -0
- package/dist/module/conditions/inline-condition-model.js +384 -0
- package/dist/module/conditions/inline-condition-model.js.map +1 -0
- package/dist/module/conditions/inline-condition-operators.d.ts +175 -0
- package/dist/module/conditions/inline-condition-operators.d.ts.map +1 -0
- package/dist/module/conditions/inline-condition-operators.js +119 -0
- package/dist/module/conditions/inline-condition-operators.js.map +1 -0
- package/dist/module/conditions/inline-condition-values.d.ts +93 -0
- package/dist/module/conditions/inline-condition-values.d.ts.map +1 -0
- package/dist/module/conditions/inline-condition-values.js +134 -0
- package/dist/module/conditions/inline-condition-values.js.map +1 -0
- package/dist/module/conditions/types.d.ts +38 -0
- package/dist/module/conditions/types.d.ts.map +1 -0
- package/dist/module/conditions/types.js +10 -0
- package/dist/module/conditions/types.js.map +1 -0
- package/dist/module/data-model/conditions-wrapper.d.ts +19 -0
- package/dist/module/data-model/conditions-wrapper.d.ts.map +1 -0
- package/dist/module/data-model/conditions-wrapper.js +30 -0
- package/dist/module/data-model/conditions-wrapper.js.map +1 -0
- package/dist/module/data-model/index.d.ts +4 -0
- package/dist/module/data-model/index.d.ts.map +1 -0
- package/dist/module/data-model/index.js +55 -0
- package/dist/module/data-model/index.js.map +1 -0
- package/dist/module/data-model/input-wrapper.d.ts +16 -0
- package/dist/module/data-model/input-wrapper.d.ts.map +1 -0
- package/dist/module/data-model/input-wrapper.js +25 -0
- package/dist/module/data-model/input-wrapper.js.map +1 -0
- package/dist/module/data-model/types.d.ts +153 -0
- package/dist/module/data-model/types.d.ts.map +1 -0
- package/dist/module/data-model/types.js +20 -0
- package/dist/module/data-model/types.js.map +1 -0
- package/dist/module/form/form-configuration.d.ts +8 -0
- package/dist/module/form/form-configuration.d.ts.map +1 -0
- package/dist/module/form/form-configuration.js +17 -0
- package/dist/module/form/form-configuration.js.map +1 -0
- package/dist/module/form/index.d.ts +2 -0
- package/dist/module/form/index.d.ts.map +1 -0
- package/dist/module/form/index.js +11 -0
- package/dist/module/form/index.js.map +1 -0
- package/dist/module/index.d.ts +12 -0
- package/dist/module/index.d.ts.map +1 -0
- package/dist/module/index.js +135 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/migration/index.d.ts +2 -0
- package/dist/module/migration/index.d.ts.map +1 -0
- package/dist/module/migration/index.js +11 -0
- package/dist/module/migration/index.js.map +1 -0
- package/dist/module/migration/migration.0-2.d.ts +3 -0
- package/dist/module/migration/migration.0-2.d.ts.map +1 -0
- package/dist/module/migration/migration.0-2.js +42 -0
- package/dist/module/migration/migration.0-2.js.map +1 -0
- package/dist/module/migration/migration.1-2.d.ts +3 -0
- package/dist/module/migration/migration.1-2.d.ts.map +1 -0
- package/dist/module/migration/migration.1-2.js +90 -0
- package/dist/module/migration/migration.1-2.js.map +1 -0
- package/dist/module/migration/types.d.ts +2 -0
- package/dist/module/migration/types.d.ts.map +1 -0
- package/dist/module/migration/types.js +1 -0
- package/dist/module/migration/types.js.map +1 -0
- package/dist/module/migration/whichMigrations.d.ts +7 -0
- package/dist/module/migration/whichMigrations.d.ts.map +1 -0
- package/dist/module/migration/whichMigrations.js +26 -0
- package/dist/module/migration/whichMigrations.js.map +1 -0
- package/dist/module/schema/index.d.ts +2 -0
- package/dist/module/schema/index.d.ts.map +1 -0
- package/dist/module/schema/index.js +17 -0
- package/dist/module/schema/index.js.map +1 -0
- package/dist/module/schema/schema.d.ts +20 -0
- package/dist/module/schema/schema.d.ts.map +1 -0
- package/dist/module/schema/schema.js +239 -0
- package/dist/module/schema/schema.js.map +1 -0
- package/dist/module/utils/helpers.d.ts +9 -0
- package/dist/module/utils/helpers.d.ts.map +1 -0
- package/dist/module/utils/helpers.js +35 -0
- package/dist/module/utils/helpers.js.map +1 -0
- package/dist/module/utils/logger.d.ts +11 -0
- package/dist/module/utils/logger.d.ts.map +1 -0
- package/dist/module/utils/logger.js +27 -0
- package/dist/module/utils/logger.js.map +1 -0
- package/package.json +35 -0
- package/src/components/component-types.ts +229 -0
- package/src/components/conditional-component-types.ts +14 -0
- package/src/components/index.ts +3 -0
- package/src/components/types.ts +362 -0
- package/src/conditions/condition-abstract.ts +59 -0
- package/src/conditions/condition-field.ts +29 -0
- package/src/conditions/condition-group-def.ts +29 -0
- package/src/conditions/condition-group.ts +61 -0
- package/src/conditions/condition-model.ts +314 -0
- package/src/conditions/condition-operators.ts +176 -0
- package/src/conditions/condition-ref.ts +47 -0
- package/src/conditions/condition-value-abstract.ts +31 -0
- package/src/conditions/condition-value-registration.ts +18 -0
- package/src/conditions/condition-values.ts +146 -0
- package/src/conditions/condition.ts +64 -0
- package/src/conditions/helpers.ts +7 -0
- package/src/conditions/index.ts +27 -0
- package/src/conditions/inline-condition-model.ts +550 -0
- package/src/conditions/inline-condition-operators.ts +166 -0
- package/src/conditions/inline-condition-values.ts +153 -0
- package/src/conditions/types.ts +30 -0
- package/src/data-model/conditions-wrapper.ts +42 -0
- package/src/data-model/index.ts +3 -0
- package/src/data-model/input-wrapper.ts +40 -0
- package/src/data-model/types.ts +179 -0
- package/src/form/form-configuration.ts +21 -0
- package/src/form/index.ts +1 -0
- package/src/index.ts +11 -0
- package/src/migration/index.ts +1 -0
- package/src/migration/migration.0-2.ts +29 -0
- package/src/migration/migration.1-2.ts +105 -0
- package/src/migration/types.ts +1 -0
- package/src/migration/whichMigrations.ts +23 -0
- package/src/schema/index.ts +1 -0
- package/src/schema/schema.ts +300 -0
- package/src/utils/helpers.ts +37 -0
- package/src/utils/logger.ts +29 -0
@@ -0,0 +1,140 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
Object.defineProperty(exports, "Condition", {
|
5
|
+
enumerable: true,
|
6
|
+
get: function () {
|
7
|
+
return _condition.Condition;
|
8
|
+
}
|
9
|
+
});
|
10
|
+
Object.defineProperty(exports, "ConditionField", {
|
11
|
+
enumerable: true,
|
12
|
+
get: function () {
|
13
|
+
return _conditionField.ConditionField;
|
14
|
+
}
|
15
|
+
});
|
16
|
+
Object.defineProperty(exports, "ConditionGroup", {
|
17
|
+
enumerable: true,
|
18
|
+
get: function () {
|
19
|
+
return _conditionGroup.ConditionGroup;
|
20
|
+
}
|
21
|
+
});
|
22
|
+
Object.defineProperty(exports, "ConditionGroupDef", {
|
23
|
+
enumerable: true,
|
24
|
+
get: function () {
|
25
|
+
return _conditionGroupDef.ConditionGroupDef;
|
26
|
+
}
|
27
|
+
});
|
28
|
+
Object.defineProperty(exports, "ConditionRef", {
|
29
|
+
enumerable: true,
|
30
|
+
get: function () {
|
31
|
+
return _conditionRef.ConditionRef;
|
32
|
+
}
|
33
|
+
});
|
34
|
+
Object.defineProperty(exports, "ConditionValue", {
|
35
|
+
enumerable: true,
|
36
|
+
get: function () {
|
37
|
+
return _conditionValues.ConditionValue;
|
38
|
+
}
|
39
|
+
});
|
40
|
+
Object.defineProperty(exports, "ConditionsModel", {
|
41
|
+
enumerable: true,
|
42
|
+
get: function () {
|
43
|
+
return _conditionModel.ConditionsModel;
|
44
|
+
}
|
45
|
+
});
|
46
|
+
Object.defineProperty(exports, "Coordinator", {
|
47
|
+
enumerable: true,
|
48
|
+
get: function () {
|
49
|
+
return _types.Coordinator;
|
50
|
+
}
|
51
|
+
});
|
52
|
+
Object.defineProperty(exports, "DateDirections", {
|
53
|
+
enumerable: true,
|
54
|
+
get: function () {
|
55
|
+
return _conditionValues.DateDirections;
|
56
|
+
}
|
57
|
+
});
|
58
|
+
Object.defineProperty(exports, "RelativeTimeValue", {
|
59
|
+
enumerable: true,
|
60
|
+
get: function () {
|
61
|
+
return _conditionValues.RelativeTimeValue;
|
62
|
+
}
|
63
|
+
});
|
64
|
+
Object.defineProperty(exports, "absoluteDateOrTimeOperatorNames", {
|
65
|
+
enumerable: true,
|
66
|
+
get: function () {
|
67
|
+
return _conditionOperators.absoluteDateOrTimeOperatorNames;
|
68
|
+
}
|
69
|
+
});
|
70
|
+
Object.defineProperty(exports, "conditionValueFrom", {
|
71
|
+
enumerable: true,
|
72
|
+
get: function () {
|
73
|
+
return _conditionValues.conditionValueFrom;
|
74
|
+
}
|
75
|
+
});
|
76
|
+
Object.defineProperty(exports, "dateTimeUnits", {
|
77
|
+
enumerable: true,
|
78
|
+
get: function () {
|
79
|
+
return _conditionValues.dateTimeUnits;
|
80
|
+
}
|
81
|
+
});
|
82
|
+
Object.defineProperty(exports, "dateUnits", {
|
83
|
+
enumerable: true,
|
84
|
+
get: function () {
|
85
|
+
return _conditionValues.dateUnits;
|
86
|
+
}
|
87
|
+
});
|
88
|
+
Object.defineProperty(exports, "getExpression", {
|
89
|
+
enumerable: true,
|
90
|
+
get: function () {
|
91
|
+
return _conditionOperators.getExpression;
|
92
|
+
}
|
93
|
+
});
|
94
|
+
Object.defineProperty(exports, "getOperatorConfig", {
|
95
|
+
enumerable: true,
|
96
|
+
get: function () {
|
97
|
+
return _conditionOperators.getOperatorConfig;
|
98
|
+
}
|
99
|
+
});
|
100
|
+
Object.defineProperty(exports, "getOperatorNames", {
|
101
|
+
enumerable: true,
|
102
|
+
get: function () {
|
103
|
+
return _conditionOperators.getOperatorNames;
|
104
|
+
}
|
105
|
+
});
|
106
|
+
Object.defineProperty(exports, "relativeDateOrTimeOperatorNames", {
|
107
|
+
enumerable: true,
|
108
|
+
get: function () {
|
109
|
+
return _conditionOperators.relativeDateOrTimeOperatorNames;
|
110
|
+
}
|
111
|
+
});
|
112
|
+
Object.defineProperty(exports, "timeUnits", {
|
113
|
+
enumerable: true,
|
114
|
+
get: function () {
|
115
|
+
return _conditionValues.timeUnits;
|
116
|
+
}
|
117
|
+
});
|
118
|
+
Object.defineProperty(exports, "toExpression", {
|
119
|
+
enumerable: true,
|
120
|
+
get: function () {
|
121
|
+
return _helpers.toExpression;
|
122
|
+
}
|
123
|
+
});
|
124
|
+
Object.defineProperty(exports, "toPresentationString", {
|
125
|
+
enumerable: true,
|
126
|
+
get: function () {
|
127
|
+
return _helpers.toPresentationString;
|
128
|
+
}
|
129
|
+
});
|
130
|
+
var _conditionOperators = require("./condition-operators");
|
131
|
+
var _conditionValues = require("./condition-values");
|
132
|
+
var _conditionField = require("./condition-field");
|
133
|
+
var _condition = require("./condition");
|
134
|
+
var _conditionRef = require("./condition-ref");
|
135
|
+
var _conditionGroup = require("./condition-group");
|
136
|
+
var _conditionModel = require("./condition-model");
|
137
|
+
var _conditionGroupDef = require("./condition-group-def");
|
138
|
+
var _helpers = require("./helpers");
|
139
|
+
var _types = require("./types");
|
140
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","names":["_conditionOperators","require","_conditionValues","_conditionField","_condition","_conditionRef","_conditionGroup","_conditionModel","_conditionGroupDef","_helpers","_types"],"sources":["../../../src/conditions/index.ts"],"sourcesContent":["export {\n getExpression,\n getOperatorConfig,\n getOperatorNames,\n absoluteDateOrTimeOperatorNames,\n relativeDateOrTimeOperatorNames\n} from './condition-operators'\n\nexport {\n timeUnits,\n dateUnits,\n dateTimeUnits,\n ConditionValue,\n DateDirections,\n RelativeTimeValue,\n conditionValueFrom\n} from './condition-values'\n\nexport { ConditionField } from './condition-field'\nexport { Condition } from './condition'\nexport { ConditionRef } from './condition-ref'\nexport { ConditionGroup } from './condition-group'\nexport { ConditionsModel } from './condition-model'\nexport { ConditionGroupDef } from './condition-group-def'\nexport { toExpression, toPresentationString } from './helpers'\n\nexport { Coordinator } from './types'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAQA,IAAAC,gBAAA,GAAAD,OAAA;AAUA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAEA,IAAAS,MAAA,GAAAT,OAAA"}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
export declare const coordinators: {
|
2
|
+
AND: string;
|
3
|
+
OR: string;
|
4
|
+
};
|
5
|
+
export declare class ConditionsModel {
|
6
|
+
#private;
|
7
|
+
constructor();
|
8
|
+
clone(): ConditionsModel;
|
9
|
+
clear(): this;
|
10
|
+
set name(name: any);
|
11
|
+
get name(): any;
|
12
|
+
add(condition: any): this;
|
13
|
+
replace(index: any, condition: any): this;
|
14
|
+
remove(indexes: any): this;
|
15
|
+
addGroups(groupDefs: any): this;
|
16
|
+
splitGroup(index: any): this;
|
17
|
+
moveEarlier(index: any): this;
|
18
|
+
moveLater(index: any): this;
|
19
|
+
switchCoordinators(): void;
|
20
|
+
get asPerUserGroupings(): any[];
|
21
|
+
get hasConditions(): boolean;
|
22
|
+
get lastIndex(): number;
|
23
|
+
toPresentationString(): any;
|
24
|
+
toExpression(): any;
|
25
|
+
_applyGroups(userGroupedConditions: any): any;
|
26
|
+
_group(conditions: any, groupDefs: any): any;
|
27
|
+
_ungroup(conditions: any, splitIndex: any): any;
|
28
|
+
_autoGroupDefs(conditions: any): GroupDef[];
|
29
|
+
toJSON(): {
|
30
|
+
name: any;
|
31
|
+
conditions: any;
|
32
|
+
};
|
33
|
+
static from(obj: any): ConditionsModel;
|
34
|
+
}
|
35
|
+
export declare class GroupDef {
|
36
|
+
first: any;
|
37
|
+
last: any;
|
38
|
+
constructor(first: any, last: any);
|
39
|
+
contains(index: any): boolean;
|
40
|
+
startsWith(index: any): boolean;
|
41
|
+
applyTo(conditions: any): any[];
|
42
|
+
}
|
43
|
+
export declare function toPresentationString(condition: any): string;
|
44
|
+
export declare function toExpression(condition: any): string;
|
45
|
+
export declare class Field {
|
46
|
+
name: any;
|
47
|
+
type: any;
|
48
|
+
display: any;
|
49
|
+
constructor(name: any, type: any, display: any);
|
50
|
+
static from(obj: any): Field;
|
51
|
+
}
|
52
|
+
declare class AbstractCondition {
|
53
|
+
coordinator: any;
|
54
|
+
constructor(coordinator: any);
|
55
|
+
coordinatorString(): string;
|
56
|
+
getCoordinator(): any;
|
57
|
+
setCoordinator(coordinator: any): void;
|
58
|
+
isGroup(): boolean;
|
59
|
+
getGroupedConditions(): this[];
|
60
|
+
_asFirstCondition(): void;
|
61
|
+
asFirstCondition(): void;
|
62
|
+
clone(): void;
|
63
|
+
conditionString(): void;
|
64
|
+
conditionExpression(): void;
|
65
|
+
}
|
66
|
+
export declare class Condition extends AbstractCondition {
|
67
|
+
field: any;
|
68
|
+
operator: any;
|
69
|
+
value: any;
|
70
|
+
constructor(field: any, operator: any, value: any, coordinator: any);
|
71
|
+
asFirstCondition(): this;
|
72
|
+
conditionString(): string;
|
73
|
+
conditionExpression(): any;
|
74
|
+
clone(): Condition;
|
75
|
+
}
|
76
|
+
export declare class ConditionRef extends AbstractCondition {
|
77
|
+
conditionName: any;
|
78
|
+
conditionDisplayName: any;
|
79
|
+
constructor(conditionName: any, conditionDisplayName: any, coordinator: any);
|
80
|
+
asFirstCondition(): this;
|
81
|
+
conditionString(): string;
|
82
|
+
conditionExpression(): any;
|
83
|
+
clone(): ConditionRef;
|
84
|
+
}
|
85
|
+
export {};
|
86
|
+
//# sourceMappingURL=inline-condition-model.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"inline-condition-model.d.ts","sourceRoot":"","sources":["../../../src/conditions/inline-condition-model.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY;;;CAGxB,CAAA;AAED,qBAAa,eAAe;;;IAU1B,KAAK;IAYL,KAAK;IAOL,IAAI,IAAI,CAAC,IAAI,KAAA,EAEZ;IAED,IAAI,IAAI,QAEP;IAED,GAAG,CAAC,SAAS,KAAA;IAYb,OAAO,CAAC,KAAK,KAAA,EAAE,SAAS,KAAA;IAgBxB,MAAM,CAAC,OAAO,KAAA;IAWd,SAAS,CAAC,SAAS,KAAA;IASnB,UAAU,CAAC,KAAK,KAAA;IAShB,WAAW,CAAC,KAAK,KAAA;IAejB,SAAS,CAAC,KAAK,KAAA;IAef,kBAAkB;IAOlB,IAAI,kBAAkB,UAErB;IAED,IAAI,aAAa,YAEhB;IAED,IAAI,SAAS,WAEZ;IAED,oBAAoB;IAMpB,YAAY;IAMZ,YAAY,CAAC,qBAAqB,KAAA;IAiBlC,MAAM,CAAC,UAAU,KAAA,EAAE,SAAS,KAAA;IAe5B,QAAQ,CAAC,UAAU,KAAA,EAAE,UAAU,KAAA;IAa/B,cAAc,CAAC,UAAU,KAAA;IA8BzB,MAAM;;;;IASN,MAAM,CAAC,IAAI,CAAC,GAAG,KAAA;CAchB;AAuBD,qBAAa,QAAQ;IACnB,KAAK,MAAA;IACL,IAAI,MAAA;gBAEQ,KAAK,KAAA,EAAE,IAAI,KAAA;IAUvB,QAAQ,CAAC,KAAK,KAAA;IAId,UAAU,CAAC,KAAK,KAAA;IAIhB,OAAO,CAAC,UAAU,KAAA;CAGnB;AA4DD,wBAAgB,oBAAoB,CAAC,SAAS,KAAA,UAE7C;AAED,wBAAgB,YAAY,CAAC,SAAS,KAAA,UAErC;AAED,qBAAa,KAAK;IAChB,IAAI,MAAA;IACJ,IAAI,MAAA;IACJ,OAAO,MAAA;gBAEK,IAAI,KAAA,EAAE,IAAI,KAAA,EAAE,OAAO,KAAA;IAe/B,MAAM,CAAC,IAAI,CAAC,GAAG,KAAA;CAGhB;AAED,cAAM,iBAAiB;IACrB,WAAW,MAAA;gBAEC,WAAW,KAAA;IAOvB,iBAAiB;IAIjB,cAAc;IAId,cAAc,CAAC,WAAW,KAAA;IAI1B,OAAO;IAIP,oBAAoB;IAIpB,iBAAiB;IAIjB,gBAAgB;IAMhB,KAAK;IAML,eAAe;IAMf,mBAAmB;CAKpB;AAED,qBAAa,SAAU,SAAQ,iBAAiB;IAC9C,KAAK,MAAA;IACL,QAAQ,MAAA;IACR,KAAK,MAAA;gBAEO,KAAK,KAAA,EAAE,QAAQ,KAAA,EAAE,KAAK,KAAA,EAAE,WAAW,KAAA;IAgB/C,gBAAgB;IAKhB,eAAe;IAMf,mBAAmB;IASnB,KAAK;CAQN;AAED,qBAAa,YAAa,SAAQ,iBAAiB;IACjD,aAAa,MAAA;IACb,oBAAoB,MAAA;gBAER,aAAa,KAAA,EAAE,oBAAoB,KAAA,EAAE,WAAW,KAAA;IAY5D,gBAAgB;IAKhB,eAAe;IAIf,mBAAmB;IAInB,KAAK;CAON"}
|
@@ -0,0 +1,384 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.coordinators = exports.GroupDef = exports.Field = exports.ConditionsModel = exports.ConditionRef = exports.Condition = void 0;
|
5
|
+
exports.toExpression = toExpression;
|
6
|
+
exports.toPresentationString = toPresentationString;
|
7
|
+
var _componentTypes = require("../components/component-types");
|
8
|
+
var _inlineConditionOperators = require("./inline-condition-operators");
|
9
|
+
var _inlineConditionValues = require("./inline-condition-values");
|
10
|
+
const coordinators = exports.coordinators = {
|
11
|
+
AND: 'and',
|
12
|
+
OR: 'or'
|
13
|
+
};
|
14
|
+
class ConditionsModel {
|
15
|
+
#groupedConditions;
|
16
|
+
#userGroupedConditions;
|
17
|
+
#conditionName;
|
18
|
+
constructor() {
|
19
|
+
this.#groupedConditions = [];
|
20
|
+
this.#userGroupedConditions = [];
|
21
|
+
}
|
22
|
+
clone() {
|
23
|
+
const toReturn = new ConditionsModel();
|
24
|
+
toReturn.#groupedConditions = this.#groupedConditions.map(it => it.clone());
|
25
|
+
toReturn.#userGroupedConditions = this.#userGroupedConditions.map(it => it.clone());
|
26
|
+
toReturn.#conditionName = this.#conditionName;
|
27
|
+
return toReturn;
|
28
|
+
}
|
29
|
+
clear() {
|
30
|
+
this.#userGroupedConditions = [];
|
31
|
+
this.#groupedConditions = [];
|
32
|
+
this.#conditionName = undefined;
|
33
|
+
return this;
|
34
|
+
}
|
35
|
+
set name(name) {
|
36
|
+
this.#conditionName = name;
|
37
|
+
}
|
38
|
+
get name() {
|
39
|
+
return this.#conditionName;
|
40
|
+
}
|
41
|
+
add(condition) {
|
42
|
+
const coordinatorExpected = this.#userGroupedConditions.length !== 0;
|
43
|
+
if (condition.getCoordinator() && !coordinatorExpected) {
|
44
|
+
throw Error('No coordinator allowed on the first condition');
|
45
|
+
} else if (!condition.getCoordinator() && coordinatorExpected) {
|
46
|
+
throw Error('Coordinator must be present on subsequent conditions');
|
47
|
+
}
|
48
|
+
this.#userGroupedConditions.push(condition);
|
49
|
+
this.#groupedConditions = this._applyGroups(this.#userGroupedConditions);
|
50
|
+
return this;
|
51
|
+
}
|
52
|
+
replace(index, condition) {
|
53
|
+
const coordinatorExpected = index !== 0;
|
54
|
+
if (condition.getCoordinator() && !coordinatorExpected) {
|
55
|
+
throw Error('No coordinator allowed on the first condition');
|
56
|
+
} else if (!condition.getCoordinator() && coordinatorExpected) {
|
57
|
+
throw Error('Coordinator must be present on subsequent conditions');
|
58
|
+
} else if (index >= this.#userGroupedConditions.length) {
|
59
|
+
throw Error(`Cannot replace condition ${index} as no such condition exists`);
|
60
|
+
}
|
61
|
+
this.#userGroupedConditions.splice(index, 1, condition);
|
62
|
+
this.#groupedConditions = this._applyGroups(this.#userGroupedConditions);
|
63
|
+
return this;
|
64
|
+
}
|
65
|
+
remove(indexes) {
|
66
|
+
this.#userGroupedConditions = this.#userGroupedConditions.filter((_condition, index) => !indexes.includes(index)).map((condition, index) => index === 0 ? condition.asFirstCondition() : condition);
|
67
|
+
this.#groupedConditions = this._applyGroups(this.#userGroupedConditions);
|
68
|
+
return this;
|
69
|
+
}
|
70
|
+
addGroups(groupDefs) {
|
71
|
+
this.#userGroupedConditions = this._group(this.#userGroupedConditions, groupDefs);
|
72
|
+
this.#groupedConditions = this._applyGroups(this.#userGroupedConditions);
|
73
|
+
return this;
|
74
|
+
}
|
75
|
+
splitGroup(index) {
|
76
|
+
this.#userGroupedConditions = this._ungroup(this.#userGroupedConditions, index);
|
77
|
+
this.#groupedConditions = this._applyGroups(this.#userGroupedConditions);
|
78
|
+
return this;
|
79
|
+
}
|
80
|
+
moveEarlier(index) {
|
81
|
+
if (index > 0 && index < this.#userGroupedConditions.length) {
|
82
|
+
this.#userGroupedConditions.splice(index - 1, 0, this.#userGroupedConditions.splice(index, 1)[0]);
|
83
|
+
if (index === 1) {
|
84
|
+
this.switchCoordinators();
|
85
|
+
}
|
86
|
+
this.#groupedConditions = this._applyGroups(this.#userGroupedConditions);
|
87
|
+
}
|
88
|
+
return this;
|
89
|
+
}
|
90
|
+
moveLater(index) {
|
91
|
+
if (index >= 0 && index < this.#userGroupedConditions.length - 1) {
|
92
|
+
this.#userGroupedConditions.splice(index + 1, 0, this.#userGroupedConditions.splice(index, 1)[0]);
|
93
|
+
if (index === 0) {
|
94
|
+
this.switchCoordinators();
|
95
|
+
}
|
96
|
+
this.#groupedConditions = this._applyGroups(this.#userGroupedConditions);
|
97
|
+
}
|
98
|
+
return this;
|
99
|
+
}
|
100
|
+
switchCoordinators() {
|
101
|
+
this.#userGroupedConditions[1].setCoordinator(this.#userGroupedConditions[0].getCoordinator());
|
102
|
+
this.#userGroupedConditions[0].setCoordinator(undefined);
|
103
|
+
}
|
104
|
+
get asPerUserGroupings() {
|
105
|
+
return [...this.#userGroupedConditions];
|
106
|
+
}
|
107
|
+
get hasConditions() {
|
108
|
+
return this.#userGroupedConditions.length > 0;
|
109
|
+
}
|
110
|
+
get lastIndex() {
|
111
|
+
return this.#userGroupedConditions.length - 1;
|
112
|
+
}
|
113
|
+
toPresentationString() {
|
114
|
+
return this.#groupedConditions.map(condition => toPresentationString(condition)).join(' ');
|
115
|
+
}
|
116
|
+
toExpression() {
|
117
|
+
return this.#groupedConditions.map(condition => toExpression(condition)).join(' ');
|
118
|
+
}
|
119
|
+
_applyGroups(userGroupedConditions) {
|
120
|
+
const correctedUserGroups = userGroupedConditions.map(condition => condition instanceof ConditionGroup && condition.conditions.length > 2 ? new ConditionGroup(this._group(condition.conditions, this._autoGroupDefs(condition.conditions))) : condition);
|
121
|
+
return this._group(correctedUserGroups, this._autoGroupDefs(correctedUserGroups));
|
122
|
+
}
|
123
|
+
_group(conditions, groupDefs) {
|
124
|
+
return conditions.reduce((groups, condition, index, conditions) => {
|
125
|
+
const groupDef = groupDefs.find(groupDef => groupDef.contains(index));
|
126
|
+
if (groupDef) {
|
127
|
+
if (groupDef.startsWith(index)) {
|
128
|
+
const groupConditions = groupDef.applyTo(conditions);
|
129
|
+
groups.push(new ConditionGroup(groupConditions));
|
130
|
+
}
|
131
|
+
} else {
|
132
|
+
groups.push(condition);
|
133
|
+
}
|
134
|
+
return groups;
|
135
|
+
}, []);
|
136
|
+
}
|
137
|
+
_ungroup(conditions, splitIndex) {
|
138
|
+
if (conditions[splitIndex].isGroup()) {
|
139
|
+
const copy = [...conditions];
|
140
|
+
copy.splice(splitIndex, 1, ...conditions[splitIndex].getGroupedConditions());
|
141
|
+
return copy;
|
142
|
+
}
|
143
|
+
return conditions;
|
144
|
+
}
|
145
|
+
_autoGroupDefs(conditions) {
|
146
|
+
const orPositions = [];
|
147
|
+
conditions.forEach((condition, index) => {
|
148
|
+
if (condition.getCoordinator() === coordinators.OR) {
|
149
|
+
orPositions.push(index);
|
150
|
+
}
|
151
|
+
});
|
152
|
+
const hasAnd = !!conditions.find(condition => condition.getCoordinator() === coordinators.AND);
|
153
|
+
const hasOr = orPositions.length > 0;
|
154
|
+
if (hasAnd && hasOr) {
|
155
|
+
let start = 0;
|
156
|
+
const groupDefs = [];
|
157
|
+
orPositions.forEach((position, index) => {
|
158
|
+
if (start < position - 1) {
|
159
|
+
groupDefs.push(new GroupDef(start, position - 1));
|
160
|
+
}
|
161
|
+
const thisIsTheLastOr = orPositions.length === index + 1;
|
162
|
+
const thereAreMoreConditions = conditions.length - 1 > position;
|
163
|
+
if (thisIsTheLastOr && thereAreMoreConditions) {
|
164
|
+
groupDefs.push(new GroupDef(position, conditions.length - 1));
|
165
|
+
}
|
166
|
+
start = position;
|
167
|
+
});
|
168
|
+
return groupDefs;
|
169
|
+
}
|
170
|
+
return [];
|
171
|
+
}
|
172
|
+
toJSON() {
|
173
|
+
const name = this.#conditionName;
|
174
|
+
const conditions = this.#userGroupedConditions;
|
175
|
+
return {
|
176
|
+
name,
|
177
|
+
conditions: conditions.map(it => it.clone())
|
178
|
+
};
|
179
|
+
}
|
180
|
+
static from(obj) {
|
181
|
+
if (obj instanceof ConditionsModel) {
|
182
|
+
return obj;
|
183
|
+
}
|
184
|
+
const toReturn = new ConditionsModel();
|
185
|
+
toReturn.#conditionName = obj.name;
|
186
|
+
toReturn.#userGroupedConditions = obj.conditions.map(it => conditionFrom(it));
|
187
|
+
toReturn.#groupedConditions = toReturn._applyGroups(toReturn.#userGroupedConditions);
|
188
|
+
return toReturn;
|
189
|
+
}
|
190
|
+
}
|
191
|
+
exports.ConditionsModel = ConditionsModel;
|
192
|
+
function conditionFrom(it) {
|
193
|
+
if (it.conditions) {
|
194
|
+
return new ConditionGroup(it.conditions.map(condition => conditionFrom(condition)));
|
195
|
+
}
|
196
|
+
if (it.conditionName) {
|
197
|
+
return new ConditionRef(it.conditionName, it.conditionDisplayName, it.coordinator);
|
198
|
+
}
|
199
|
+
return new Condition(Field.from(it.field), it.operator, (0, _inlineConditionValues.valueFrom)(it.value), it.coordinator);
|
200
|
+
}
|
201
|
+
class GroupDef {
|
202
|
+
constructor(first, last) {
|
203
|
+
if (typeof first !== 'number' || typeof last !== 'number') {
|
204
|
+
throw Error(`Cannot construct a group from ${first} and ${last}`);
|
205
|
+
} else if (first >= last) {
|
206
|
+
throw Error(`Last (${last}) must be greater than first (${first})`);
|
207
|
+
}
|
208
|
+
this.first = first;
|
209
|
+
this.last = last;
|
210
|
+
}
|
211
|
+
contains(index) {
|
212
|
+
return this.first <= index && this.last >= index;
|
213
|
+
}
|
214
|
+
startsWith(index) {
|
215
|
+
return this.first === index;
|
216
|
+
}
|
217
|
+
applyTo(conditions) {
|
218
|
+
return [...conditions].splice(this.first, this.last - this.first + 1);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
exports.GroupDef = GroupDef;
|
222
|
+
class ConditionGroup {
|
223
|
+
constructor(conditions) {
|
224
|
+
if (!Array.isArray(conditions) || conditions.length < 2) {
|
225
|
+
throw Error('Cannot construct a condition group from a single condition');
|
226
|
+
}
|
227
|
+
this.conditions = conditions;
|
228
|
+
}
|
229
|
+
coordinatorString() {
|
230
|
+
return this.conditions[0].coordinatorString();
|
231
|
+
}
|
232
|
+
conditionString() {
|
233
|
+
const copy = [...this.conditions];
|
234
|
+
copy.splice(0, 1);
|
235
|
+
return `(${this.conditions[0].conditionString()} ${copy.map(condition => toPresentationString(condition)).join(' ')})`;
|
236
|
+
}
|
237
|
+
conditionExpression() {
|
238
|
+
const copy = [...this.conditions];
|
239
|
+
copy.splice(0, 1);
|
240
|
+
return `(${this.conditions[0].conditionExpression()} ${copy.map(condition => toExpression(condition)).join(' ')})`;
|
241
|
+
}
|
242
|
+
asFirstCondition() {
|
243
|
+
this.conditions[0].asFirstCondition();
|
244
|
+
return this;
|
245
|
+
}
|
246
|
+
getCoordinator() {
|
247
|
+
return this.conditions[0].getCoordinator();
|
248
|
+
}
|
249
|
+
setCoordinator(coordinator) {
|
250
|
+
this.conditions[0].setCoordinator(coordinator);
|
251
|
+
}
|
252
|
+
isGroup() {
|
253
|
+
return true;
|
254
|
+
}
|
255
|
+
getGroupedConditions() {
|
256
|
+
return this.conditions.map(condition => condition.clone());
|
257
|
+
}
|
258
|
+
clone() {
|
259
|
+
return new ConditionGroup(this.conditions.map(condition => condition.clone()));
|
260
|
+
}
|
261
|
+
}
|
262
|
+
function toPresentationString(condition) {
|
263
|
+
return `${condition.coordinatorString()}${condition.conditionString()}`;
|
264
|
+
}
|
265
|
+
function toExpression(condition) {
|
266
|
+
return `${condition.coordinatorString()}${condition.conditionExpression()}`;
|
267
|
+
}
|
268
|
+
class Field {
|
269
|
+
constructor(name, type, display) {
|
270
|
+
if (!name || typeof name !== 'string') {
|
271
|
+
throw Error(`name ${name} is not valid`);
|
272
|
+
}
|
273
|
+
if (!_componentTypes.ComponentTypes.find(componentType => componentType.name === type)) {
|
274
|
+
throw Error(`type ${type} is not valid`);
|
275
|
+
}
|
276
|
+
if (!display || typeof display !== 'string') {
|
277
|
+
throw Error(`display ${display} is not valid`);
|
278
|
+
}
|
279
|
+
this.name = name;
|
280
|
+
this.type = type;
|
281
|
+
this.display = display;
|
282
|
+
}
|
283
|
+
static from(obj) {
|
284
|
+
return new Field(obj.name, obj.type, obj.display);
|
285
|
+
}
|
286
|
+
}
|
287
|
+
exports.Field = Field;
|
288
|
+
class AbstractCondition {
|
289
|
+
constructor(coordinator) {
|
290
|
+
if (coordinator && !Object.values(coordinators).includes(coordinator)) {
|
291
|
+
throw Error(`coordinator ${coordinator} is not a valid coordinator`);
|
292
|
+
}
|
293
|
+
this.coordinator = coordinator;
|
294
|
+
}
|
295
|
+
coordinatorString() {
|
296
|
+
return this.coordinator ? `${this.coordinator} ` : '';
|
297
|
+
}
|
298
|
+
getCoordinator() {
|
299
|
+
return this.coordinator;
|
300
|
+
}
|
301
|
+
setCoordinator(coordinator) {
|
302
|
+
this.coordinator = coordinator;
|
303
|
+
}
|
304
|
+
isGroup() {
|
305
|
+
return false;
|
306
|
+
}
|
307
|
+
getGroupedConditions() {
|
308
|
+
return [this];
|
309
|
+
}
|
310
|
+
_asFirstCondition() {
|
311
|
+
delete this.coordinator;
|
312
|
+
}
|
313
|
+
asFirstCondition() {
|
314
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
315
|
+
}
|
316
|
+
clone() {
|
317
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
318
|
+
}
|
319
|
+
conditionString() {
|
320
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
321
|
+
}
|
322
|
+
conditionExpression() {
|
323
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
324
|
+
}
|
325
|
+
}
|
326
|
+
class Condition extends AbstractCondition {
|
327
|
+
constructor(field, operator, value, coordinator) {
|
328
|
+
super(coordinator);
|
329
|
+
if (!(field instanceof Field)) {
|
330
|
+
throw Error(`field ${field} is not a valid Field object`);
|
331
|
+
}
|
332
|
+
if (typeof operator !== 'string') {
|
333
|
+
throw Error(`operator ${operator} is not a valid operator`);
|
334
|
+
}
|
335
|
+
if (!(value instanceof _inlineConditionValues.AbstractConditionValue)) {
|
336
|
+
throw Error(`value ${value} is not a valid value type`);
|
337
|
+
}
|
338
|
+
this.field = field;
|
339
|
+
this.operator = operator;
|
340
|
+
this.value = value;
|
341
|
+
}
|
342
|
+
asFirstCondition() {
|
343
|
+
this._asFirstCondition();
|
344
|
+
return this;
|
345
|
+
}
|
346
|
+
conditionString() {
|
347
|
+
return `'${this.field.display}' ${this.operator} '${this.value.toPresentationString()}'`;
|
348
|
+
}
|
349
|
+
conditionExpression() {
|
350
|
+
return (0, _inlineConditionOperators.getExpression)(this.field.type, this.field.name, this.operator, this.value);
|
351
|
+
}
|
352
|
+
clone() {
|
353
|
+
return new Condition(Field.from(this.field), this.operator, this.value.clone(), this.coordinator);
|
354
|
+
}
|
355
|
+
}
|
356
|
+
exports.Condition = Condition;
|
357
|
+
class ConditionRef extends AbstractCondition {
|
358
|
+
constructor(conditionName, conditionDisplayName, coordinator) {
|
359
|
+
super(coordinator);
|
360
|
+
if (typeof conditionName !== 'string') {
|
361
|
+
throw Error(`condition name ${conditionName} is not valid`);
|
362
|
+
}
|
363
|
+
if (typeof conditionDisplayName !== 'string') {
|
364
|
+
throw Error(`condition display name ${conditionDisplayName} is not valid`);
|
365
|
+
}
|
366
|
+
this.conditionName = conditionName;
|
367
|
+
this.conditionDisplayName = conditionDisplayName;
|
368
|
+
}
|
369
|
+
asFirstCondition() {
|
370
|
+
this._asFirstCondition();
|
371
|
+
return this;
|
372
|
+
}
|
373
|
+
conditionString() {
|
374
|
+
return `'${this.conditionDisplayName}'`;
|
375
|
+
}
|
376
|
+
conditionExpression() {
|
377
|
+
return this.conditionName;
|
378
|
+
}
|
379
|
+
clone() {
|
380
|
+
return new ConditionRef(this.conditionName, this.conditionDisplayName, this.coordinator);
|
381
|
+
}
|
382
|
+
}
|
383
|
+
exports.ConditionRef = ConditionRef;
|
384
|
+
//# sourceMappingURL=inline-condition-model.js.map
|