@clxmedia/clxforms-client 1.0.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.
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.js +9 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +11 -0
- package/dist/layout-processor.d.ts +35 -0
- package/dist/layout-processor.js +115 -0
- package/dist/rules-engine.d.ts +6 -0
- package/dist/rules-engine.js +105 -0
- package/dist/rules-processor.d.ts +6 -0
- package/dist/rules-processor.js +40 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 John Biundo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<h1 align="center"></h1>
|
|
2
|
+
|
|
3
|
+
<h3 align="center">CLXperience Forms Client</h3>
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Static processing of form data and rule conditions
|
|
8
|
+
|
|
9
|
+
## Change Log
|
|
10
|
+
|
|
11
|
+
See [Changelog](CHANGELOG.md) for more information.
|
|
12
|
+
|
|
13
|
+
## Author
|
|
14
|
+
|
|
15
|
+
**Brandon Thompson**
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
Licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CLXFormMode } from '@clxmedia/types/core/clxforms';
|
|
2
|
+
export type CLXFormRights = 'none' | 'view' | 'edit' | 'admin';
|
|
3
|
+
export type CLXFormSettings = {
|
|
4
|
+
rights: CLXFormRights;
|
|
5
|
+
mode: CLXFormMode;
|
|
6
|
+
locked: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const CLXFormConstants: {
|
|
9
|
+
yesNoOptions: {
|
|
10
|
+
value: string;
|
|
11
|
+
label: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { CLXFormLayoutProcessor, ProcessedCLXFormSection, ProcessedCLXFormStep, ProcessedCLXFormLayout } from './layout-processor';
|
|
2
|
+
export { CLXRulesetProcessor } from './rules-processor';
|
|
3
|
+
export { CLXRulesEngine } from './rules-engine';
|
|
4
|
+
export { CLXFormConstants, CLXFormRights, CLXFormSettings } from './constants';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLXFormConstants = exports.CLXRulesEngine = exports.CLXRulesetProcessor = exports.CLXFormLayoutProcessor = void 0;
|
|
4
|
+
var layout_processor_1 = require("./layout-processor");
|
|
5
|
+
Object.defineProperty(exports, "CLXFormLayoutProcessor", { enumerable: true, get: function () { return layout_processor_1.CLXFormLayoutProcessor; } });
|
|
6
|
+
var rules_processor_1 = require("./rules-processor");
|
|
7
|
+
Object.defineProperty(exports, "CLXRulesetProcessor", { enumerable: true, get: function () { return rules_processor_1.CLXRulesetProcessor; } });
|
|
8
|
+
var rules_engine_1 = require("./rules-engine");
|
|
9
|
+
Object.defineProperty(exports, "CLXRulesEngine", { enumerable: true, get: function () { return rules_engine_1.CLXRulesEngine; } });
|
|
10
|
+
var constants_1 = require("./constants");
|
|
11
|
+
Object.defineProperty(exports, "CLXFormConstants", { enumerable: true, get: function () { return constants_1.CLXFormConstants; } });
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CLXFormLayout, CLXFormMode, CLXFormQuestionLayout, CLXFormResponses, CLXFormRuleSet, FormStats } from '@clxmedia/types/core/clxforms';
|
|
2
|
+
import { CLXFormRights } from './constants';
|
|
3
|
+
export type ProcessedCLXFormSection = {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
question_layouts: CLXFormQuestionLayout[];
|
|
7
|
+
conditions?: CLXFormRuleSet;
|
|
8
|
+
is_complete: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type ProcessedCLXFormStep = {
|
|
11
|
+
id: number;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
is_gate: boolean;
|
|
15
|
+
sections: ProcessedCLXFormSection[];
|
|
16
|
+
conditions?: CLXFormRuleSet;
|
|
17
|
+
is_complete: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type ProcessedCLXFormLayout = {
|
|
20
|
+
form: {
|
|
21
|
+
slug: string;
|
|
22
|
+
name: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
};
|
|
25
|
+
steps: ProcessedCLXFormStep[];
|
|
26
|
+
stats?: FormStats;
|
|
27
|
+
};
|
|
28
|
+
export declare const CLXFormLayoutProcessor: ({ mode, responseData, formRights }: {
|
|
29
|
+
mode: CLXFormMode;
|
|
30
|
+
responseData: CLXFormResponses;
|
|
31
|
+
formRights: CLXFormRights;
|
|
32
|
+
}) => {
|
|
33
|
+
process: (layout: CLXFormLayout) => ProcessedCLXFormLayout;
|
|
34
|
+
processRuleSet: (ruleSet?: CLXFormRuleSet) => boolean;
|
|
35
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLXFormLayoutProcessor = void 0;
|
|
4
|
+
const rules_processor_1 = require("./rules-processor");
|
|
5
|
+
const CLXFormLayoutProcessor = ({ mode, responseData, formRights }) => {
|
|
6
|
+
const isQuestionLayoutEnabled = (questionLayout) => {
|
|
7
|
+
if (mode === 'edit') {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (questionLayout.is_enabled === false) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (!questionLayout.conditions ||
|
|
14
|
+
!questionLayout.conditions.rules ||
|
|
15
|
+
questionLayout.conditions.rules.length === 0) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return (0, rules_processor_1.CLXRulesetProcessor)({ responseData }).processRuleSet(questionLayout.conditions);
|
|
19
|
+
};
|
|
20
|
+
const containsErrors = (errs) => {
|
|
21
|
+
return errs !== undefined && Array.isArray(errs) && errs.some(err => err !== null);
|
|
22
|
+
};
|
|
23
|
+
const isResponseSaved = (response) => {
|
|
24
|
+
if (!response) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return !!response && response.value !== undefined && !containsErrors(response.errorMsg);
|
|
28
|
+
};
|
|
29
|
+
const isSectionComplete = (section) => {
|
|
30
|
+
if (!section || !section.question_layouts || section.question_layouts.length === 0) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const requiredQuestionLayouts = section.question_layouts.filter(ql => {
|
|
34
|
+
return ql.is_required && isQuestionLayoutEnabled(ql);
|
|
35
|
+
});
|
|
36
|
+
return requiredQuestionLayouts.every(ql => {
|
|
37
|
+
return isResponseSaved(responseData[ql.form_question_slug]);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const questionLayoutProcessor = (questionLayout, response) => {
|
|
41
|
+
const is_enabled = isQuestionLayoutEnabled(questionLayout);
|
|
42
|
+
return Object.assign(Object.assign({}, questionLayout), { is_enabled, is_complete: is_enabled ? isResponseSaved(response) : false });
|
|
43
|
+
};
|
|
44
|
+
const sectionProcessor = (section) => {
|
|
45
|
+
if (section.conditions && !(0, rules_processor_1.CLXRulesetProcessor)({ responseData }).processRuleSet(section.conditions)) {
|
|
46
|
+
return Object.assign(Object.assign({}, section), { is_complete: true, question_layouts: [] });
|
|
47
|
+
}
|
|
48
|
+
const is_section_complete = isSectionComplete(section);
|
|
49
|
+
return Object.assign(Object.assign({}, section), { is_complete: is_section_complete, question_layouts: section.question_layouts.map(questionLayout => questionLayoutProcessor(questionLayout, responseData[questionLayout.form_question_slug])) });
|
|
50
|
+
};
|
|
51
|
+
const stepProcessor = (step) => {
|
|
52
|
+
if (step.conditions && !(0, rules_processor_1.CLXRulesetProcessor)({ responseData }).processRuleSet(step.conditions)) {
|
|
53
|
+
return Object.assign(Object.assign({}, step), { is_complete: true, sections: [] });
|
|
54
|
+
}
|
|
55
|
+
const sections = step.sections
|
|
56
|
+
.map(section => sectionProcessor(section))
|
|
57
|
+
.filter(section => section.question_layouts.some(ql => ql.is_enabled));
|
|
58
|
+
return Object.assign(Object.assign({}, step), { is_complete: sections.every(section => section.is_complete), sections });
|
|
59
|
+
};
|
|
60
|
+
const gatherFormStats = (steps) => {
|
|
61
|
+
const allEnabledQuestions = steps
|
|
62
|
+
.flatMap(step => step.sections)
|
|
63
|
+
.flatMap(section => section.question_layouts)
|
|
64
|
+
.filter(ql => ql.is_enabled);
|
|
65
|
+
const requiredQuestions = allEnabledQuestions.filter(ql => ql.is_required);
|
|
66
|
+
const optionalQuestions = allEnabledQuestions.filter(ql => !ql.is_required);
|
|
67
|
+
return {
|
|
68
|
+
required: { complete: requiredQuestions.filter(rq => rq.is_complete).length, total: requiredQuestions.length },
|
|
69
|
+
optional: { complete: optionalQuestions.filter(rq => rq.is_complete).length, total: optionalQuestions.length }
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const isResponseBooleanTrue = (key) => {
|
|
73
|
+
const value = responseData[key];
|
|
74
|
+
return !!value && value.type === 'BOOLEAN' && value.value;
|
|
75
|
+
};
|
|
76
|
+
const MockProcessor = (layout) => {
|
|
77
|
+
return {
|
|
78
|
+
form: layout.form,
|
|
79
|
+
steps: layout.steps.map(step => {
|
|
80
|
+
return Object.assign(Object.assign({}, step), { is_complete: false, sections: step.sections.map(section => {
|
|
81
|
+
return Object.assign(Object.assign({}, section), { is_complete: false });
|
|
82
|
+
}) });
|
|
83
|
+
})
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const process = (layout) => {
|
|
87
|
+
if (mode === 'edit') {
|
|
88
|
+
return MockProcessor(layout);
|
|
89
|
+
}
|
|
90
|
+
let isGated = false;
|
|
91
|
+
const isCLXInternalUser = isResponseBooleanTrue('is_clxinternal_user');
|
|
92
|
+
const steps = formRights === 'none'
|
|
93
|
+
? []
|
|
94
|
+
: layout.steps
|
|
95
|
+
.map(step => stepProcessor(step))
|
|
96
|
+
.filter(step => step.sections.length > 0)
|
|
97
|
+
.reduce((acc, step) => {
|
|
98
|
+
if (isGated && !isCLXInternalUser) {
|
|
99
|
+
return acc;
|
|
100
|
+
}
|
|
101
|
+
if (step.is_gate && !isCLXInternalUser) {
|
|
102
|
+
isGated = !step.is_complete;
|
|
103
|
+
}
|
|
104
|
+
acc.push(step);
|
|
105
|
+
return acc;
|
|
106
|
+
}, [])
|
|
107
|
+
.filter(step => !step.is_gate || isCLXInternalUser);
|
|
108
|
+
return { form: layout.form, steps, stats: gatherFormStats(steps) };
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
process,
|
|
112
|
+
processRuleSet: (0, rules_processor_1.CLXRulesetProcessor)({ responseData }).processRuleSet
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
exports.CLXFormLayoutProcessor = CLXFormLayoutProcessor;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CLXFormResponseDateValue, CLXFormRuleInstance } from '@clxmedia/types/core/clxforms';
|
|
2
|
+
export declare const CLXRulesEngine: {
|
|
3
|
+
compareNumbers: (comparison: 'numberEquals' | 'numberGreaterThan' | 'numberLessThan', a?: any, b?: any) => boolean;
|
|
4
|
+
compareDates: (comparison: 'dateEquals' | 'dateBefore' | 'dateAfter', subject?: CLXFormResponseDateValue, target?: CLXFormResponseDateValue) => boolean;
|
|
5
|
+
evaluateRuleInstance: (ruleInstance?: CLXFormRuleInstance) => boolean;
|
|
6
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLXRulesEngine = void 0;
|
|
4
|
+
const luxon_1 = require("luxon");
|
|
5
|
+
exports.CLXRulesEngine = {
|
|
6
|
+
compareNumbers: (comparison, a, b) => {
|
|
7
|
+
if (a === undefined || b === undefined) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (isNaN(Number(a)) || isNaN(Number(b))) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
switch (comparison) {
|
|
14
|
+
case 'numberEquals':
|
|
15
|
+
return Number(a) === Number(b);
|
|
16
|
+
case 'numberGreaterThan':
|
|
17
|
+
return Number(a) > Number(b);
|
|
18
|
+
case 'numberLessThan':
|
|
19
|
+
return Number(a) < Number(b);
|
|
20
|
+
default:
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
compareDates: (comparison, subject, target) => {
|
|
25
|
+
if (subject === undefined || target === undefined || subject.type !== 'DATE' || target.type !== 'DATE') {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const subjectDate = luxon_1.DateTime.fromISO(subject.value.iso_date_time, { zone: subject.value.zone }).toSeconds();
|
|
30
|
+
const targetDate = luxon_1.DateTime.fromISO(target.value.iso_date_time, { zone: target.value.zone }).toSeconds();
|
|
31
|
+
switch (comparison) {
|
|
32
|
+
case 'dateEquals':
|
|
33
|
+
return subjectDate === targetDate;
|
|
34
|
+
case 'dateBefore':
|
|
35
|
+
return subjectDate < targetDate;
|
|
36
|
+
case 'dateAfter':
|
|
37
|
+
return subjectDate > targetDate;
|
|
38
|
+
default:
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
evaluateRuleInstance: (ruleInstance) => {
|
|
47
|
+
var _a, _b, _c, _d, _e, _f;
|
|
48
|
+
if (!ruleInstance ||
|
|
49
|
+
ruleInstance.subject === undefined ||
|
|
50
|
+
ruleInstance.target === undefined ||
|
|
51
|
+
ruleInstance.comparisonType === undefined) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
switch (ruleInstance.comparisonType) {
|
|
55
|
+
case 'stringEquals':
|
|
56
|
+
return ruleInstance.subject.value === ruleInstance.target.value;
|
|
57
|
+
case 'stringContains':
|
|
58
|
+
return (_a = ruleInstance.subject.value) === null || _a === void 0 ? void 0 : _a.includes(ruleInstance.target.value);
|
|
59
|
+
case 'stringStartsWith':
|
|
60
|
+
return (_b = ruleInstance.subject.value) === null || _b === void 0 ? void 0 : _b.startsWith(ruleInstance.target.value);
|
|
61
|
+
case 'stringEndsWith':
|
|
62
|
+
return (_c = ruleInstance.subject.value) === null || _c === void 0 ? void 0 : _c.endsWith(ruleInstance.target.value);
|
|
63
|
+
case 'stringListContainsAny':
|
|
64
|
+
return (Array.isArray(ruleInstance.subject.value) &&
|
|
65
|
+
Array.isArray(ruleInstance.target.value) &&
|
|
66
|
+
ruleInstance.target.value.some((item) => ruleInstance.subject.value.includes(item)));
|
|
67
|
+
case 'stringListContainsAll':
|
|
68
|
+
return (Array.isArray(ruleInstance.subject.value) &&
|
|
69
|
+
Array.isArray(ruleInstance.target.value) &&
|
|
70
|
+
ruleInstance.target.value.every((item) => ruleInstance.subject.value.includes(item)));
|
|
71
|
+
case 'dateEquals':
|
|
72
|
+
case 'dateBefore':
|
|
73
|
+
case 'dateAfter':
|
|
74
|
+
return exports.CLXRulesEngine.compareDates(ruleInstance.comparisonType, ruleInstance.subject, ruleInstance.target);
|
|
75
|
+
case 'stringInList':
|
|
76
|
+
return (Array.isArray(ruleInstance.target.value) && ((_d = ruleInstance.target.value) === null || _d === void 0 ? void 0 : _d.includes(ruleInstance.subject.value)));
|
|
77
|
+
case 'stringListEntryContains':
|
|
78
|
+
return (Array.isArray(ruleInstance.subject.value) &&
|
|
79
|
+
((_e = ruleInstance.subject.value) === null || _e === void 0 ? void 0 : _e.some((item) => item.includes(ruleInstance.target.value))));
|
|
80
|
+
case 'stringListEntryStartsWith':
|
|
81
|
+
return (Array.isArray(ruleInstance.subject.value) &&
|
|
82
|
+
((_f = ruleInstance.subject.value) === null || _f === void 0 ? void 0 : _f.some((item) => item.startsWith(ruleInstance.target.value))));
|
|
83
|
+
case 'stringListEntryEndsWith':
|
|
84
|
+
return (Array.isArray(ruleInstance.subject.value) &&
|
|
85
|
+
ruleInstance.subject.value.some((item) => item.endsWith(ruleInstance.target.value)));
|
|
86
|
+
case 'stringListEntryEquals':
|
|
87
|
+
return (Array.isArray(ruleInstance.subject.value) && ruleInstance.subject.value.includes(ruleInstance.target.value));
|
|
88
|
+
case 'fileExists':
|
|
89
|
+
if (ruleInstance.target.value === true) {
|
|
90
|
+
return ruleInstance.subject.value !== undefined && Object.keys(ruleInstance.subject.value).length > 0;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return ruleInstance.subject.value === undefined || Object.keys(ruleInstance.subject.value).length === 0;
|
|
94
|
+
}
|
|
95
|
+
case 'booleanEquals':
|
|
96
|
+
return ruleInstance.subject.value === ruleInstance.target.value;
|
|
97
|
+
case 'numberEquals':
|
|
98
|
+
case 'numberGreaterThan':
|
|
99
|
+
case 'numberLessThan':
|
|
100
|
+
return exports.CLXRulesEngine.compareNumbers(ruleInstance.comparisonType, ruleInstance.subject.value, ruleInstance.target.value);
|
|
101
|
+
default:
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLXRulesetProcessor = void 0;
|
|
4
|
+
const rules_engine_1 = require("./rules-engine");
|
|
5
|
+
const CLXRulesetProcessor = ({ responseData }) => {
|
|
6
|
+
const processRuleSet = (ruleSet) => {
|
|
7
|
+
const evaluateRuleBase = (ruleBase) => {
|
|
8
|
+
if (ruleBase.comparison) {
|
|
9
|
+
const ruleDefinition = ruleBase;
|
|
10
|
+
const ruleInstance = {
|
|
11
|
+
subject: responseData[ruleDefinition.subject] || { value: undefined },
|
|
12
|
+
target: ruleDefinition.target,
|
|
13
|
+
comparisonType: ruleDefinition.comparison
|
|
14
|
+
};
|
|
15
|
+
return rules_engine_1.CLXRulesEngine.evaluateRuleInstance(ruleInstance);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const ruleSet = ruleBase;
|
|
19
|
+
return processRuleSet(ruleSet);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
if (!ruleSet || !ruleSet.rules || ruleSet.rules.length === 0) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (ruleSet.combinator === 'or') {
|
|
26
|
+
return ruleSet.rules.some((ruleBase) => {
|
|
27
|
+
return evaluateRuleBase(ruleBase);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return ruleSet.rules.every((ruleBase) => {
|
|
32
|
+
return evaluateRuleBase(ruleBase);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
processRuleSet
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
exports.CLXRulesetProcessor = CLXRulesetProcessor;
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clxmedia/clxforms-client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLXperience Forms Client",
|
|
5
|
+
"author": "Brandon Thompson <brandont@clxmedia.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"readmeFilename": "README.md",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/**/*",
|
|
12
|
+
"*.md"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./layout-processor": "./dist/layout-processor.js",
|
|
20
|
+
"./constants": "./dist/constants.js",
|
|
21
|
+
"./rules-engine": "./dist/rules-engine.js",
|
|
22
|
+
"./rules-processor": "./dist/rules-processor.js"
|
|
23
|
+
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"start:dev": "tsc -w",
|
|
27
|
+
"build": "rm -Rf dist && tsc",
|
|
28
|
+
"prepare": "npm run build",
|
|
29
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
30
|
+
"lint": "tslint -p tsconfig.json -c tslint.json",
|
|
31
|
+
"test": "jest",
|
|
32
|
+
"test:watch": "jest --watch",
|
|
33
|
+
"test:cov": "jest --coverage",
|
|
34
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/adsupnow/xperience-library/clxforms-client"
|
|
42
|
+
},
|
|
43
|
+
"bugs": "https://github.com/adsupnow/xperience-library/clxforms-client",
|
|
44
|
+
"peerDependencies": {},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@clxmedia/types": "1.0.47",
|
|
47
|
+
"luxon": "3.4.4"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"typescript": "^5.2.2",
|
|
51
|
+
"@types/node": "^20",
|
|
52
|
+
"@types/jsonwebtoken": "9.0.6",
|
|
53
|
+
"jest": "29.7.0",
|
|
54
|
+
"ts-jest": "29.1.2",
|
|
55
|
+
"nock": "13.5.4",
|
|
56
|
+
"tslint": "6.1.3"
|
|
57
|
+
},
|
|
58
|
+
"jest": {
|
|
59
|
+
"moduleFileExtensions": [
|
|
60
|
+
"js",
|
|
61
|
+
"json",
|
|
62
|
+
"ts"
|
|
63
|
+
],
|
|
64
|
+
"rootDir": "src",
|
|
65
|
+
"testRegex": ".spec.ts$",
|
|
66
|
+
"transform": {
|
|
67
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
68
|
+
},
|
|
69
|
+
"coverageDirectory": "../coverage",
|
|
70
|
+
"testEnvironment": "node"
|
|
71
|
+
}
|
|
72
|
+
}
|