@degenerate/rules 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__testdata__/conditions/current-conditions.test-data.js +5 -5
- package/dist/__testdata__/rules/rules.test-data.d.ts +8 -5
- package/dist/__testdata__/rules/rules.test-data.d.ts.map +1 -1
- package/dist/__testdata__/rules/rules.test-data.js +55 -4
- package/dist/create/create-share-rule-group.d.ts +11 -0
- package/dist/create/create-share-rule-group.d.ts.map +1 -0
- package/dist/create/create-share-rule-group.js +16 -0
- package/dist/create/create-share-rule-set.d.ts +13 -0
- package/dist/create/create-share-rule-set.d.ts.map +1 -0
- package/dist/create/create-share-rule-set.js +36 -0
- package/dist/create/index.d.ts +2 -0
- package/dist/create/index.d.ts.map +1 -1
- package/dist/create/index.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/validation/conditions/validate-condition-base.d.ts +9 -0
- package/dist/validation/conditions/validate-condition-base.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-base.js +29 -0
- package/dist/validation/conditions/validate-condition-boolean.d.ts +10 -0
- package/dist/validation/conditions/validate-condition-boolean.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-boolean.js +26 -0
- package/dist/validation/conditions/validate-condition-contains.d.ts +10 -0
- package/dist/validation/conditions/validate-condition-contains.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-contains.js +43 -0
- package/dist/validation/conditions/validate-condition-empty.d.ts +10 -0
- package/dist/validation/conditions/validate-condition-empty.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-empty.js +23 -0
- package/dist/validation/conditions/validate-condition-equality.d.ts +10 -0
- package/dist/validation/conditions/validate-condition-equality.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-equality.js +26 -0
- package/dist/validation/conditions/validate-condition-null.d.ts +10 -0
- package/dist/validation/conditions/validate-condition-null.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-null.js +23 -0
- package/dist/validation/conditions/validate-condition-qualifier.d.ts +9 -0
- package/dist/validation/conditions/validate-condition-qualifier.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-qualifier.js +19 -0
- package/dist/validation/conditions/validate-condition-range.d.ts +9 -0
- package/dist/validation/conditions/validate-condition-range.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-range.js +35 -0
- package/dist/validation/conditions/validate-condition-share-rule.d.ts +10 -0
- package/dist/validation/conditions/validate-condition-share-rule.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-share-rule.js +34 -0
- package/dist/validation/conditions/validate-condition-special.d.ts +10 -0
- package/dist/validation/conditions/validate-condition-special.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-special.js +30 -0
- package/dist/validation/conditions/validate-condition-starts-ends-with.d.ts +10 -0
- package/dist/validation/conditions/validate-condition-starts-ends-with.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-starts-ends-with.js +31 -0
- package/dist/validation/conditions/validate-condition-type-of.d.ts +10 -0
- package/dist/validation/conditions/validate-condition-type-of.d.ts.map +1 -0
- package/dist/validation/conditions/validate-condition-type-of.js +30 -0
- package/dist/validation/determine-condition-to-validate.d.ts +9 -0
- package/dist/validation/determine-condition-to-validate.d.ts.map +1 -0
- package/dist/validation/determine-condition-to-validate.js +56 -0
- package/dist/validation/index.d.ts +15 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +32 -0
- package/dist/validation/validate-share-rule.d.ts +9 -0
- package/dist/validation/validate-share-rule.d.ts.map +1 -0
- package/dist/validation/validate-share-rule.js +52 -0
- package/package.json +3 -3
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
// /**
|
|
39
39
|
// * This contains the interface for the rule set in the share data object
|
|
40
40
|
// */
|
|
41
|
-
// export interface
|
|
41
|
+
// export interface IShareRuleSet {
|
|
42
42
|
// id: string; // the id of the rule set
|
|
43
43
|
// version: number; // the version of the rule set
|
|
44
44
|
// name: string; // the name of the rule set
|
|
45
45
|
// description: string; // the description of the rule set
|
|
46
|
-
// ruleGroups:
|
|
46
|
+
// ruleGroups: IShareRuleGroup[]; // the rules in the rule set
|
|
47
47
|
// }
|
|
48
48
|
// //#endregion RuleSet
|
|
49
49
|
// //#region RuleGroup
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
// *
|
|
60
60
|
// * A rule group can contain individual rules or nested rule groups.
|
|
61
61
|
// */
|
|
62
|
-
// export interface
|
|
62
|
+
// export interface IShareRuleGroup {
|
|
63
63
|
// operator: LogicalOperator; // The logical operator to combine the rules
|
|
64
|
-
// rules: (IShareRuleApplied |
|
|
64
|
+
// rules: (IShareRuleApplied | IShareRuleGroup)[]; // The rules or nested rule groups
|
|
65
65
|
// }
|
|
66
66
|
// //#endregion RuleGroup
|
|
67
67
|
// //#region Rule
|
|
@@ -334,6 +334,6 @@
|
|
|
334
334
|
// export interface IConditionCombinedRules {
|
|
335
335
|
// targettedProperty: string; // the property that is being checked ('address.city.value')
|
|
336
336
|
// conditionType: ConditionTypeCombinedRules; // the type of condition to evaluate
|
|
337
|
-
// conditionValue:
|
|
337
|
+
// conditionValue: IShareRuleGroup; // the value to evaluate the condition against
|
|
338
338
|
// }
|
|
339
339
|
// //#endregion Conditions
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IShareRule, IShareRuleApplied, IShareRuleGroup, IShareRuleSet } from '@degenerate/generic';
|
|
2
|
+
export declare const loanAmountCreateRule: IShareRule;
|
|
2
3
|
export declare const loanAmountCreate: IShareRuleApplied;
|
|
3
4
|
export declare const loanAmountCreateWithHold: IShareRuleApplied;
|
|
4
5
|
export declare const loanAmountCreateWithPink_A: IShareRuleApplied;
|
|
5
6
|
export declare const loanAmountUpdate: IShareRuleApplied;
|
|
6
7
|
export declare const loanAmountUpdateWithPink_BA: IShareRuleApplied;
|
|
7
8
|
export declare const loanAmountDelete: IShareRuleApplied;
|
|
8
|
-
export declare const loanCreateRuleGroup:
|
|
9
|
-
export declare const loanCreateWithHoldUntil:
|
|
10
|
-
export declare const loanCreateFullRuleGroup:
|
|
11
|
-
export declare const loanCreateRuleSet:
|
|
9
|
+
export declare const loanCreateRuleGroup: IShareRuleGroup;
|
|
10
|
+
export declare const loanCreateWithHoldUntil: IShareRuleGroup;
|
|
11
|
+
export declare const loanCreateFullRuleGroup: IShareRuleGroup;
|
|
12
|
+
export declare const loanCreateRuleSet: IShareRuleSet;
|
|
12
13
|
export declare const userAgeCreate: IShareRuleApplied;
|
|
14
|
+
export declare const userAge18: IShareRuleApplied;
|
|
13
15
|
export declare const userAgeUpdate: IShareRuleApplied;
|
|
14
16
|
export declare const userAgeDelete: IShareRuleApplied;
|
|
15
17
|
export declare const userFirstNameCreate: IShareRuleApplied;
|
|
@@ -21,4 +23,5 @@ export declare const userLastNameDelete: IShareRuleApplied;
|
|
|
21
23
|
export declare const userCombinedCreate: IShareRuleApplied;
|
|
22
24
|
export declare const userCombinedUpdate: IShareRuleApplied;
|
|
23
25
|
export declare const userCombinedDelete: IShareRuleApplied;
|
|
26
|
+
export declare const canadianAdddressCreate: IShareRule;
|
|
24
27
|
//# sourceMappingURL=rules.test-data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.test-data.d.ts","sourceRoot":"","sources":["../../../src/__testdata__/rules/rules.test-data.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"rules.test-data.d.ts","sourceRoot":"","sources":["../../../src/__testdata__/rules/rules.test-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,aAAa,EAEhB,MAAM,qBAAqB,CAAC;AAK7B,eAAO,MAAM,oBAAoB,EAAE,UASlC,CAAA;AACD,eAAO,MAAM,gBAAgB,EAAE,iBAU9B,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAStC,CAAA;AAED,eAAO,MAAM,0BAA0B,EAAE,iBAWxC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,iBAW9B,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,iBAazC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,iBAU9B,CAAC;AAmBF,eAAO,MAAM,mBAAmB,EAAE,eAGjC,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,eAGrC,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,eAGrC,CAAA;AA0FD,eAAO,MAAM,iBAAiB,EAAE,aAM/B,CAAA;AAMD,eAAO,MAAM,aAAa,EAAE,iBAU3B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,iBAWvB,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,iBAW3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,iBAU3B,CAAC;AAMF,eAAO,MAAM,mBAAmB,EAAE,iBASjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,iBAShC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,iBASjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,iBAShC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,iBASjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,iBAShC,CAAC;AAIF,eAAO,MAAM,kBAAkB,EAAE,iBAchC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,iBAehC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,iBAchC,CAAC;AAeF,eAAO,MAAM,sBAAsB,EAAE,UAkBpC,CAAA"}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.userCombinedDelete = exports.userCombinedUpdate = exports.userCombinedCreate = exports.userLastNameDelete = exports.userFirstNameDelete = exports.userLastNameUpdate = exports.userFirstNameUpdate = exports.userLastNameCreate = exports.userFirstNameCreate = exports.userAgeDelete = exports.userAgeUpdate = exports.userAgeCreate = exports.loanCreateRuleSet = exports.loanCreateFullRuleGroup = exports.loanCreateWithHoldUntil = exports.loanCreateRuleGroup = exports.loanAmountDelete = exports.loanAmountUpdateWithPink_BA = exports.loanAmountUpdate = exports.loanAmountCreateWithPink_A = exports.loanAmountCreateWithHold = exports.loanAmountCreate = void 0;
|
|
3
|
+
exports.canadianAdddressCreate = exports.userCombinedDelete = exports.userCombinedUpdate = exports.userCombinedCreate = exports.userLastNameDelete = exports.userFirstNameDelete = exports.userLastNameUpdate = exports.userFirstNameUpdate = exports.userLastNameCreate = exports.userFirstNameCreate = exports.userAgeDelete = exports.userAgeUpdate = exports.userAge18 = exports.userAgeCreate = exports.loanCreateRuleSet = exports.loanCreateFullRuleGroup = exports.loanCreateWithHoldUntil = exports.loanCreateRuleGroup = exports.loanAmountDelete = exports.loanAmountUpdateWithPink_BA = exports.loanAmountUpdate = exports.loanAmountCreateWithPink_A = exports.loanAmountCreateWithHold = exports.loanAmountCreate = exports.loanAmountCreateRule = void 0;
|
|
4
4
|
const generic_1 = require("@degenerate/generic");
|
|
5
5
|
//#region property loanAmount
|
|
6
|
+
exports.loanAmountCreateRule = {
|
|
7
|
+
ruleId: 'loanAmountCreate',
|
|
8
|
+
currentDataConditions: [
|
|
9
|
+
{ targettedProperty: 'loanAmount', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.UNDEFINED, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS }
|
|
10
|
+
],
|
|
11
|
+
proposedDataConditions: [
|
|
12
|
+
{ targettedProperty: 'loanAmount', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.NUMBER, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
13
|
+
{ targettedProperty: 'loanAmount', conditionType: generic_1.ConditionTypeRange.GREATER_THAN_OR_EQUAL, conditionValue: 0, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
14
|
+
],
|
|
15
|
+
};
|
|
6
16
|
exports.loanAmountCreate = {
|
|
7
17
|
ruleId: 'loanAmountCreate',
|
|
8
18
|
currentDataConditions: [
|
|
@@ -75,15 +85,15 @@ exports.loanAmountDelete = {
|
|
|
75
85
|
};
|
|
76
86
|
//#endregion property loanAmount
|
|
77
87
|
//#region ruleSet LoanAmount
|
|
78
|
-
// const ruleGroupLoanAmount:
|
|
88
|
+
// const ruleGroupLoanAmount: IShareRuleSet = {
|
|
79
89
|
// /**
|
|
80
90
|
// * This contains the interface for the rule set in the share data object
|
|
81
91
|
// */
|
|
82
|
-
// export interface
|
|
92
|
+
// export interface IShareRuleSet {
|
|
83
93
|
// id: string; // the id of the rule set
|
|
84
94
|
// name: string; // the name of the rule set
|
|
85
95
|
// description: string; // the description of the rule set
|
|
86
|
-
// ruleGroups:
|
|
96
|
+
// ruleGroups: IShareRuleGroup[]; // the rules in the rule set
|
|
87
97
|
// }
|
|
88
98
|
exports.loanCreateRuleGroup = {
|
|
89
99
|
operator: generic_1.LogicalOperator.AND,
|
|
@@ -204,6 +214,18 @@ exports.userAgeCreate = {
|
|
|
204
214
|
],
|
|
205
215
|
targettedProperty: 'user'
|
|
206
216
|
};
|
|
217
|
+
exports.userAge18 = {
|
|
218
|
+
ruleId: 'user.age17to18',
|
|
219
|
+
currentDataConditions: [
|
|
220
|
+
{ targettedProperty: 'user.age', conditionType: generic_1.ConditionTypeSingle.EQUAL, conditionValue: 17, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS, },
|
|
221
|
+
{ targettedProperty: 'user.ageOfMajority', conditionType: generic_1.ConditionTypeBoolean.FALSE, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS, },
|
|
222
|
+
],
|
|
223
|
+
proposedDataConditions: [
|
|
224
|
+
{ targettedProperty: 'user.age', conditionType: generic_1.ConditionTypeSingle.EQUAL, conditionValue: 18, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS, },
|
|
225
|
+
{ targettedProperty: 'user.ageOfMajority', conditionType: generic_1.ConditionTypeBoolean.TRUE, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS, },
|
|
226
|
+
],
|
|
227
|
+
targettedProperty: 'user'
|
|
228
|
+
};
|
|
207
229
|
exports.userAgeUpdate = {
|
|
208
230
|
ruleId: 'user.ageUpdate',
|
|
209
231
|
currentDataConditions: [
|
|
@@ -337,3 +359,32 @@ exports.userCombinedDelete = {
|
|
|
337
359
|
targettedProperty: 'user'
|
|
338
360
|
};
|
|
339
361
|
//#endregion User
|
|
362
|
+
//#region IShareRule
|
|
363
|
+
const canadianAddress = {
|
|
364
|
+
streetAddress1: '123 Main St',
|
|
365
|
+
streetAddress2: 'Apt 1',
|
|
366
|
+
city: 'Toronto',
|
|
367
|
+
province: 'ON',
|
|
368
|
+
country: 'Canada',
|
|
369
|
+
postalCode: 'M1M 1M1'
|
|
370
|
+
};
|
|
371
|
+
exports.canadianAdddressCreate = {
|
|
372
|
+
ruleId: 'canadianAddressCreate',
|
|
373
|
+
currentDataConditions: [
|
|
374
|
+
{ targettedProperty: 'country', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.UNDEFINED, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
375
|
+
{ targettedProperty: 'postalCode', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.UNDEFINED, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
376
|
+
{ targettedProperty: 'streetAddress1', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.UNDEFINED, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
377
|
+
{ targettedProperty: 'streetAddress2', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.UNDEFINED, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
378
|
+
{ targettedProperty: 'province', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.UNDEFINED, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
379
|
+
{ targettedProperty: 'city', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.UNDEFINED, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
380
|
+
],
|
|
381
|
+
proposedDataConditions: [
|
|
382
|
+
{ targettedProperty: 'country', conditionType: generic_1.ConditionTypeSingle.EQUAL, conditionValue: 'Canada', conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
383
|
+
{ targettedProperty: 'postalCode', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.STRING, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
384
|
+
{ targettedProperty: 'streetAddress1', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.STRING, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
385
|
+
{ targettedProperty: 'streetAddress2', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.STRING, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
386
|
+
{ targettedProperty: 'province', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.STRING, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
387
|
+
{ targettedProperty: 'city', conditionType: generic_1.ConditionTypeSingle.TYPEOF, conditionValue: generic_1.ConditionTypeOf.STRING, conditionTypeQualifier: generic_1.ConditionTypeQualifier.IS },
|
|
388
|
+
],
|
|
389
|
+
};
|
|
390
|
+
//#endregion IShareRule
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IShareRuleApplied, LogicalOperator } from '@degenerate/generic';
|
|
2
|
+
import { IShareRuleGroup } from '@degenerate/generic';
|
|
3
|
+
/**
|
|
4
|
+
* This function creates a share rule group
|
|
5
|
+
* @param operator the logical operator to use
|
|
6
|
+
* @param rules the rules to apply
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
declare const createShareRuleGroup: (operator: LogicalOperator, rules: (IShareRuleApplied | IShareRuleGroup)[]) => IShareRuleGroup;
|
|
10
|
+
export { createShareRuleGroup };
|
|
11
|
+
//# sourceMappingURL=create-share-rule-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-share-rule-group.d.ts","sourceRoot":"","sources":["../../src/create/create-share-rule-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;;;GAKG;AACH,QAAA,MAAM,oBAAoB,aACZ,eAAe,SAClB,CAAC,iBAAiB,GAAG,eAAe,CAAC,EAAE,KAC/C,eAKF,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createShareRuleGroup = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This function creates a share rule group
|
|
6
|
+
* @param operator the logical operator to use
|
|
7
|
+
* @param rules the rules to apply
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
const createShareRuleGroup = (operator, rules) => {
|
|
11
|
+
return {
|
|
12
|
+
operator,
|
|
13
|
+
rules,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
exports.createShareRuleGroup = createShareRuleGroup;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IShareRuleGroup, IShareRuleSet } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* This creates a share rule set
|
|
4
|
+
*
|
|
5
|
+
* @param name the name of the rule set
|
|
6
|
+
* @param ruleGroups the rule groups to apply
|
|
7
|
+
* @param id the id of the rule set (optional)
|
|
8
|
+
* @param description the description of the rule set (optional)
|
|
9
|
+
* @param version the version of the rule set (default 1)
|
|
10
|
+
*/
|
|
11
|
+
declare const createShareRuleSet: (name: string, ruleGroups: IShareRuleGroup[], id?: string, description?: string, version?: number) => IShareRuleSet;
|
|
12
|
+
export { createShareRuleSet };
|
|
13
|
+
//# sourceMappingURL=create-share-rule-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-share-rule-set.d.ts","sourceRoot":"","sources":["../../src/create/create-share-rule-set.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,aAAa,EAIhB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB,SACd,MAAM,cACA,eAAe,EAAE,OACxB,MAAM,gBACG,MAAM,uBAErB,aAwBF,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createShareRuleSet = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
/**
|
|
6
|
+
* This creates a share rule set
|
|
7
|
+
*
|
|
8
|
+
* @param name the name of the rule set
|
|
9
|
+
* @param ruleGroups the rule groups to apply
|
|
10
|
+
* @param id the id of the rule set (optional)
|
|
11
|
+
* @param description the description of the rule set (optional)
|
|
12
|
+
* @param version the version of the rule set (default 1)
|
|
13
|
+
*/
|
|
14
|
+
const createShareRuleSet = (name, ruleGroups, id, description, version = 1) => {
|
|
15
|
+
let stringifiedId = '';
|
|
16
|
+
if ((0, generic_1.validateArray)(ruleGroups, 1)) {
|
|
17
|
+
throw new generic_1.SafeRuleRuleSetNoRuleGroupsError(name, description);
|
|
18
|
+
}
|
|
19
|
+
if (!id) { // create the
|
|
20
|
+
const stringForId = JSON.stringify(ruleGroups) + name + version;
|
|
21
|
+
stringifiedId = (0, generic_1.calculateHash)(stringForId, 'hex');
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
stringifiedId = id;
|
|
25
|
+
}
|
|
26
|
+
const shareRuleSet = {
|
|
27
|
+
id: stringifiedId,
|
|
28
|
+
name,
|
|
29
|
+
version,
|
|
30
|
+
ruleGroups,
|
|
31
|
+
};
|
|
32
|
+
if (description)
|
|
33
|
+
shareRuleSet.description = description;
|
|
34
|
+
return shareRuleSet;
|
|
35
|
+
};
|
|
36
|
+
exports.createShareRuleSet = createShareRuleSet;
|
package/dist/create/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export * from './conditions/create-special-conditions';
|
|
|
8
8
|
export * from './conditions/create-starts-end-with-conditions';
|
|
9
9
|
export * from './conditions/create-typeof-conditions';
|
|
10
10
|
export * from './create-share-rule-applied';
|
|
11
|
+
export * from './create-share-rule-group';
|
|
11
12
|
export * from './create-share-rule-id';
|
|
13
|
+
export * from './create-share-rule-set';
|
|
12
14
|
export * from './create-share-rule';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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"}
|
|
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,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC"}
|
package/dist/create/index.js
CHANGED
|
@@ -26,5 +26,7 @@ __exportStar(require("./conditions/create-starts-end-with-conditions"), exports)
|
|
|
26
26
|
__exportStar(require("./conditions/create-typeof-conditions"), exports);
|
|
27
27
|
//#endregion Conditional Functions
|
|
28
28
|
__exportStar(require("./create-share-rule-applied"), exports);
|
|
29
|
+
__exportStar(require("./create-share-rule-group"), exports);
|
|
29
30
|
__exportStar(require("./create-share-rule-id"), exports);
|
|
31
|
+
__exportStar(require("./create-share-rule-set"), exports);
|
|
30
32
|
__exportStar(require("./create-share-rule"), exports);
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,4 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./create"), exports);
|
|
17
18
|
__exportStar(require("./evaluation"), exports);
|
|
19
|
+
__exportStar(require("./validation"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function validates the base condition.
|
|
3
|
+
*
|
|
4
|
+
* @param incomingObject the object to validate
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare const validateConditionBase: (incomingObject: unknown) => void;
|
|
8
|
+
export { validateConditionBase };
|
|
9
|
+
//# sourceMappingURL=validate-condition-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-base.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-base.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,QAAA,MAAM,qBAAqB,mBAAoB,OAAO,KAAG,IAoBxD,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionBase = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const validate_condition_qualifier_1 = require("./validate-condition-qualifier");
|
|
6
|
+
/**
|
|
7
|
+
* This function validates the base condition.
|
|
8
|
+
*
|
|
9
|
+
* @param incomingObject the object to validate
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const validateConditionBase = (incomingObject) => {
|
|
13
|
+
if (typeof incomingObject !== 'object' || incomingObject === null) {
|
|
14
|
+
throw new generic_1.SafeRuleConditionNotObjectError(incomingObject);
|
|
15
|
+
}
|
|
16
|
+
if (!('conditionType' in incomingObject)) {
|
|
17
|
+
throw new generic_1.SafeRuleConditionPropertyMissingError('conditionType');
|
|
18
|
+
}
|
|
19
|
+
if (!('conditionTypeQualifier' in incomingObject)) {
|
|
20
|
+
throw new generic_1.SafeRuleConditionPropertyMissingError('conditionTypeQualifier');
|
|
21
|
+
}
|
|
22
|
+
// make sure the condition type qualifier is in the basic condition
|
|
23
|
+
(0, validate_condition_qualifier_1.validateConditionQualifier)(incomingObject['conditionTypeQualifier']);
|
|
24
|
+
if (!('targettedProperty' in incomingObject && typeof incomingObject['targettedProperty'] === 'string')) {
|
|
25
|
+
throw new generic_1.SafeRuleConditionPropertyMissingError('targettedProperty');
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
};
|
|
29
|
+
exports.validateConditionBase = validateConditionBase;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICondition } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* This function validates the boolean condition.
|
|
4
|
+
*
|
|
5
|
+
* @param incomingObject the object to validate
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const validateConditionBoolean: (incomingObject: ICondition) => void;
|
|
9
|
+
export { validateConditionBoolean };
|
|
10
|
+
//# sourceMappingURL=validate-condition-boolean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-boolean.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-boolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtF;;;;;GAKG;AACH,QAAA,MAAM,wBAAwB,mBAAoB,UAAU,KAAG,IAa9D,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionBoolean = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
|
+
/**
|
|
7
|
+
* This function validates the boolean condition.
|
|
8
|
+
*
|
|
9
|
+
* @param incomingObject the object to validate
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const validateConditionBoolean = (incomingObject) => {
|
|
13
|
+
// make sure there are 3 properties only
|
|
14
|
+
const totalProperties = Object.keys(incomingObject).length;
|
|
15
|
+
if (totalProperties !== 3) {
|
|
16
|
+
throw new generic_2.SafeRuleConditionHasMismatchingProperties(incomingObject, 3, totalProperties);
|
|
17
|
+
}
|
|
18
|
+
if (incomingObject['conditionType'] === generic_1.ConditionTypeBoolean.FALSE ||
|
|
19
|
+
incomingObject['conditionType'] === generic_1.ConditionTypeBoolean.TRUE) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw new generic_2.SafeRuleConditionNotTypeOfError('false or true', incomingObject['conditionType']);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.validateConditionBoolean = validateConditionBoolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICondition } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* This function validates the contains condition.
|
|
4
|
+
*
|
|
5
|
+
* @param incomingObject the object to validate
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const validateConditionContains: (incomingObject: ICondition) => void;
|
|
9
|
+
export { validateConditionContains };
|
|
10
|
+
//# sourceMappingURL=validate-condition-contains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-contains.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-contains.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,UAAU,EAMb,MAAM,qBAAqB,CAAC;AAE7B;;;;;GAKG;AACH,QAAA,MAAM,yBAAyB,mBAAoB,UAAU,KAAG,IAkC/D,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionContains = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
/**
|
|
6
|
+
* This function validates the contains condition.
|
|
7
|
+
*
|
|
8
|
+
* @param incomingObject the object to validate
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
const validateConditionContains = (incomingObject) => {
|
|
12
|
+
// make sure there are 4 properties only
|
|
13
|
+
const totalProperties = Object.keys(incomingObject).length;
|
|
14
|
+
if (totalProperties !== 4) {
|
|
15
|
+
throw new generic_1.SafeRuleConditionHasMismatchingProperties(incomingObject, 4, totalProperties);
|
|
16
|
+
}
|
|
17
|
+
if (incomingObject['conditionType'] !== generic_1.ConditionTypeSingle.CONTAINS) {
|
|
18
|
+
throw new generic_1.SafeRuleConditionNotTypeOfError(generic_1.ConditionTypeSingle.CONTAINS, incomingObject['conditionType']);
|
|
19
|
+
}
|
|
20
|
+
if (!('conditionValue' in incomingObject)) {
|
|
21
|
+
throw new generic_1.SafeRuleConditionPropertyMissingError('conditionValue');
|
|
22
|
+
}
|
|
23
|
+
// make sure the condition value is a string or an array of strings
|
|
24
|
+
if (typeof incomingObject['conditionValue'] === 'string') {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
if (!(0, generic_1.validateArray)(incomingObject['conditionValue'])) {
|
|
29
|
+
throw new generic_1.SafeRuleConditionValueWrongType(incomingObject['conditionValue'], 'string or array of strings');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// make sure all items in the array are strings
|
|
33
|
+
if ((0, generic_1.checkIfAllItemsInAnArrayAreSameType)(incomingObject['conditionValue'], 'string')) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if ((0, generic_1.checkIfAllItemsInAnArrayAreSameType)(incomingObject['conditionValue'], 'number')) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
throw new generic_1.SafeRuleConditionValueWrongType(incomingObject['conditionValue'], 'Values in array are not all strings or numbers');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.validateConditionContains = validateConditionContains;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICondition } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* This function validates the empty condition.
|
|
4
|
+
*
|
|
5
|
+
* @param incomingObject the object to validate
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const validateConditionEmpty: (incomingObject: ICondition) => void;
|
|
9
|
+
export { validateConditionEmpty };
|
|
10
|
+
//# sourceMappingURL=validate-condition-empty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-empty.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-empty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtE;;;;;GAKG;AACH,QAAA,MAAM,sBAAsB,mBAAoB,UAAU,SAYzD,CAAA;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionEmpty = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
|
+
/**
|
|
7
|
+
* This function validates the empty condition.
|
|
8
|
+
*
|
|
9
|
+
* @param incomingObject the object to validate
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const validateConditionEmpty = (incomingObject) => {
|
|
13
|
+
// make sure there are 3 properties only
|
|
14
|
+
const totalProperties = Object.keys(incomingObject).length;
|
|
15
|
+
if (totalProperties !== 3) {
|
|
16
|
+
throw new generic_2.SafeRuleConditionHasMismatchingProperties(incomingObject, 3, totalProperties);
|
|
17
|
+
}
|
|
18
|
+
if (incomingObject['conditionType'] !== generic_1.ConditionTypeSingle.EMPTY) {
|
|
19
|
+
throw new generic_2.SafeRuleConditionNotTypeOfError(generic_1.ConditionTypeSingle.EMPTY, incomingObject['conditionType']);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
};
|
|
23
|
+
exports.validateConditionEmpty = validateConditionEmpty;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICondition } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* This function validates the equality condition.
|
|
4
|
+
*
|
|
5
|
+
* @param incomingObject the object to validate
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const validateConditionEquality: (incomingObject: ICondition) => void;
|
|
9
|
+
export { validateConditionEquality };
|
|
10
|
+
//# sourceMappingURL=validate-condition-equality.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-equality.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-equality.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,UAAU,EACb,MAAM,qBAAqB,CAAC;AAO7B;;;;;GAKG;AACH,QAAA,MAAM,yBAAyB,mBAAoB,UAAU,KAAG,IAgB/D,CAAA;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionEquality = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
|
+
/**
|
|
7
|
+
* This function validates the equality condition.
|
|
8
|
+
*
|
|
9
|
+
* @param incomingObject the object to validate
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const validateConditionEquality = (incomingObject) => {
|
|
13
|
+
// make sure there are 4 properties only
|
|
14
|
+
const totalProperties = Object.keys(incomingObject).length;
|
|
15
|
+
if (totalProperties !== 4) {
|
|
16
|
+
throw new generic_2.SafeRuleConditionHasMismatchingProperties(incomingObject, 4, totalProperties);
|
|
17
|
+
}
|
|
18
|
+
if (incomingObject['conditionType'] !== generic_1.ConditionTypeSingle.EQUAL) {
|
|
19
|
+
throw new generic_2.SafeRuleConditionNotTypeOfError(generic_1.ConditionTypeSingle.EQUAL, incomingObject['conditionType']);
|
|
20
|
+
}
|
|
21
|
+
if (!('conditionValue' in incomingObject)) {
|
|
22
|
+
throw new generic_2.SafeRuleConditionPropertyMissingError('conditionValue');
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
};
|
|
26
|
+
exports.validateConditionEquality = validateConditionEquality;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICondition } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* This function validates the null condition.
|
|
4
|
+
*
|
|
5
|
+
* @param incomingObject the object to validate
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const validateConditionNull: (incomingObject: ICondition) => void;
|
|
9
|
+
export { validateConditionNull };
|
|
10
|
+
//# sourceMappingURL=validate-condition-null.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-null.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-null.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtE;;;;;GAKG;AACH,QAAA,MAAM,qBAAqB,mBAAoB,UAAU,KAAG,IAY3D,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionNull = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
|
+
/**
|
|
7
|
+
* This function validates the null condition.
|
|
8
|
+
*
|
|
9
|
+
* @param incomingObject the object to validate
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const validateConditionNull = (incomingObject) => {
|
|
13
|
+
// make sure there are 3 properties only
|
|
14
|
+
const totalProperties = Object.keys(incomingObject).length;
|
|
15
|
+
if (totalProperties !== 3) {
|
|
16
|
+
throw new generic_2.SafeRuleConditionHasMismatchingProperties(incomingObject, 3, totalProperties);
|
|
17
|
+
}
|
|
18
|
+
if (incomingObject['conditionType'] !== generic_1.ConditionTypeSingle.NULL) {
|
|
19
|
+
throw new generic_2.SafeRuleConditionNotTypeOfError(generic_1.ConditionTypeSingle.NULL, incomingObject['conditionType']);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
};
|
|
23
|
+
exports.validateConditionNull = validateConditionNull;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function validates the condition type qualifier.
|
|
3
|
+
*
|
|
4
|
+
* @param conditionTypeQualifier the condition type qualifier to validate
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare const validateConditionQualifier: (conditionTypeQualifier: unknown) => void;
|
|
8
|
+
export { validateConditionQualifier };
|
|
9
|
+
//# sourceMappingURL=validate-condition-qualifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-qualifier.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-qualifier.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,QAAA,MAAM,0BAA0B,2BAA4B,OAAO,KAAG,IAOrE,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionQualifier = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
|
+
/**
|
|
7
|
+
* This function validates the condition type qualifier.
|
|
8
|
+
*
|
|
9
|
+
* @param conditionTypeQualifier the condition type qualifier to validate
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const validateConditionQualifier = (conditionTypeQualifier) => {
|
|
13
|
+
const containsConditionQualifier = Object.values(generic_1.ConditionTypeQualifier).includes(conditionTypeQualifier);
|
|
14
|
+
if (!containsConditionQualifier) {
|
|
15
|
+
throw new generic_2.SafeRuleConditionQualifierError(conditionTypeQualifier);
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
};
|
|
19
|
+
exports.validateConditionQualifier = validateConditionQualifier;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICondition } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* The function validates the range condition.
|
|
4
|
+
* @param incomingObject
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare const validateConditionRange: (incomingObject: ICondition) => void;
|
|
8
|
+
export { validateConditionRange };
|
|
9
|
+
//# sourceMappingURL=validate-condition-range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-range.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGpF;;;;GAIG;AACH,QAAA,MAAM,sBAAsB,mBAAoB,UAAU,KAAG,IA+B5D,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionRange = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
|
+
/**
|
|
7
|
+
* The function validates the range condition.
|
|
8
|
+
* @param incomingObject
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
const validateConditionRange = (incomingObject) => {
|
|
12
|
+
// make sure there are 4 properties only
|
|
13
|
+
const totalProperties = Object.keys(incomingObject).length;
|
|
14
|
+
if (totalProperties !== 4) {
|
|
15
|
+
throw new generic_2.SafeRuleConditionHasMismatchingProperties(incomingObject, 4, totalProperties);
|
|
16
|
+
}
|
|
17
|
+
if (!(incomingObject['conditionType'] === generic_1.ConditionTypeRange.GREATER_THAN ||
|
|
18
|
+
incomingObject['conditionType'] === generic_1.ConditionTypeRange.GREATER_THAN_OR_EQUAL ||
|
|
19
|
+
incomingObject['conditionType'] === generic_1.ConditionTypeRange.LESS_THAN ||
|
|
20
|
+
incomingObject['conditionType'] === generic_1.ConditionTypeRange.LESS_THAN_OR_EQUAL)) {
|
|
21
|
+
throw new generic_2.SafeRuleConditionNotTypeOfError('greater than or | greater than or equal | less than | less than or equal', incomingObject['conditionType']);
|
|
22
|
+
}
|
|
23
|
+
if (!('conditionValue' in incomingObject)) {
|
|
24
|
+
throw new generic_2.SafeRuleConditionPropertyMissingError('conditionValue');
|
|
25
|
+
}
|
|
26
|
+
// make sure the condition value is a string or number
|
|
27
|
+
if (typeof incomingObject['conditionValue'] === 'string') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (typeof incomingObject['conditionValue'] === 'number') {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
throw new generic_2.SafeRuleConditionValueWrongType(incomingObject['conditionValue'], 'string or number');
|
|
34
|
+
};
|
|
35
|
+
exports.validateConditionRange = validateConditionRange;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICondition } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* This validates the condition to be a type of a share rule.
|
|
4
|
+
*
|
|
5
|
+
* @param incomingObject the object to validate as a share rule condition
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const validateConditionShareRule: (incomingObject: ICondition) => void;
|
|
9
|
+
export { validateConditionShareRule };
|
|
10
|
+
//# sourceMappingURL=validate-condition-share-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-share-rule.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-share-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,UAAU,EAKb,MAAM,qBAAqB,CAAC;AAG7B;;;;;GAKG;AACH,QAAA,MAAM,0BAA0B,mBAAoB,UAAU,KAAG,IA0BhE,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionShareRule = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const validate_share_rule_1 = require("../validate-share-rule");
|
|
6
|
+
/**
|
|
7
|
+
* This validates the condition to be a type of a share rule.
|
|
8
|
+
*
|
|
9
|
+
* @param incomingObject the object to validate as a share rule condition
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const validateConditionShareRule = (incomingObject) => {
|
|
13
|
+
// make sure there are 4 properties only
|
|
14
|
+
const totalProperties = Object.keys(incomingObject).length;
|
|
15
|
+
if (totalProperties !== 4) {
|
|
16
|
+
throw new generic_1.SafeRuleConditionHasMismatchingProperties(incomingObject, 4, totalProperties);
|
|
17
|
+
}
|
|
18
|
+
if (incomingObject['conditionType'] !== generic_1.ConditionTypeSingle.SHARE_RULE) {
|
|
19
|
+
throw new generic_1.SafeRuleConditionNotTypeOfError(generic_1.ConditionTypeSingle.SHARE_RULE, incomingObject['conditionType']);
|
|
20
|
+
}
|
|
21
|
+
if (!('conditionValue' in incomingObject)) {
|
|
22
|
+
throw new generic_1.SafeRuleConditionPropertyMissingError('conditionValue');
|
|
23
|
+
}
|
|
24
|
+
// make sure the condition value is an object that is not null
|
|
25
|
+
if (typeof incomingObject['conditionValue'] === 'object' &&
|
|
26
|
+
incomingObject['conditionValue'] !== null) {
|
|
27
|
+
(0, validate_share_rule_1.validateShareRule)(incomingObject['conditionValue']);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new generic_1.SafeRuleConditionValueWrongType(incomingObject['conditionValue'], 'object');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.validateConditionShareRule = validateConditionShareRule;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICondition } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* This function validates the special condition.
|
|
4
|
+
*
|
|
5
|
+
* @param incomingObject the object to validate
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const validateConditionSpecial: (incomingObject: ICondition) => void;
|
|
9
|
+
export { validateConditionSpecial };
|
|
10
|
+
//# sourceMappingURL=validate-condition-special.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-special.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-special.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAInH;;;;;GAKG;AACH,QAAA,MAAM,wBAAwB,mBAAoB,UAAU,KAAG,IAwB9D,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionSpecial = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
|
+
/**
|
|
7
|
+
* This function validates the special condition.
|
|
8
|
+
*
|
|
9
|
+
* @param incomingObject the object to validate
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const validateConditionSpecial = (incomingObject) => {
|
|
13
|
+
// make sure there are 4 properties only
|
|
14
|
+
const totalProperties = Object.keys(incomingObject).length;
|
|
15
|
+
if (totalProperties !== 4) {
|
|
16
|
+
throw new generic_2.SafeRuleConditionHasMismatchingProperties(incomingObject, 4, totalProperties);
|
|
17
|
+
}
|
|
18
|
+
if (!(incomingObject['conditionType'] === generic_1.ConditionTypeSpecial.PATTERN)) {
|
|
19
|
+
throw new generic_2.SafeRuleConditionNotTypeOfError('condition type is not pattern', incomingObject['conditionType']);
|
|
20
|
+
}
|
|
21
|
+
if (!('conditionValue' in incomingObject)) {
|
|
22
|
+
throw new generic_2.SafeRuleConditionPropertyMissingError('conditionValue');
|
|
23
|
+
}
|
|
24
|
+
// make sure the condition value is a string or number
|
|
25
|
+
if (typeof incomingObject['conditionValue'] !== 'string') {
|
|
26
|
+
throw new generic_2.SafeRuleConditionValueWrongType(incomingObject['conditionValue'], 'string');
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
};
|
|
30
|
+
exports.validateConditionSpecial = validateConditionSpecial;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICondition } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* This function validates the starts or ends with condition.
|
|
4
|
+
*
|
|
5
|
+
* @param incomingObject the object to validate
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const validateConditionStartsEndsWith: (incomingObject: ICondition) => void;
|
|
9
|
+
export { validateConditionStartsEndsWith };
|
|
10
|
+
//# sourceMappingURL=validate-condition-starts-ends-with.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-starts-ends-with.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-starts-ends-with.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAI7F;;;;;GAKG;AACH,QAAA,MAAM,+BAA+B,mBAAoB,UAAU,KAAG,IAyBrE,CAAC;AAEF,OAAO,EAAE,+BAA+B,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionStartsEndsWith = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
|
+
/**
|
|
7
|
+
* This function validates the starts or ends with condition.
|
|
8
|
+
*
|
|
9
|
+
* @param incomingObject the object to validate
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const validateConditionStartsEndsWith = (incomingObject) => {
|
|
13
|
+
// make sure there are 4 properties only
|
|
14
|
+
const totalProperties = Object.keys(incomingObject).length;
|
|
15
|
+
if (totalProperties !== 4) {
|
|
16
|
+
throw new generic_2.SafeRuleConditionHasMismatchingProperties(incomingObject, 4, totalProperties);
|
|
17
|
+
}
|
|
18
|
+
if (!(incomingObject['conditionType'] === generic_1.ConditionTypeStartsEndsWith.ENDS_WITH ||
|
|
19
|
+
incomingObject['conditionType'] === generic_1.ConditionTypeStartsEndsWith.STARTS_WITH)) {
|
|
20
|
+
throw new generic_2.SafeRuleConditionNotTypeOfError('starts or endwith not set as condition type', incomingObject['conditionType']);
|
|
21
|
+
}
|
|
22
|
+
if (!('conditionValue' in incomingObject)) {
|
|
23
|
+
throw new generic_2.SafeRuleConditionPropertyMissingError('conditionValue');
|
|
24
|
+
}
|
|
25
|
+
// make sure the condition value is a string or number
|
|
26
|
+
if (typeof incomingObject['conditionValue'] !== 'string') {
|
|
27
|
+
throw new generic_2.SafeRuleConditionValueWrongType(incomingObject['conditionValue'], 'string');
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
};
|
|
31
|
+
exports.validateConditionStartsEndsWith = validateConditionStartsEndsWith;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICondition } from '@degenerate/generic';
|
|
2
|
+
/**
|
|
3
|
+
* this validates that the type of condition is correct
|
|
4
|
+
*
|
|
5
|
+
* @param incomingObject the object to validate
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
declare const validateConditionTypeOf: (incomingObject: ICondition) => void;
|
|
9
|
+
export { validateConditionTypeOf };
|
|
10
|
+
//# sourceMappingURL=validate-condition-type-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-condition-type-of.d.ts","sourceRoot":"","sources":["../../../src/validation/conditions/validate-condition-type-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,UAAU,EACb,MAAM,qBAAqB,CAAC;AAO7B;;;;;GAKG;AACH,QAAA,MAAM,uBAAuB,mBAAoB,UAAU,KAAG,IAqB7D,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConditionTypeOf = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
|
+
/**
|
|
7
|
+
* this validates that the type of condition is correct
|
|
8
|
+
*
|
|
9
|
+
* @param incomingObject the object to validate
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const validateConditionTypeOf = (incomingObject) => {
|
|
13
|
+
// make sure there are 4 properties only
|
|
14
|
+
const totalProperties = Object.keys(incomingObject).length;
|
|
15
|
+
if (totalProperties !== 4) {
|
|
16
|
+
throw new generic_2.SafeRuleConditionHasMismatchingProperties(incomingObject, 4, totalProperties);
|
|
17
|
+
}
|
|
18
|
+
if (incomingObject['conditionType'] !== generic_1.ConditionTypeSingle.TYPEOF) {
|
|
19
|
+
throw new generic_2.SafeRuleConditionNotTypeOfError(generic_1.ConditionTypeSingle.TYPEOF, incomingObject['conditionType']);
|
|
20
|
+
}
|
|
21
|
+
if (!('conditionValue' in incomingObject)) {
|
|
22
|
+
throw new generic_2.SafeRuleConditionPropertyMissingError('conditionValue');
|
|
23
|
+
}
|
|
24
|
+
// ensure that the condition value is part of the ConditionTypeOf enum
|
|
25
|
+
if (!Object.values(generic_1.ConditionTypeOf).includes(incomingObject['conditionValue'])) {
|
|
26
|
+
throw new generic_2.SafeRuleConditionNotTypeOfError(generic_1.ConditionTypeSingle.TYPEOF, incomingObject['conditionValue']);
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
};
|
|
30
|
+
exports.validateConditionTypeOf = validateConditionTypeOf;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function determines the condition to validate.
|
|
3
|
+
*
|
|
4
|
+
* @param incomingObject the object to validate
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare const determineConditionToValidate: (incomingObject: unknown) => void;
|
|
8
|
+
export { determineConditionToValidate };
|
|
9
|
+
//# sourceMappingURL=determine-condition-to-validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"determine-condition-to-validate.d.ts","sourceRoot":"","sources":["../../src/validation/determine-condition-to-validate.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,QAAA,MAAM,4BAA4B,mBAAoB,OAAO,KAAG,IAiC/D,CAAC;AAEF,OAAO,EAAE,4BAA4B,EAAE,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.determineConditionToValidate = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const validate_condition_base_1 = require("./conditions/validate-condition-base");
|
|
6
|
+
const validate_condition_type_of_1 = require("./conditions/validate-condition-type-of");
|
|
7
|
+
const validate_condition_equality_1 = require("./conditions/validate-condition-equality");
|
|
8
|
+
const validate_condition_contains_1 = require("./conditions/validate-condition-contains");
|
|
9
|
+
const validate_condition_null_1 = require("./conditions/validate-condition-null");
|
|
10
|
+
const validate_condition_empty_1 = require("./conditions/validate-condition-empty");
|
|
11
|
+
const validate_condition_boolean_1 = require("./conditions/validate-condition-boolean");
|
|
12
|
+
const validate_condition_range_1 = require("./conditions/validate-condition-range");
|
|
13
|
+
const validate_condition_starts_ends_with_1 = require("./conditions/validate-condition-starts-ends-with");
|
|
14
|
+
const validate_condition_special_1 = require("./conditions/validate-condition-special");
|
|
15
|
+
const generic_2 = require("@degenerate/generic");
|
|
16
|
+
const validate_share_rule_1 = require("./validate-share-rule");
|
|
17
|
+
/**
|
|
18
|
+
* This function determines the condition to validate.
|
|
19
|
+
*
|
|
20
|
+
* @param incomingObject the object to validate
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
const determineConditionToValidate = (incomingObject) => {
|
|
24
|
+
(0, validate_condition_base_1.validateConditionBase)(incomingObject);
|
|
25
|
+
const condition = incomingObject;
|
|
26
|
+
switch (condition.conditionType) {
|
|
27
|
+
case generic_1.ConditionTypeSingle.TYPEOF:
|
|
28
|
+
return (0, validate_condition_type_of_1.validateConditionTypeOf)(condition);
|
|
29
|
+
case generic_1.ConditionTypeSingle.EQUAL:
|
|
30
|
+
return (0, validate_condition_equality_1.validateConditionEquality)(condition);
|
|
31
|
+
case generic_1.ConditionTypeSingle.CONTAINS:
|
|
32
|
+
return (0, validate_condition_contains_1.validateConditionContains)(condition);
|
|
33
|
+
case generic_1.ConditionTypeSingle.NULL:
|
|
34
|
+
return (0, validate_condition_null_1.validateConditionNull)(condition);
|
|
35
|
+
case generic_1.ConditionTypeSingle.EMPTY:
|
|
36
|
+
return (0, validate_condition_empty_1.validateConditionEmpty)(condition);
|
|
37
|
+
case generic_1.ConditionTypeBoolean.TRUE:
|
|
38
|
+
case generic_1.ConditionTypeBoolean.FALSE:
|
|
39
|
+
return (0, validate_condition_boolean_1.validateConditionBoolean)(condition);
|
|
40
|
+
case generic_1.ConditionTypeRange.GREATER_THAN:
|
|
41
|
+
case generic_1.ConditionTypeRange.LESS_THAN:
|
|
42
|
+
case generic_1.ConditionTypeRange.GREATER_THAN_OR_EQUAL:
|
|
43
|
+
case generic_1.ConditionTypeRange.LESS_THAN_OR_EQUAL:
|
|
44
|
+
return (0, validate_condition_range_1.validateConditionRange)(condition);
|
|
45
|
+
case generic_1.ConditionTypeStartsEndsWith.STARTS_WITH:
|
|
46
|
+
case generic_1.ConditionTypeStartsEndsWith.ENDS_WITH:
|
|
47
|
+
return (0, validate_condition_starts_ends_with_1.validateConditionStartsEndsWith)(condition);
|
|
48
|
+
case generic_1.ConditionTypeSpecial.PATTERN:
|
|
49
|
+
return (0, validate_condition_special_1.validateConditionSpecial)(condition);
|
|
50
|
+
case generic_1.ConditionTypeSingle.SHARE_RULE:
|
|
51
|
+
return (0, validate_share_rule_1.validateShareRule)(condition);
|
|
52
|
+
default:
|
|
53
|
+
throw new generic_2.SafeRuleConditionTypeNotValidError(condition['conditionType']);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.determineConditionToValidate = determineConditionToValidate;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './conditions/validate-condition-base';
|
|
2
|
+
export * from './conditions/validate-condition-boolean';
|
|
3
|
+
export * from './conditions/validate-condition-contains';
|
|
4
|
+
export * from './conditions/validate-condition-empty';
|
|
5
|
+
export * from './conditions/validate-condition-equality';
|
|
6
|
+
export * from './conditions/validate-condition-null';
|
|
7
|
+
export * from './conditions/validate-condition-qualifier';
|
|
8
|
+
export * from './conditions/validate-condition-range';
|
|
9
|
+
export * from './conditions/validate-condition-share-rule';
|
|
10
|
+
export * from './conditions/validate-condition-special';
|
|
11
|
+
export * from './conditions/validate-condition-starts-ends-with';
|
|
12
|
+
export * from './conditions/validate-condition-type-of';
|
|
13
|
+
export * from './determine-condition-to-validate';
|
|
14
|
+
export * from './validate-share-rule';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AACA,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,uCAAuC,CAAC;AACtD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,uCAAuC,CAAC;AACtD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,yCAAyC,CAAC;AACxD,cAAc,kDAAkD,CAAC;AACjE,cAAc,yCAAyC,CAAC;AAGxD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
//#region conditions
|
|
18
|
+
__exportStar(require("./conditions/validate-condition-base"), exports);
|
|
19
|
+
__exportStar(require("./conditions/validate-condition-boolean"), exports);
|
|
20
|
+
__exportStar(require("./conditions/validate-condition-contains"), exports);
|
|
21
|
+
__exportStar(require("./conditions/validate-condition-empty"), exports);
|
|
22
|
+
__exportStar(require("./conditions/validate-condition-equality"), exports);
|
|
23
|
+
__exportStar(require("./conditions/validate-condition-null"), exports);
|
|
24
|
+
__exportStar(require("./conditions/validate-condition-qualifier"), exports);
|
|
25
|
+
__exportStar(require("./conditions/validate-condition-range"), exports);
|
|
26
|
+
__exportStar(require("./conditions/validate-condition-share-rule"), exports);
|
|
27
|
+
__exportStar(require("./conditions/validate-condition-special"), exports);
|
|
28
|
+
__exportStar(require("./conditions/validate-condition-starts-ends-with"), exports);
|
|
29
|
+
__exportStar(require("./conditions/validate-condition-type-of"), exports);
|
|
30
|
+
//#endregion conditions
|
|
31
|
+
__exportStar(require("./determine-condition-to-validate"), exports);
|
|
32
|
+
__exportStar(require("./validate-share-rule"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function validates the share rule.
|
|
3
|
+
*
|
|
4
|
+
* @param incomingObject the object to validate
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare const validateShareRule: (incomingObject: unknown) => void;
|
|
8
|
+
export { validateShareRule };
|
|
9
|
+
//# sourceMappingURL=validate-share-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-share-rule.d.ts","sourceRoot":"","sources":["../../src/validation/validate-share-rule.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB,mBAAoB,OAAO,KAAG,IA8CpD,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateShareRule = void 0;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
|
+
const determine_condition_to_validate_1 = require("./determine-condition-to-validate");
|
|
7
|
+
/**
|
|
8
|
+
* This function validates the share rule.
|
|
9
|
+
*
|
|
10
|
+
* @param incomingObject the object to validate
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
const validateShareRule = (incomingObject) => {
|
|
14
|
+
// make sure the incoming object is an object
|
|
15
|
+
if (typeof incomingObject !== 'object' || incomingObject === null) {
|
|
16
|
+
throw new generic_2.SafeRuleNotObjectError(incomingObject);
|
|
17
|
+
}
|
|
18
|
+
const shareRule = incomingObject;
|
|
19
|
+
// make sure the object has the correct properties
|
|
20
|
+
const expectedProperties = ['ruleId', 'currentDataConditions', 'proposedDataConditions'];
|
|
21
|
+
const actualProperties = Object.keys(shareRule);
|
|
22
|
+
// make sure the object has the correct number of properties
|
|
23
|
+
if (expectedProperties.length !== actualProperties.length) {
|
|
24
|
+
throw new generic_2.SafeRuleHasMismatchingProperties(shareRule, expectedProperties.length, actualProperties.length);
|
|
25
|
+
}
|
|
26
|
+
// make sure the object has the correct properties
|
|
27
|
+
expectedProperties.forEach((property) => {
|
|
28
|
+
if (!actualProperties.includes(property)) {
|
|
29
|
+
throw new generic_2.SafeRuleHasMissingProperty(shareRule, property);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
// make sure that the properties for the share rule are valid
|
|
33
|
+
if (typeof shareRule['ruleId'] !== 'string') {
|
|
34
|
+
throw new generic_2.SafeRuleConditionValueWrongType(shareRule['ruleId'], 'string');
|
|
35
|
+
}
|
|
36
|
+
if (!(0, generic_1.validateArray)(shareRule['currentDataConditions'], 1)) {
|
|
37
|
+
throw new generic_2.SafeRuleConditionValueWrongType(shareRule['currentDataConditions'], 'array');
|
|
38
|
+
}
|
|
39
|
+
if (!(0, generic_1.validateArray)(shareRule['proposedDataConditions'], 1)) {
|
|
40
|
+
throw new generic_2.SafeRuleConditionValueWrongType(shareRule['proposedDataConditions'], 'array');
|
|
41
|
+
}
|
|
42
|
+
// loop through the current data conditions and validate them
|
|
43
|
+
for (const condition of shareRule['currentDataConditions']) {
|
|
44
|
+
(0, determine_condition_to_validate_1.determineConditionToValidate)(condition);
|
|
45
|
+
}
|
|
46
|
+
// loop through the proposed data conditions and validate them
|
|
47
|
+
for (const condition of shareRule['proposedDataConditions']) {
|
|
48
|
+
(0, determine_condition_to_validate_1.determineConditionToValidate)(condition);
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
};
|
|
52
|
+
exports.validateShareRule = validateShareRule;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@degenerate/rules",
|
|
3
3
|
"description": "This contains the rules information needed for the ShareData Adaptive Framework Ecosystem (SAFE) network.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"devDependencies": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"homepage": "https://github.com/syncrude/safe#readme",
|
|
36
36
|
"author": "Degenerate Inc.",
|
|
37
37
|
"license": "ISC",
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "914fe4dbb4c4a61963d137a4c583bd9084e2d802",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@degenerate/generic": "^0.1.
|
|
40
|
+
"@degenerate/generic": "^0.1.4"
|
|
41
41
|
}
|
|
42
42
|
}
|