@degenerate/rules 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/__testdata__/conditions/current-conditions.test-data.d.ts +1 -0
  2. package/dist/__testdata__/conditions/current-conditions.test-data.d.ts.map +1 -0
  3. package/dist/__testdata__/conditions/current-conditions.test-data.js +339 -0
  4. package/dist/__testdata__/rules/rules.test-data.d.ts +24 -0
  5. package/dist/__testdata__/rules/rules.test-data.d.ts.map +1 -0
  6. package/dist/__testdata__/rules/rules.test-data.js +339 -0
  7. package/dist/create/conditions/create-boolean-conditions.d.ts +12 -0
  8. package/dist/create/conditions/create-boolean-conditions.d.ts.map +1 -0
  9. package/dist/create/conditions/create-boolean-conditions.js +20 -0
  10. package/dist/create/conditions/create-contains-conditions.d.ts +12 -0
  11. package/dist/create/conditions/create-contains-conditions.d.ts.map +1 -0
  12. package/dist/create/conditions/create-contains-conditions.js +21 -0
  13. package/dist/create/conditions/create-empty-conditions.d.ts +11 -0
  14. package/dist/create/conditions/create-empty-conditions.d.ts.map +1 -0
  15. package/dist/create/conditions/create-empty-conditions.js +19 -0
  16. package/dist/create/conditions/create-equality-conditions.d.ts +12 -0
  17. package/dist/create/conditions/create-equality-conditions.d.ts.map +1 -0
  18. package/dist/create/conditions/create-equality-conditions.js +21 -0
  19. package/dist/create/conditions/create-null-conditions.d.ts +11 -0
  20. package/dist/create/conditions/create-null-conditions.d.ts.map +1 -0
  21. package/dist/create/conditions/create-null-conditions.js +19 -0
  22. package/dist/create/conditions/create-range-conditions.d.ts +13 -0
  23. package/dist/create/conditions/create-range-conditions.d.ts.map +1 -0
  24. package/dist/create/conditions/create-range-conditions.js +22 -0
  25. package/dist/create/conditions/create-special-conditions.d.ts +12 -0
  26. package/dist/create/conditions/create-special-conditions.d.ts.map +1 -0
  27. package/dist/create/conditions/create-special-conditions.js +21 -0
  28. package/dist/create/conditions/create-starts-end-with-conditions.d.ts +13 -0
  29. package/dist/create/conditions/create-starts-end-with-conditions.d.ts.map +1 -0
  30. package/dist/create/conditions/create-starts-end-with-conditions.js +22 -0
  31. package/dist/create/conditions/create-typeof-conditions.d.ts +12 -0
  32. package/dist/create/conditions/create-typeof-conditions.d.ts.map +1 -0
  33. package/dist/create/conditions/create-typeof-conditions.js +21 -0
  34. package/dist/create/create-share-rule-applied.d.ts +11 -0
  35. package/dist/create/create-share-rule-applied.d.ts.map +1 -0
  36. package/dist/create/create-share-rule-applied.js +17 -0
  37. package/dist/create/create-share-rule-id.d.ts +11 -0
  38. package/dist/create/create-share-rule-id.d.ts.map +1 -0
  39. package/dist/create/create-share-rule-id.js +25 -0
  40. package/dist/create/create-share-rule.d.ts +11 -0
  41. package/dist/create/create-share-rule.d.ts.map +1 -0
  42. package/dist/create/create-share-rule.js +28 -0
  43. package/dist/create/index.d.ts +13 -0
  44. package/dist/create/index.d.ts.map +1 -0
  45. package/dist/create/index.js +30 -0
  46. package/dist/evaluation/conditions/boolean-conditions.d.ts +2 -2
  47. package/dist/evaluation/conditions/boolean-conditions.d.ts.map +1 -1
  48. package/dist/evaluation/conditions/boolean-conditions.js +9 -8
  49. package/dist/evaluation/conditions/contains-conditions.d.ts +2 -2
  50. package/dist/evaluation/conditions/contains-conditions.d.ts.map +1 -1
  51. package/dist/evaluation/conditions/contains-conditions.js +2 -2
  52. package/dist/evaluation/conditions/empty-conditions.d.ts +2 -2
  53. package/dist/evaluation/conditions/empty-conditions.d.ts.map +1 -1
  54. package/dist/evaluation/conditions/empty-conditions.js +4 -13
  55. package/dist/evaluation/conditions/equality-conditions.d.ts +2 -2
  56. package/dist/evaluation/conditions/equality-conditions.d.ts.map +1 -1
  57. package/dist/evaluation/conditions/equality-conditions.js +4 -7
  58. package/dist/evaluation/conditions/null-conditions.d.ts +2 -2
  59. package/dist/evaluation/conditions/null-conditions.d.ts.map +1 -1
  60. package/dist/evaluation/conditions/null-conditions.js +4 -7
  61. package/dist/evaluation/conditions/range-conditions.d.ts +2 -2
  62. package/dist/evaluation/conditions/range-conditions.d.ts.map +1 -1
  63. package/dist/evaluation/conditions/range-conditions.js +16 -5
  64. package/dist/evaluation/conditions/special-conditions.d.ts +2 -2
  65. package/dist/evaluation/conditions/special-conditions.d.ts.map +1 -1
  66. package/dist/evaluation/conditions/special-conditions.js +11 -8
  67. package/dist/evaluation/conditions/starts-end-with-conditions.d.ts +2 -2
  68. package/dist/evaluation/conditions/starts-end-with-conditions.d.ts.map +1 -1
  69. package/dist/evaluation/conditions/starts-end-with-conditions.js +5 -3
  70. package/dist/evaluation/conditions/{typeof-rule-conditions.d.ts → typeof-conditions.d.ts} +3 -3
  71. package/dist/evaluation/conditions/typeof-conditions.d.ts.map +1 -0
  72. package/dist/evaluation/conditions/{typeof-rule-conditions.js → typeof-conditions.js} +2 -2
  73. package/dist/evaluation/evaluate-rule-conditions.d.ts.map +1 -1
  74. package/dist/evaluation/evaluate-rule-conditions.js +19 -22
  75. package/dist/evaluation/evaluate-rules.js +3 -5
  76. package/dist/evaluation/index.d.ts +1 -1
  77. package/dist/evaluation/index.d.ts.map +1 -1
  78. package/dist/evaluation/index.js +1 -1
  79. package/package.json +4 -4
  80. package/dist/evaluation/conditions/typeof-rule-conditions.d.ts.map +0 -1
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createStartsEndsWithConditions = void 0;
4
+ const generic_1 = require("@degenerate/generic");
5
+ /**
6
+ * This creates the starts with or ends with conditions for the share data rules
7
+ *
8
+ * @param targettedProperty the property to target
9
+ * @param conditionType the condition type
10
+ * @param conditionValue the value to check against
11
+ * @param conditionTypeQualifier the condition type qualifier
12
+ * @returns
13
+ */
14
+ const createStartsEndsWithConditions = (targettedProperty, conditionType, conditionValue, conditionTypeQualifier = generic_1.ConditionTypeQualifier.IS) => {
15
+ return {
16
+ targettedProperty,
17
+ conditionType,
18
+ conditionValue,
19
+ conditionTypeQualifier,
20
+ };
21
+ };
22
+ exports.createStartsEndsWithConditions = createStartsEndsWithConditions;
@@ -0,0 +1,12 @@
1
+ import { ConditionTypeOf, IConditionTypeOf, ConditionTypeQualifier } from '@degenerate/generic';
2
+ /**
3
+ * This function creates a typeof condition for the sharedata rules engine.
4
+ *
5
+ * @param targettedProperty the property to check
6
+ * @param conditionType the type of typeof condition
7
+ * @param conditionValue the value to check against
8
+ * @returns
9
+ */
10
+ declare const createConditionTypeOf: (targettedProperty: string, conditionValue: ConditionTypeOf, conditionTypeQualifier?: ConditionTypeQualifier) => IConditionTypeOf;
11
+ export { createConditionTypeOf };
12
+ //# sourceMappingURL=create-typeof-conditions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-typeof-conditions.d.ts","sourceRoot":"","sources":["../../../src/create/conditions/create-typeof-conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAuB,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAErH;;;;;;;GAOG;AACH,QAAA,MAAM,qBAAqB,sBACJ,MAAM,kBACT,eAAe,2BACP,sBAAsB,KAC/C,gBAOF,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createConditionTypeOf = void 0;
4
+ const generic_1 = require("@degenerate/generic");
5
+ /**
6
+ * This function creates a typeof condition for the sharedata rules engine.
7
+ *
8
+ * @param targettedProperty the property to check
9
+ * @param conditionType the type of typeof condition
10
+ * @param conditionValue the value to check against
11
+ * @returns
12
+ */
13
+ const createConditionTypeOf = (targettedProperty, conditionValue, conditionTypeQualifier = generic_1.ConditionTypeQualifier.IS) => {
14
+ return {
15
+ targettedProperty,
16
+ conditionType: generic_1.ConditionTypeSingle.TYPEOF,
17
+ conditionValue,
18
+ conditionTypeQualifier,
19
+ };
20
+ };
21
+ exports.createConditionTypeOf = createConditionTypeOf;
@@ -0,0 +1,11 @@
1
+ import { IShareRule, IShareRuleApplied } from '@degenerate/generic';
2
+ /**
3
+ * This creates a share rule applied.
4
+ *
5
+ * @param rule the share rule
6
+ * @param targettedProperty the targetted property
7
+ * @returns
8
+ */
9
+ declare const createShareRuleApplied: (rule: IShareRule, targettedProperty: string) => IShareRuleApplied;
10
+ export { createShareRuleApplied };
11
+ //# sourceMappingURL=create-share-rule-applied.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-share-rule-applied.d.ts","sourceRoot":"","sources":["../../src/create/create-share-rule-applied.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpE;;;;;;GAMG;AACH,QAAA,MAAM,sBAAsB,SAAU,UAAU,qBAAqB,MAAM,KAAG,iBAK7E,CAAA;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createShareRuleApplied = void 0;
4
+ /**
5
+ * This creates a share rule applied.
6
+ *
7
+ * @param rule the share rule
8
+ * @param targettedProperty the targetted property
9
+ * @returns
10
+ */
11
+ const createShareRuleApplied = (rule, targettedProperty) => {
12
+ return {
13
+ ...rule,
14
+ targettedProperty
15
+ };
16
+ };
17
+ exports.createShareRuleApplied = createShareRuleApplied;
@@ -0,0 +1,11 @@
1
+ import { ICondition } from '@degenerate/generic';
2
+ /**
3
+ * This creates a share rule id from the current and proposed data conditions.
4
+ *
5
+ * @param currentDataConditions the current data conditions
6
+ * @param proposedDataConditions the proposed data conditions
7
+ * @returns (string) the hashed rule id
8
+ */
9
+ declare const createShareRuleId: (currentDataConditions: ICondition[], proposedDataConditions: ICondition[]) => string;
10
+ export { createShareRuleId };
11
+ //# sourceMappingURL=create-share-rule-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-share-rule-id.d.ts","sourceRoot":"","sources":["../../src/create/create-share-rule-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEhE;;;;;;GAMG;AACH,QAAA,MAAM,iBAAiB,0BAA2B,UAAU,EAAE,0BAClC,UAAU,EAAE,WAYvC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createShareRuleId = void 0;
4
+ const generic_1 = require("@degenerate/generic");
5
+ /**
6
+ * This creates a share rule id from the current and proposed data conditions.
7
+ *
8
+ * @param currentDataConditions the current data conditions
9
+ * @param proposedDataConditions the proposed data conditions
10
+ * @returns (string) the hashed rule id
11
+ */
12
+ const createShareRuleId = (currentDataConditions, proposedDataConditions) => {
13
+ // get the current timestamp
14
+ const timestamp = Date.now();
15
+ // get the representation of the current data conditions
16
+ const currentDataConditionsString = JSON.stringify(currentDataConditions);
17
+ // get the representation of the proposed data conditions
18
+ const proposedDataConditionsString = JSON.stringify(proposedDataConditions);
19
+ // create the rule id
20
+ const ruleId = `${currentDataConditionsString}-${proposedDataConditionsString}-${timestamp}`;
21
+ // get the hash of the rule id
22
+ const ruleHash = (0, generic_1.calculateHash)(ruleId, 'hex');
23
+ return ruleHash;
24
+ };
25
+ exports.createShareRuleId = createShareRuleId;
@@ -0,0 +1,11 @@
1
+ import { ICondition, IShareRule } from '@degenerate/generic';
2
+ /**
3
+ * This creates a share rule.
4
+ *
5
+ * @param currentDataConditions the current data conditions
6
+ * @param proposedDataConditions the proposed data conditions
7
+ * @returns
8
+ */
9
+ declare const createShareRule: (currentDataConditions: ICondition[], proposedDataConditions: ICondition[]) => IShareRule;
10
+ export { createShareRule };
11
+ //# sourceMappingURL=create-share-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-share-rule.d.ts","sourceRoot":"","sources":["../../src/create/create-share-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,UAAU,EAGb,MAAM,qBAAqB,CAAC;AAI7B;;;;;;GAMG;AACH,QAAA,MAAM,eAAe,0BACM,UAAU,EAAE,0BACX,UAAU,EAAE,KACrC,UAgBF,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createShareRule = void 0;
4
+ const generic_1 = require("@degenerate/generic");
5
+ const create_share_rule_id_1 = require("./create-share-rule-id");
6
+ /**
7
+ * This creates a share rule.
8
+ *
9
+ * @param currentDataConditions the current data conditions
10
+ * @param proposedDataConditions the proposed data conditions
11
+ * @returns
12
+ */
13
+ const createShareRule = (currentDataConditions, proposedDataConditions) => {
14
+ let ruleId = '';
15
+ if (currentDataConditions.length === 0) {
16
+ throw new generic_1.ShareRuleCurrentConditionsNotPresentError(ruleId);
17
+ }
18
+ if (proposedDataConditions.length === 0) {
19
+ throw new generic_1.ShareRuleProposedConditionsNotPresentError(ruleId);
20
+ }
21
+ ruleId = (0, create_share_rule_id_1.createShareRuleId)(currentDataConditions, proposedDataConditions);
22
+ return {
23
+ ruleId,
24
+ currentDataConditions,
25
+ proposedDataConditions
26
+ };
27
+ };
28
+ exports.createShareRule = createShareRule;
@@ -0,0 +1,13 @@
1
+ export * from './conditions/create-boolean-conditions';
2
+ export * from './conditions/create-contains-conditions';
3
+ export * from './conditions/create-empty-conditions';
4
+ export * from './conditions/create-equality-conditions';
5
+ export * from './conditions/create-null-conditions';
6
+ export * from './conditions/create-range-conditions';
7
+ export * from './conditions/create-special-conditions';
8
+ export * from './conditions/create-starts-end-with-conditions';
9
+ export * from './conditions/create-typeof-conditions';
10
+ export * from './create-share-rule-applied';
11
+ export * from './create-share-rule-id';
12
+ export * from './create-share-rule';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/create/index.ts"],"names":[],"mappings":"AAEA,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uCAAuC,CAAC;AAItD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ //#region Conditional Functions
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./conditions/create-boolean-conditions"), exports);
19
+ __exportStar(require("./conditions/create-contains-conditions"), exports);
20
+ __exportStar(require("./conditions/create-empty-conditions"), exports);
21
+ __exportStar(require("./conditions/create-equality-conditions"), exports);
22
+ __exportStar(require("./conditions/create-null-conditions"), exports);
23
+ __exportStar(require("./conditions/create-range-conditions"), exports);
24
+ __exportStar(require("./conditions/create-special-conditions"), exports);
25
+ __exportStar(require("./conditions/create-starts-end-with-conditions"), exports);
26
+ __exportStar(require("./conditions/create-typeof-conditions"), exports);
27
+ //#endregion Conditional Functions
28
+ __exportStar(require("./create-share-rule-applied"), exports);
29
+ __exportStar(require("./create-share-rule-id"), exports);
30
+ __exportStar(require("./create-share-rule"), exports);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file contains the functions for checking that the boolean conditions are met.
3
3
  */
4
- import { ConditionTypeBoolean } from '@degenerate/generic';
4
+ import { ConditionTypeBoolean, ConditionTypeQualifier } from '@degenerate/generic';
5
5
  /**
6
6
  * This takes a value and checks if it meets the boolean condition.
7
7
  *
@@ -10,6 +10,6 @@ import { ConditionTypeBoolean } from '@degenerate/generic';
10
10
  *
11
11
  * @returns
12
12
  */
13
- declare const isValidBooleanValue: (dataValue: unknown, conditionType: ConditionTypeBoolean) => boolean;
13
+ declare const isValidBooleanValue: (dataValue: unknown, conditionType: ConditionTypeBoolean, conditionTypeQualifier: ConditionTypeQualifier) => boolean;
14
14
  export { isValidBooleanValue };
15
15
  //# sourceMappingURL=boolean-conditions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boolean-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/boolean-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAmB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;;;;;;GAOG;AACH,QAAA,MAAM,mBAAmB,cAAe,OAAO,iBAAiB,oBAAoB,KAAG,OAWtF,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"boolean-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/boolean-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAmB,MAAM,qBAAqB,CAAC;AAEpG;;;;;;;GAOG;AACH,QAAA,MAAM,mBAAmB,cAAe,OAAO,iBAAiB,oBAAoB,0BACxD,sBAAsB,KAAG,OAYpD,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -13,16 +13,17 @@ const generic_1 = require("@degenerate/generic");
13
13
  *
14
14
  * @returns
15
15
  */
16
- const isValidBooleanValue = (dataValue, conditionType) => {
17
- const isBoolean = (0, generic_1.validateBoolean)(dataValue);
18
- if (!isBoolean) {
16
+ const isValidBooleanValue = (dataValue, conditionType, conditionTypeQualifier) => {
17
+ const isBoolean = (0, generic_1.validateBoolean)(dataValue); // make sure the type is boolean
18
+ if (!isBoolean) { // if this is not a boolean, then it is not valid
19
19
  return false;
20
20
  }
21
- switch (conditionType) {
22
- case generic_1.ConditionTypeBoolean.IS_TRUE:
23
- return dataValue === true;
24
- case generic_1.ConditionTypeBoolean.IS_FALSE:
25
- return dataValue === false;
21
+ const isTrue = (conditionType === generic_1.ConditionTypeBoolean.TRUE) ? true : false;
22
+ if (conditionTypeQualifier === generic_1.ConditionTypeQualifier.IS_NOT) {
23
+ return dataValue !== isTrue;
24
+ }
25
+ else {
26
+ return dataValue === isTrue;
26
27
  }
27
28
  };
28
29
  exports.isValidBooleanValue = isValidBooleanValue;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file contains the functions for checking that contains conditions are met.
3
3
  */
4
- import { ConditionTypeContains } from '@degenerate/generic';
4
+ import { ConditionTypeQualifier } from '@degenerate/generic';
5
5
  /**
6
6
  * This takes a value and checks if it is contained or not contained in the proper range of values.
7
7
  *
@@ -11,6 +11,6 @@ import { ConditionTypeContains } from '@degenerate/generic';
11
11
  *
12
12
  * @returns
13
13
  */
14
- declare const isValidContainsValue: (dataValue: string | number, conditionValue: string | (number | string)[], conditionType: ConditionTypeContains) => boolean;
14
+ declare const isValidContainsValue: (dataValue: string | number, conditionValue: string | (number | string)[], conditionTypeQualifier: ConditionTypeQualifier) => boolean;
15
15
  export { isValidContainsValue };
16
16
  //# sourceMappingURL=contains-conditions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contains-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/contains-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;;;;;GAQG;AACH,QAAA,MAAM,oBAAoB,cAAe,MAAM,GAAG,MAAM,kBAAkB,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,iBACnF,qBAAqB,KAAG,OAQ1C,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
1
+ {"version":3,"file":"contains-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/contains-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;;;GAQG;AACH,QAAA,MAAM,oBAAoB,cAAe,MAAM,GAAG,MAAM,kBAAkB,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,0BAC1E,sBAAsB,KAAG,OAUpD,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -14,7 +14,7 @@ const generic_1 = require("@degenerate/generic");
14
14
  *
15
15
  * @returns
16
16
  */
17
- const isValidContainsValue = (dataValue, conditionValue, conditionType) => {
17
+ const isValidContainsValue = (dataValue, conditionValue, conditionTypeQualifier) => {
18
18
  let isMatchedCondition = false;
19
19
  if (typeof conditionValue === 'string') {
20
20
  isMatchedCondition = conditionValue.includes(dataValue.toString());
@@ -22,6 +22,6 @@ const isValidContainsValue = (dataValue, conditionValue, conditionType) => {
22
22
  else {
23
23
  isMatchedCondition = conditionValue.includes(dataValue);
24
24
  }
25
- return (conditionType === generic_1.ConditionTypeContains.CONTAINS) ? isMatchedCondition : !isMatchedCondition;
25
+ return (conditionTypeQualifier === generic_1.ConditionTypeQualifier.IS) ? isMatchedCondition : !isMatchedCondition;
26
26
  };
27
27
  exports.isValidContainsValue = isValidContainsValue;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file contains the functions for checking that the values are empty
3
3
  */
4
- import { ConditionTypeEmpty } from '@degenerate/generic';
4
+ import { ConditionTypeQualifier } from '@degenerate/generic';
5
5
  /**
6
6
  * This takes a value and checks if it meets the empty condition
7
7
  *
@@ -10,6 +10,6 @@ import { ConditionTypeEmpty } from '@degenerate/generic';
10
10
  *
11
11
  * @returns
12
12
  */
13
- declare const isValidEmptyValue: (dataValue: unknown, conditionType: ConditionTypeEmpty) => boolean;
13
+ declare const isValidEmptyValue: (dataValue: unknown, conditionTypeQualifier: ConditionTypeQualifier) => boolean;
14
14
  export { isValidEmptyValue };
15
15
  //# sourceMappingURL=empty-conditions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"empty-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/empty-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAiB,MAAM,qBAAqB,CAAC;AAExE;;;;;;;GAOG;AACH,QAAA,MAAM,iBAAiB,cAAe,OAAO,iBAAiB,kBAAkB,KAAG,OAiBlF,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"empty-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/empty-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAiB,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;;;;;;GAOG;AACH,QAAA,MAAM,iBAAiB,cAAe,OAAO,0BAA0B,sBAAsB,KAAG,OAQ/F,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -13,23 +13,14 @@ const generic_1 = require("@degenerate/generic");
13
13
  *
14
14
  * @returns
15
15
  */
16
- const isValidEmptyValue = (dataValue, conditionType) => {
16
+ const isValidEmptyValue = (dataValue, conditionTypeQualifier) => {
17
17
  const isArray = (0, generic_1.validateArray)(dataValue);
18
18
  if (isArray) {
19
- switch (conditionType) {
20
- case generic_1.ConditionTypeEmpty.IS_EMPTY:
21
- return dataValue.length === 0;
22
- case generic_1.ConditionTypeEmpty.IS_NOT_EMPTY:
23
- return dataValue.length > 0;
24
- }
19
+ return (conditionTypeQualifier === generic_1.ConditionTypeQualifier.IS) ? dataValue.length === 0 : dataValue.length > 0;
25
20
  }
26
21
  else {
27
- switch (conditionType) {
28
- case generic_1.ConditionTypeEmpty.IS_EMPTY:
29
- return isEmpty(dataValue);
30
- case generic_1.ConditionTypeEmpty.IS_NOT_EMPTY:
31
- return !isEmpty(dataValue);
32
- }
22
+ const isEmptyValue = isEmpty(dataValue);
23
+ return (conditionTypeQualifier === generic_1.ConditionTypeQualifier.IS) ? isEmptyValue : !isEmptyValue;
33
24
  }
34
25
  };
35
26
  exports.isValidEmptyValue = isValidEmptyValue;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file contains the functions for checking that equality conditions are met.
3
3
  */
4
- import { ConditionTypeEquality } from '@degenerate/generic';
4
+ import { ConditionTypeQualifier } from '@degenerate/generic';
5
5
  /**
6
6
  * This takes a value and checks if two values are strictly equal or not equal.
7
7
  *
@@ -10,6 +10,6 @@ import { ConditionTypeEquality } from '@degenerate/generic';
10
10
  * @param conditionType the type of equality condition to check for
11
11
  * @returns
12
12
  */
13
- declare const isValidEqualityValue: (dataValue: unknown, conditionValue: unknown, conditionType: ConditionTypeEquality) => boolean;
13
+ declare const isValidEqualityValue: (dataValue: unknown, conditionValue: unknown, conditionTypeQualifier: ConditionTypeQualifier) => boolean;
14
14
  export { isValidEqualityValue };
15
15
  //# sourceMappingURL=equality-conditions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"equality-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/equality-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB,cAAe,OAAO,kBAAkB,OAAO,iBAAiB,qBAAqB,KAAG,OAOjH,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
1
+ {"version":3,"file":"equality-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/equality-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB,cAAe,OAAO,kBAAkB,OAAO,0BAC7C,sBAAsB,KAAG,OAIpD,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -13,12 +13,9 @@ const generic_1 = require("@degenerate/generic");
13
13
  * @param conditionType the type of equality condition to check for
14
14
  * @returns
15
15
  */
16
- const isValidEqualityValue = (dataValue, conditionValue, conditionType) => {
17
- switch (conditionType) {
18
- case generic_1.ConditionTypeEquality.EQUAL:
19
- return dataValue === conditionValue;
20
- case generic_1.ConditionTypeEquality.NOT_EQUAL:
21
- return dataValue !== conditionValue;
22
- }
16
+ const isValidEqualityValue = (dataValue, conditionValue, conditionTypeQualifier) => {
17
+ const conditionOutcome = (conditionTypeQualifier === generic_1.ConditionTypeQualifier.IS) ?
18
+ dataValue === conditionValue : dataValue !== conditionValue;
19
+ return conditionOutcome;
23
20
  };
24
21
  exports.isValidEqualityValue = isValidEqualityValue;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file contains the functions for checking that the null conditions are met.
3
3
  */
4
- import { ConditionTypeNull } from '@degenerate/generic';
4
+ import { ConditionTypeQualifier } from '@degenerate/generic';
5
5
  /**
6
6
  * This takes a value and checks if it meets the null condition.
7
7
  *
@@ -10,6 +10,6 @@ import { ConditionTypeNull } from '@degenerate/generic';
10
10
  *
11
11
  * @returns
12
12
  */
13
- declare const isValidNullValue: (dataValue: any, conditionType: ConditionTypeNull) => boolean;
13
+ declare const isValidNullValue: (dataValue: any, conditionTypeQualifier: ConditionTypeQualifier) => boolean;
14
14
  export { isValidNullValue };
15
15
  //# sourceMappingURL=null-conditions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"null-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/null-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;;;;GAOG;AACH,QAAA,MAAM,gBAAgB,cAAe,GAAG,iBAAiB,iBAAiB,KAAG,OAO5E,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"null-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/null-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;;GAOG;AACH,QAAA,MAAM,gBAAgB,cAAe,GAAG,0BAA0B,sBAAsB,KAAG,OAI1F,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -13,12 +13,9 @@ const generic_1 = require("@degenerate/generic");
13
13
  *
14
14
  * @returns
15
15
  */
16
- const isValidNullValue = (dataValue, conditionType) => {
17
- switch (conditionType) {
18
- case generic_1.ConditionTypeNull.IS_NULL:
19
- return dataValue === null;
20
- case generic_1.ConditionTypeNull.IS_NOT_NULL:
21
- return dataValue !== null;
22
- }
16
+ const isValidNullValue = (dataValue, conditionTypeQualifier) => {
17
+ const evaluationCondition = (conditionTypeQualifier === generic_1.ConditionTypeQualifier.IS) ?
18
+ dataValue === null : dataValue !== null;
19
+ return evaluationCondition;
23
20
  };
24
21
  exports.isValidNullValue = isValidNullValue;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file contains the functions for checking that range conditions are met.
3
3
  */
4
- import { ConditionTypeRange } from '@degenerate/generic';
4
+ import { ConditionTypeQualifier, ConditionTypeRange } from '@degenerate/generic';
5
5
  /**
6
6
  * This takes a value and checks if it is in the proper range of values.
7
7
  *
@@ -10,6 +10,6 @@ import { ConditionTypeRange } from '@degenerate/generic';
10
10
  * @param conditionType the type of equality condition to check for
11
11
  * @returns
12
12
  */
13
- declare const isValidRangeValue: (dataValue: string | number, conditionValue: string | number, conditionType: ConditionTypeRange) => boolean;
13
+ declare const isValidRangeValue: (dataValue: string | number, conditionValue: string | number, conditionType: ConditionTypeRange, conditionTypeQualifier: ConditionTypeQualifier) => boolean;
14
14
  export { isValidRangeValue };
15
15
  //# sourceMappingURL=range-conditions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"range-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/range-conditions.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;;GAOG;AACH,QAAA,MAAM,iBAAiB,cAAe,MAAM,GAAG,MAAM,kBAAkB,MAAM,GAAG,MAAM,iBAAiB,kBAAkB,KAAG,OAW3H,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"range-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/range-conditions.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEjF;;;;;;;GAOG;AACH,QAAA,MAAM,iBAAiB,cAAe,MAAM,GAAG,MAAM,kBAAkB,MAAM,GAAG,MAAM,iBACnE,kBAAkB,0BAA0B,sBAAsB,KAAG,OAsBvF,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -13,16 +13,27 @@ const generic_1 = require("@degenerate/generic");
13
13
  * @param conditionType the type of equality condition to check for
14
14
  * @returns
15
15
  */
16
- const isValidRangeValue = (dataValue, conditionValue, conditionType) => {
16
+ const isValidRangeValue = (dataValue, conditionValue, conditionType, conditionTypeQualifier) => {
17
+ let rangeResult = false;
17
18
  switch (conditionType) {
18
19
  case generic_1.ConditionTypeRange.GREATER_THAN:
19
- return dataValue > conditionValue;
20
+ rangeResult = dataValue > conditionValue;
21
+ break;
20
22
  case generic_1.ConditionTypeRange.LESS_THAN:
21
- return dataValue < conditionValue;
23
+ rangeResult = dataValue < conditionValue;
24
+ break;
22
25
  case generic_1.ConditionTypeRange.GREATER_THAN_OR_EQUAL:
23
- return dataValue >= conditionValue;
26
+ rangeResult = dataValue >= conditionValue;
27
+ break;
24
28
  case generic_1.ConditionTypeRange.LESS_THAN_OR_EQUAL:
25
- return dataValue <= conditionValue;
29
+ rangeResult = dataValue <= conditionValue;
30
+ break;
31
+ }
32
+ if (conditionTypeQualifier === generic_1.ConditionTypeQualifier.IS_NOT) {
33
+ return !rangeResult;
34
+ }
35
+ else {
36
+ return rangeResult;
26
37
  }
27
38
  };
28
39
  exports.isValidRangeValue = isValidRangeValue;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file contains the functions for checking that special conditions are met.
3
3
  */
4
- import { ConditionTypeSpecial } from '@degenerate/generic';
4
+ import { ConditionTypeSpecial, ConditionTypeQualifier } from '@degenerate/generic';
5
5
  /**
6
6
  * This takes a value and checks if the special condition is met.
7
7
  *
@@ -10,6 +10,6 @@ import { ConditionTypeSpecial } from '@degenerate/generic';
10
10
  * @param conditionType the type of equality condition to check for
11
11
  * @returns
12
12
  */
13
- declare const isValidSpecialValue: (dataValue: unknown, conditionValue: unknown, conditionType: ConditionTypeSpecial) => boolean;
13
+ declare const isValidSpecialValue: (dataValue: unknown, conditionValue: unknown, conditionType: ConditionTypeSpecial, conditionTypeQualifier: ConditionTypeQualifier) => boolean;
14
14
  export { isValidSpecialValue };
15
15
  //# sourceMappingURL=special-conditions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"special-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/special-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAkD,MAAM,qBAAqB,CAAC;AAE3G;;;;;;;GAOG;AACH,QAAA,MAAM,mBAAmB,cAAe,OAAO,kBAAkB,OAAO,iBAAiB,oBAAoB,KAAG,OAK/G,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"special-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/special-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAkD,MAAM,qBAAqB,CAAC;AAEnI;;;;;;;GAOG;AACH,QAAA,MAAM,mBAAmB,cAAe,OAAO,kBAAkB,OAAO,iBACrD,oBAAoB,0BAA0B,sBAAsB,KAAG,OAiBzF,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -13,11 +13,20 @@ const generic_1 = require("@degenerate/generic");
13
13
  * @param conditionType the type of equality condition to check for
14
14
  * @returns
15
15
  */
16
- const isValidSpecialValue = (dataValue, conditionValue, conditionType) => {
16
+ const isValidSpecialValue = (dataValue, conditionValue, conditionType, conditionTypeQualifier) => {
17
+ if (!dataValue || typeof dataValue !== 'string') {
18
+ return false;
19
+ }
20
+ if (!conditionValue || typeof conditionValue !== 'string') {
21
+ return false;
22
+ }
23
+ let result = false;
17
24
  switch (conditionType) {
18
25
  case generic_1.ConditionTypeSpecial.PATTERN:
19
- return evaluatePattern(dataValue, conditionValue);
26
+ result = evaluatePattern(dataValue, conditionValue);
27
+ break;
20
28
  }
29
+ return (conditionTypeQualifier === generic_1.ConditionTypeQualifier.IS) ? result : !result;
21
30
  };
22
31
  exports.isValidSpecialValue = isValidSpecialValue;
23
32
  //#region Special Conditions Functions
@@ -28,12 +37,6 @@ exports.isValidSpecialValue = isValidSpecialValue;
28
37
  * @returns
29
38
  */
30
39
  const evaluatePattern = (dataValue, conditionValue) => {
31
- if (!dataValue || typeof dataValue !== 'string') {
32
- return false;
33
- }
34
- if (!conditionValue || typeof conditionValue !== 'string') {
35
- return false;
36
- }
37
40
  try {
38
41
  const regex = new RegExp(conditionValue);
39
42
  const result = regex.test(dataValue);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file contains the functions for checking that starts or ends with are met
3
3
  */
4
- import { ConditionTypeStartsEndsWith } from '@degenerate/generic';
4
+ import { ConditionTypeQualifier, ConditionTypeStartsEndsWith } from '@degenerate/generic';
5
5
  /**
6
6
  * This takes a value and checks if the value starts or ends with value
7
7
  *
@@ -11,6 +11,6 @@ import { ConditionTypeStartsEndsWith } from '@degenerate/generic';
11
11
  *
12
12
  * @returns
13
13
  */
14
- declare const isValidStartEndWithValue: (dataValue: string | number | (string | number)[], conditionValue: string | number | (string | number)[], conditionType: ConditionTypeStartsEndsWith) => boolean;
14
+ declare const isValidStartEndWithValue: (dataValue: string | number | (string | number)[], conditionValue: string | number | (string | number)[], conditionType: ConditionTypeStartsEndsWith, conditionTypeQualifier: ConditionTypeQualifier) => boolean;
15
15
  export { isValidStartEndWithValue };
16
16
  //# sourceMappingURL=starts-end-with-conditions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"starts-end-with-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/starts-end-with-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEH,2BAA2B,EAI9B,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;GAQG;AACH,QAAA,MAAM,wBAAwB,cAAe,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,kBAAkB,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,iBACtH,2BAA2B,KAAG,OAchD,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
1
+ {"version":3,"file":"starts-end-with-conditions.d.ts","sourceRoot":"","sources":["../../../src/evaluation/conditions/starts-end-with-conditions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEH,sBAAsB,EACtB,2BAA2B,EAI9B,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;GAQG;AACH,QAAA,MAAM,wBAAwB,cAAe,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,kBAAkB,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,iBACtH,2BAA2B,0BAA0B,sBAAsB,KAAG,OAiBhG,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}