@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,144 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(["exports", "./condition-operators", "./condition-values", "./condition-field", "./condition", "./condition-ref", "./condition-group", "./condition-model", "./condition-group-def", "./helpers", "./types"], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require("./condition-operators"), require("./condition-values"), require("./condition-field"), require("./condition"), require("./condition-ref"), require("./condition-group"), require("./condition-model"), require("./condition-group-def"), require("./helpers"), require("./types"));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.conditionOperators, global.conditionValues, global.conditionField, global.condition, global.conditionRef, global.conditionGroup, global.conditionModel, global.conditionGroupDef, global.helpers, global.types);
|
11
|
+
global.index = mod.exports;
|
12
|
+
}
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _conditionOperators, _conditionValues, _conditionField, _condition, _conditionRef, _conditionGroup, _conditionModel, _conditionGroupDef, _helpers, _types) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
_exports.__esModule = true;
|
17
|
+
Object.defineProperty(_exports, "Condition", {
|
18
|
+
enumerable: true,
|
19
|
+
get: function () {
|
20
|
+
return _condition.Condition;
|
21
|
+
}
|
22
|
+
});
|
23
|
+
Object.defineProperty(_exports, "ConditionField", {
|
24
|
+
enumerable: true,
|
25
|
+
get: function () {
|
26
|
+
return _conditionField.ConditionField;
|
27
|
+
}
|
28
|
+
});
|
29
|
+
Object.defineProperty(_exports, "ConditionGroup", {
|
30
|
+
enumerable: true,
|
31
|
+
get: function () {
|
32
|
+
return _conditionGroup.ConditionGroup;
|
33
|
+
}
|
34
|
+
});
|
35
|
+
Object.defineProperty(_exports, "ConditionGroupDef", {
|
36
|
+
enumerable: true,
|
37
|
+
get: function () {
|
38
|
+
return _conditionGroupDef.ConditionGroupDef;
|
39
|
+
}
|
40
|
+
});
|
41
|
+
Object.defineProperty(_exports, "ConditionRef", {
|
42
|
+
enumerable: true,
|
43
|
+
get: function () {
|
44
|
+
return _conditionRef.ConditionRef;
|
45
|
+
}
|
46
|
+
});
|
47
|
+
Object.defineProperty(_exports, "ConditionValue", {
|
48
|
+
enumerable: true,
|
49
|
+
get: function () {
|
50
|
+
return _conditionValues.ConditionValue;
|
51
|
+
}
|
52
|
+
});
|
53
|
+
Object.defineProperty(_exports, "ConditionsModel", {
|
54
|
+
enumerable: true,
|
55
|
+
get: function () {
|
56
|
+
return _conditionModel.ConditionsModel;
|
57
|
+
}
|
58
|
+
});
|
59
|
+
Object.defineProperty(_exports, "Coordinator", {
|
60
|
+
enumerable: true,
|
61
|
+
get: function () {
|
62
|
+
return _types.Coordinator;
|
63
|
+
}
|
64
|
+
});
|
65
|
+
Object.defineProperty(_exports, "DateDirections", {
|
66
|
+
enumerable: true,
|
67
|
+
get: function () {
|
68
|
+
return _conditionValues.DateDirections;
|
69
|
+
}
|
70
|
+
});
|
71
|
+
Object.defineProperty(_exports, "RelativeTimeValue", {
|
72
|
+
enumerable: true,
|
73
|
+
get: function () {
|
74
|
+
return _conditionValues.RelativeTimeValue;
|
75
|
+
}
|
76
|
+
});
|
77
|
+
Object.defineProperty(_exports, "absoluteDateOrTimeOperatorNames", {
|
78
|
+
enumerable: true,
|
79
|
+
get: function () {
|
80
|
+
return _conditionOperators.absoluteDateOrTimeOperatorNames;
|
81
|
+
}
|
82
|
+
});
|
83
|
+
Object.defineProperty(_exports, "conditionValueFrom", {
|
84
|
+
enumerable: true,
|
85
|
+
get: function () {
|
86
|
+
return _conditionValues.conditionValueFrom;
|
87
|
+
}
|
88
|
+
});
|
89
|
+
Object.defineProperty(_exports, "dateTimeUnits", {
|
90
|
+
enumerable: true,
|
91
|
+
get: function () {
|
92
|
+
return _conditionValues.dateTimeUnits;
|
93
|
+
}
|
94
|
+
});
|
95
|
+
Object.defineProperty(_exports, "dateUnits", {
|
96
|
+
enumerable: true,
|
97
|
+
get: function () {
|
98
|
+
return _conditionValues.dateUnits;
|
99
|
+
}
|
100
|
+
});
|
101
|
+
Object.defineProperty(_exports, "getExpression", {
|
102
|
+
enumerable: true,
|
103
|
+
get: function () {
|
104
|
+
return _conditionOperators.getExpression;
|
105
|
+
}
|
106
|
+
});
|
107
|
+
Object.defineProperty(_exports, "getOperatorConfig", {
|
108
|
+
enumerable: true,
|
109
|
+
get: function () {
|
110
|
+
return _conditionOperators.getOperatorConfig;
|
111
|
+
}
|
112
|
+
});
|
113
|
+
Object.defineProperty(_exports, "getOperatorNames", {
|
114
|
+
enumerable: true,
|
115
|
+
get: function () {
|
116
|
+
return _conditionOperators.getOperatorNames;
|
117
|
+
}
|
118
|
+
});
|
119
|
+
Object.defineProperty(_exports, "relativeDateOrTimeOperatorNames", {
|
120
|
+
enumerable: true,
|
121
|
+
get: function () {
|
122
|
+
return _conditionOperators.relativeDateOrTimeOperatorNames;
|
123
|
+
}
|
124
|
+
});
|
125
|
+
Object.defineProperty(_exports, "timeUnits", {
|
126
|
+
enumerable: true,
|
127
|
+
get: function () {
|
128
|
+
return _conditionValues.timeUnits;
|
129
|
+
}
|
130
|
+
});
|
131
|
+
Object.defineProperty(_exports, "toExpression", {
|
132
|
+
enumerable: true,
|
133
|
+
get: function () {
|
134
|
+
return _helpers.toExpression;
|
135
|
+
}
|
136
|
+
});
|
137
|
+
Object.defineProperty(_exports, "toPresentationString", {
|
138
|
+
enumerable: true,
|
139
|
+
get: function () {
|
140
|
+
return _helpers.toPresentationString;
|
141
|
+
}
|
142
|
+
});
|
143
|
+
});
|
144
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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":""}
|
@@ -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,418 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(["exports", "../components/component-types", "./inline-condition-operators", "./inline-condition-values"], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require("../components/component-types"), require("./inline-condition-operators"), require("./inline-condition-values"));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.componentTypes, global.inlineConditionOperators, global.inlineConditionValues);
|
11
|
+
global.inlineConditionModel = mod.exports;
|
12
|
+
}
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _componentTypes, _inlineConditionOperators, _inlineConditionValues) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
_exports.__esModule = true;
|
17
|
+
_exports.coordinators = _exports.GroupDef = _exports.Field = _exports.ConditionsModel = _exports.ConditionRef = _exports.Condition = void 0;
|
18
|
+
_exports.toExpression = toExpression;
|
19
|
+
_exports.toPresentationString = toPresentationString;
|
20
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
22
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
23
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
24
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
25
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
26
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
27
|
+
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"); }
|
28
|
+
const coordinators = _exports.coordinators = {
|
29
|
+
AND: 'and',
|
30
|
+
OR: 'or'
|
31
|
+
};
|
32
|
+
var _groupedConditions = /*#__PURE__*/new WeakMap();
|
33
|
+
var _userGroupedConditions = /*#__PURE__*/new WeakMap();
|
34
|
+
var _conditionName = /*#__PURE__*/new WeakMap();
|
35
|
+
class ConditionsModel {
|
36
|
+
constructor() {
|
37
|
+
_classPrivateFieldInitSpec(this, _groupedConditions, void 0);
|
38
|
+
_classPrivateFieldInitSpec(this, _userGroupedConditions, void 0);
|
39
|
+
_classPrivateFieldInitSpec(this, _conditionName, void 0);
|
40
|
+
_classPrivateFieldSet(_groupedConditions, this, []);
|
41
|
+
_classPrivateFieldSet(_userGroupedConditions, this, []);
|
42
|
+
}
|
43
|
+
clone() {
|
44
|
+
const toReturn = new ConditionsModel();
|
45
|
+
_classPrivateFieldSet(_groupedConditions, toReturn, _classPrivateFieldGet(_groupedConditions, this).map(it => it.clone()));
|
46
|
+
_classPrivateFieldSet(_userGroupedConditions, toReturn, _classPrivateFieldGet(_userGroupedConditions, this).map(it => it.clone()));
|
47
|
+
_classPrivateFieldSet(_conditionName, toReturn, _classPrivateFieldGet(_conditionName, this));
|
48
|
+
return toReturn;
|
49
|
+
}
|
50
|
+
clear() {
|
51
|
+
_classPrivateFieldSet(_userGroupedConditions, this, []);
|
52
|
+
_classPrivateFieldSet(_groupedConditions, this, []);
|
53
|
+
_classPrivateFieldSet(_conditionName, this, undefined);
|
54
|
+
return this;
|
55
|
+
}
|
56
|
+
set name(name) {
|
57
|
+
_classPrivateFieldSet(_conditionName, this, name);
|
58
|
+
}
|
59
|
+
get name() {
|
60
|
+
return _classPrivateFieldGet(_conditionName, this);
|
61
|
+
}
|
62
|
+
add(condition) {
|
63
|
+
const coordinatorExpected = _classPrivateFieldGet(_userGroupedConditions, this).length !== 0;
|
64
|
+
if (condition.getCoordinator() && !coordinatorExpected) {
|
65
|
+
throw Error('No coordinator allowed on the first condition');
|
66
|
+
} else if (!condition.getCoordinator() && coordinatorExpected) {
|
67
|
+
throw Error('Coordinator must be present on subsequent conditions');
|
68
|
+
}
|
69
|
+
_classPrivateFieldGet(_userGroupedConditions, this).push(condition);
|
70
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
71
|
+
return this;
|
72
|
+
}
|
73
|
+
replace(index, condition) {
|
74
|
+
const coordinatorExpected = index !== 0;
|
75
|
+
if (condition.getCoordinator() && !coordinatorExpected) {
|
76
|
+
throw Error('No coordinator allowed on the first condition');
|
77
|
+
} else if (!condition.getCoordinator() && coordinatorExpected) {
|
78
|
+
throw Error('Coordinator must be present on subsequent conditions');
|
79
|
+
} else if (index >= _classPrivateFieldGet(_userGroupedConditions, this).length) {
|
80
|
+
throw Error(`Cannot replace condition ${index} as no such condition exists`);
|
81
|
+
}
|
82
|
+
_classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1, condition);
|
83
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
84
|
+
return this;
|
85
|
+
}
|
86
|
+
remove(indexes) {
|
87
|
+
_classPrivateFieldSet(_userGroupedConditions, this, _classPrivateFieldGet(_userGroupedConditions, this).filter((_condition, index) => !indexes.includes(index)).map((condition, index) => index === 0 ? condition.asFirstCondition() : condition));
|
88
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
89
|
+
return this;
|
90
|
+
}
|
91
|
+
addGroups(groupDefs) {
|
92
|
+
_classPrivateFieldSet(_userGroupedConditions, this, this._group(_classPrivateFieldGet(_userGroupedConditions, this), groupDefs));
|
93
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
94
|
+
return this;
|
95
|
+
}
|
96
|
+
splitGroup(index) {
|
97
|
+
_classPrivateFieldSet(_userGroupedConditions, this, this._ungroup(_classPrivateFieldGet(_userGroupedConditions, this), index));
|
98
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
99
|
+
return this;
|
100
|
+
}
|
101
|
+
moveEarlier(index) {
|
102
|
+
if (index > 0 && index < _classPrivateFieldGet(_userGroupedConditions, this).length) {
|
103
|
+
_classPrivateFieldGet(_userGroupedConditions, this).splice(index - 1, 0, _classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1)[0]);
|
104
|
+
if (index === 1) {
|
105
|
+
this.switchCoordinators();
|
106
|
+
}
|
107
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
108
|
+
}
|
109
|
+
return this;
|
110
|
+
}
|
111
|
+
moveLater(index) {
|
112
|
+
if (index >= 0 && index < _classPrivateFieldGet(_userGroupedConditions, this).length - 1) {
|
113
|
+
_classPrivateFieldGet(_userGroupedConditions, this).splice(index + 1, 0, _classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1)[0]);
|
114
|
+
if (index === 0) {
|
115
|
+
this.switchCoordinators();
|
116
|
+
}
|
117
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
118
|
+
}
|
119
|
+
return this;
|
120
|
+
}
|
121
|
+
switchCoordinators() {
|
122
|
+
_classPrivateFieldGet(_userGroupedConditions, this)[1].setCoordinator(_classPrivateFieldGet(_userGroupedConditions, this)[0].getCoordinator());
|
123
|
+
_classPrivateFieldGet(_userGroupedConditions, this)[0].setCoordinator(undefined);
|
124
|
+
}
|
125
|
+
get asPerUserGroupings() {
|
126
|
+
return [..._classPrivateFieldGet(_userGroupedConditions, this)];
|
127
|
+
}
|
128
|
+
get hasConditions() {
|
129
|
+
return _classPrivateFieldGet(_userGroupedConditions, this).length > 0;
|
130
|
+
}
|
131
|
+
get lastIndex() {
|
132
|
+
return _classPrivateFieldGet(_userGroupedConditions, this).length - 1;
|
133
|
+
}
|
134
|
+
toPresentationString() {
|
135
|
+
return _classPrivateFieldGet(_groupedConditions, this).map(condition => toPresentationString(condition)).join(' ');
|
136
|
+
}
|
137
|
+
toExpression() {
|
138
|
+
return _classPrivateFieldGet(_groupedConditions, this).map(condition => toExpression(condition)).join(' ');
|
139
|
+
}
|
140
|
+
_applyGroups(userGroupedConditions) {
|
141
|
+
const correctedUserGroups = userGroupedConditions.map(condition => condition instanceof ConditionGroup && condition.conditions.length > 2 ? new ConditionGroup(this._group(condition.conditions, this._autoGroupDefs(condition.conditions))) : condition);
|
142
|
+
return this._group(correctedUserGroups, this._autoGroupDefs(correctedUserGroups));
|
143
|
+
}
|
144
|
+
_group(conditions, groupDefs) {
|
145
|
+
return conditions.reduce((groups, condition, index, conditions) => {
|
146
|
+
const groupDef = groupDefs.find(groupDef => groupDef.contains(index));
|
147
|
+
if (groupDef) {
|
148
|
+
if (groupDef.startsWith(index)) {
|
149
|
+
const groupConditions = groupDef.applyTo(conditions);
|
150
|
+
groups.push(new ConditionGroup(groupConditions));
|
151
|
+
}
|
152
|
+
} else {
|
153
|
+
groups.push(condition);
|
154
|
+
}
|
155
|
+
return groups;
|
156
|
+
}, []);
|
157
|
+
}
|
158
|
+
_ungroup(conditions, splitIndex) {
|
159
|
+
if (conditions[splitIndex].isGroup()) {
|
160
|
+
const copy = [...conditions];
|
161
|
+
copy.splice(splitIndex, 1, ...conditions[splitIndex].getGroupedConditions());
|
162
|
+
return copy;
|
163
|
+
}
|
164
|
+
return conditions;
|
165
|
+
}
|
166
|
+
_autoGroupDefs(conditions) {
|
167
|
+
const orPositions = [];
|
168
|
+
conditions.forEach((condition, index) => {
|
169
|
+
if (condition.getCoordinator() === coordinators.OR) {
|
170
|
+
orPositions.push(index);
|
171
|
+
}
|
172
|
+
});
|
173
|
+
const hasAnd = !!conditions.find(condition => condition.getCoordinator() === coordinators.AND);
|
174
|
+
const hasOr = orPositions.length > 0;
|
175
|
+
if (hasAnd && hasOr) {
|
176
|
+
let start = 0;
|
177
|
+
const groupDefs = [];
|
178
|
+
orPositions.forEach((position, index) => {
|
179
|
+
if (start < position - 1) {
|
180
|
+
groupDefs.push(new GroupDef(start, position - 1));
|
181
|
+
}
|
182
|
+
const thisIsTheLastOr = orPositions.length === index + 1;
|
183
|
+
const thereAreMoreConditions = conditions.length - 1 > position;
|
184
|
+
if (thisIsTheLastOr && thereAreMoreConditions) {
|
185
|
+
groupDefs.push(new GroupDef(position, conditions.length - 1));
|
186
|
+
}
|
187
|
+
start = position;
|
188
|
+
});
|
189
|
+
return groupDefs;
|
190
|
+
}
|
191
|
+
return [];
|
192
|
+
}
|
193
|
+
toJSON() {
|
194
|
+
const name = _classPrivateFieldGet(_conditionName, this);
|
195
|
+
const conditions = _classPrivateFieldGet(_userGroupedConditions, this);
|
196
|
+
return {
|
197
|
+
name,
|
198
|
+
conditions: conditions.map(it => it.clone())
|
199
|
+
};
|
200
|
+
}
|
201
|
+
static from(obj) {
|
202
|
+
if (obj instanceof ConditionsModel) {
|
203
|
+
return obj;
|
204
|
+
}
|
205
|
+
const toReturn = new ConditionsModel();
|
206
|
+
_classPrivateFieldSet(_conditionName, toReturn, obj.name);
|
207
|
+
_classPrivateFieldSet(_userGroupedConditions, toReturn, obj.conditions.map(it => conditionFrom(it)));
|
208
|
+
_classPrivateFieldSet(_groupedConditions, toReturn, toReturn._applyGroups(_classPrivateFieldGet(_userGroupedConditions, toReturn)));
|
209
|
+
return toReturn;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
_exports.ConditionsModel = ConditionsModel;
|
213
|
+
function conditionFrom(it) {
|
214
|
+
if (it.conditions) {
|
215
|
+
return new ConditionGroup(it.conditions.map(condition => conditionFrom(condition)));
|
216
|
+
}
|
217
|
+
if (it.conditionName) {
|
218
|
+
return new ConditionRef(it.conditionName, it.conditionDisplayName, it.coordinator);
|
219
|
+
}
|
220
|
+
return new Condition(Field.from(it.field), it.operator, (0, _inlineConditionValues.valueFrom)(it.value), it.coordinator);
|
221
|
+
}
|
222
|
+
class GroupDef {
|
223
|
+
constructor(first, last) {
|
224
|
+
_defineProperty(this, "first", void 0);
|
225
|
+
_defineProperty(this, "last", void 0);
|
226
|
+
if (typeof first !== 'number' || typeof last !== 'number') {
|
227
|
+
throw Error(`Cannot construct a group from ${first} and ${last}`);
|
228
|
+
} else if (first >= last) {
|
229
|
+
throw Error(`Last (${last}) must be greater than first (${first})`);
|
230
|
+
}
|
231
|
+
this.first = first;
|
232
|
+
this.last = last;
|
233
|
+
}
|
234
|
+
contains(index) {
|
235
|
+
return this.first <= index && this.last >= index;
|
236
|
+
}
|
237
|
+
startsWith(index) {
|
238
|
+
return this.first === index;
|
239
|
+
}
|
240
|
+
applyTo(conditions) {
|
241
|
+
return [...conditions].splice(this.first, this.last - this.first + 1);
|
242
|
+
}
|
243
|
+
}
|
244
|
+
_exports.GroupDef = GroupDef;
|
245
|
+
class ConditionGroup {
|
246
|
+
constructor(conditions) {
|
247
|
+
_defineProperty(this, "conditions", void 0);
|
248
|
+
if (!Array.isArray(conditions) || conditions.length < 2) {
|
249
|
+
throw Error('Cannot construct a condition group from a single condition');
|
250
|
+
}
|
251
|
+
this.conditions = conditions;
|
252
|
+
}
|
253
|
+
coordinatorString() {
|
254
|
+
return this.conditions[0].coordinatorString();
|
255
|
+
}
|
256
|
+
conditionString() {
|
257
|
+
const copy = [...this.conditions];
|
258
|
+
copy.splice(0, 1);
|
259
|
+
return `(${this.conditions[0].conditionString()} ${copy.map(condition => toPresentationString(condition)).join(' ')})`;
|
260
|
+
}
|
261
|
+
conditionExpression() {
|
262
|
+
const copy = [...this.conditions];
|
263
|
+
copy.splice(0, 1);
|
264
|
+
return `(${this.conditions[0].conditionExpression()} ${copy.map(condition => toExpression(condition)).join(' ')})`;
|
265
|
+
}
|
266
|
+
asFirstCondition() {
|
267
|
+
this.conditions[0].asFirstCondition();
|
268
|
+
return this;
|
269
|
+
}
|
270
|
+
getCoordinator() {
|
271
|
+
return this.conditions[0].getCoordinator();
|
272
|
+
}
|
273
|
+
setCoordinator(coordinator) {
|
274
|
+
this.conditions[0].setCoordinator(coordinator);
|
275
|
+
}
|
276
|
+
isGroup() {
|
277
|
+
return true;
|
278
|
+
}
|
279
|
+
getGroupedConditions() {
|
280
|
+
return this.conditions.map(condition => condition.clone());
|
281
|
+
}
|
282
|
+
clone() {
|
283
|
+
return new ConditionGroup(this.conditions.map(condition => condition.clone()));
|
284
|
+
}
|
285
|
+
}
|
286
|
+
function toPresentationString(condition) {
|
287
|
+
return `${condition.coordinatorString()}${condition.conditionString()}`;
|
288
|
+
}
|
289
|
+
function toExpression(condition) {
|
290
|
+
return `${condition.coordinatorString()}${condition.conditionExpression()}`;
|
291
|
+
}
|
292
|
+
class Field {
|
293
|
+
constructor(name, type, display) {
|
294
|
+
_defineProperty(this, "name", void 0);
|
295
|
+
_defineProperty(this, "type", void 0);
|
296
|
+
_defineProperty(this, "display", void 0);
|
297
|
+
if (!name || typeof name !== 'string') {
|
298
|
+
throw Error(`name ${name} is not valid`);
|
299
|
+
}
|
300
|
+
if (!_componentTypes.ComponentTypes.find(componentType => componentType.name === type)) {
|
301
|
+
throw Error(`type ${type} is not valid`);
|
302
|
+
}
|
303
|
+
if (!display || typeof display !== 'string') {
|
304
|
+
throw Error(`display ${display} is not valid`);
|
305
|
+
}
|
306
|
+
this.name = name;
|
307
|
+
this.type = type;
|
308
|
+
this.display = display;
|
309
|
+
}
|
310
|
+
static from(obj) {
|
311
|
+
return new Field(obj.name, obj.type, obj.display);
|
312
|
+
}
|
313
|
+
}
|
314
|
+
_exports.Field = Field;
|
315
|
+
class AbstractCondition {
|
316
|
+
constructor(coordinator) {
|
317
|
+
_defineProperty(this, "coordinator", void 0);
|
318
|
+
if (coordinator && !Object.values(coordinators).includes(coordinator)) {
|
319
|
+
throw Error(`coordinator ${coordinator} is not a valid coordinator`);
|
320
|
+
}
|
321
|
+
this.coordinator = coordinator;
|
322
|
+
}
|
323
|
+
coordinatorString() {
|
324
|
+
return this.coordinator ? `${this.coordinator} ` : '';
|
325
|
+
}
|
326
|
+
getCoordinator() {
|
327
|
+
return this.coordinator;
|
328
|
+
}
|
329
|
+
setCoordinator(coordinator) {
|
330
|
+
this.coordinator = coordinator;
|
331
|
+
}
|
332
|
+
isGroup() {
|
333
|
+
return false;
|
334
|
+
}
|
335
|
+
getGroupedConditions() {
|
336
|
+
return [this];
|
337
|
+
}
|
338
|
+
_asFirstCondition() {
|
339
|
+
delete this.coordinator;
|
340
|
+
}
|
341
|
+
asFirstCondition() {
|
342
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
343
|
+
}
|
344
|
+
clone() {
|
345
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
346
|
+
}
|
347
|
+
conditionString() {
|
348
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
349
|
+
}
|
350
|
+
conditionExpression() {
|
351
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
352
|
+
}
|
353
|
+
}
|
354
|
+
class Condition extends AbstractCondition {
|
355
|
+
constructor(field, operator, value, coordinator) {
|
356
|
+
super(coordinator);
|
357
|
+
_defineProperty(this, "field", void 0);
|
358
|
+
_defineProperty(this, "operator", void 0);
|
359
|
+
_defineProperty(this, "value", void 0);
|
360
|
+
if (!(field instanceof Field)) {
|
361
|
+
throw Error(`field ${field} is not a valid Field object`);
|
362
|
+
}
|
363
|
+
if (typeof operator !== 'string') {
|
364
|
+
throw Error(`operator ${operator} is not a valid operator`);
|
365
|
+
}
|
366
|
+
if (!(value instanceof _inlineConditionValues.AbstractConditionValue)) {
|
367
|
+
throw Error(`value ${value} is not a valid value type`);
|
368
|
+
}
|
369
|
+
this.field = field;
|
370
|
+
this.operator = operator;
|
371
|
+
this.value = value;
|
372
|
+
}
|
373
|
+
asFirstCondition() {
|
374
|
+
this._asFirstCondition();
|
375
|
+
return this;
|
376
|
+
}
|
377
|
+
conditionString() {
|
378
|
+
return `'${this.field.display}' ${this.operator} '${this.value.toPresentationString()}'`;
|
379
|
+
}
|
380
|
+
conditionExpression() {
|
381
|
+
return (0, _inlineConditionOperators.getExpression)(this.field.type, this.field.name, this.operator, this.value);
|
382
|
+
}
|
383
|
+
clone() {
|
384
|
+
return new Condition(Field.from(this.field), this.operator, this.value.clone(), this.coordinator);
|
385
|
+
}
|
386
|
+
}
|
387
|
+
_exports.Condition = Condition;
|
388
|
+
class ConditionRef extends AbstractCondition {
|
389
|
+
constructor(conditionName, conditionDisplayName, coordinator) {
|
390
|
+
super(coordinator);
|
391
|
+
_defineProperty(this, "conditionName", void 0);
|
392
|
+
_defineProperty(this, "conditionDisplayName", void 0);
|
393
|
+
if (typeof conditionName !== 'string') {
|
394
|
+
throw Error(`condition name ${conditionName} is not valid`);
|
395
|
+
}
|
396
|
+
if (typeof conditionDisplayName !== 'string') {
|
397
|
+
throw Error(`condition display name ${conditionDisplayName} is not valid`);
|
398
|
+
}
|
399
|
+
this.conditionName = conditionName;
|
400
|
+
this.conditionDisplayName = conditionDisplayName;
|
401
|
+
}
|
402
|
+
asFirstCondition() {
|
403
|
+
this._asFirstCondition();
|
404
|
+
return this;
|
405
|
+
}
|
406
|
+
conditionString() {
|
407
|
+
return `'${this.conditionDisplayName}'`;
|
408
|
+
}
|
409
|
+
conditionExpression() {
|
410
|
+
return this.conditionName;
|
411
|
+
}
|
412
|
+
clone() {
|
413
|
+
return new ConditionRef(this.conditionName, this.conditionDisplayName, this.coordinator);
|
414
|
+
}
|
415
|
+
}
|
416
|
+
_exports.ConditionRef = ConditionRef;
|
417
|
+
});
|
418
|
+
//# sourceMappingURL=inline-condition-model.js.map
|