@featurevisor/core 2.5.0 → 2.6.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/CHANGELOG.md +11 -0
- package/coverage/clover.xml +444 -78
- package/coverage/coverage-final.json +9 -3
- package/coverage/lcov-report/index.html +42 -42
- package/coverage/lcov-report/lib/builder/allocator.js.html +1 -1
- package/coverage/lcov-report/lib/builder/buildScopedConditions.js.html +373 -0
- package/coverage/lcov-report/lib/builder/buildScopedDatafile.js.html +403 -0
- package/coverage/lcov-report/lib/builder/buildScopedSegments.js.html +379 -0
- package/coverage/lcov-report/lib/builder/index.html +53 -8
- package/coverage/lcov-report/lib/builder/revision.js.html +1 -1
- package/coverage/lcov-report/lib/builder/traffic.js.html +1 -1
- package/coverage/lcov-report/lib/list/index.html +14 -14
- package/coverage/lcov-report/lib/list/matrix.js.html +23 -8
- package/coverage/lcov-report/lib/tester/helpers.js.html +1 -1
- package/coverage/lcov-report/lib/tester/index.html +1 -1
- package/coverage/lcov-report/src/builder/allocator.ts.html +1 -1
- package/coverage/lcov-report/src/builder/buildScopedConditions.ts.html +487 -0
- package/coverage/lcov-report/src/builder/buildScopedDatafile.ts.html +604 -0
- package/coverage/lcov-report/src/builder/buildScopedSegments.ts.html +544 -0
- package/coverage/lcov-report/src/builder/index.html +55 -10
- package/coverage/lcov-report/src/builder/revision.ts.html +1 -1
- package/coverage/lcov-report/src/builder/traffic.ts.html +3 -3
- package/coverage/lcov-report/src/list/index.html +14 -14
- package/coverage/lcov-report/src/list/matrix.ts.html +33 -12
- package/coverage/lcov-report/src/tester/helpers.ts.html +1 -1
- package/coverage/lcov-report/src/tester/index.html +1 -1
- package/coverage/lcov.info +810 -129
- package/jest.config.js +8 -0
- package/lib/builder/buildDatafile.d.ts +10 -0
- package/lib/builder/buildDatafile.js +27 -0
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildProject.d.ts +2 -0
- package/lib/builder/buildProject.js +38 -4
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/builder/buildScopedConditions.d.ts +5 -0
- package/lib/builder/buildScopedConditions.js +97 -0
- package/lib/builder/buildScopedConditions.js.map +1 -0
- package/lib/builder/buildScopedConditions.spec.d.ts +1 -0
- package/lib/builder/buildScopedConditions.spec.js +2167 -0
- package/lib/builder/buildScopedConditions.spec.js.map +1 -0
- package/lib/builder/buildScopedDatafile.d.ts +2 -0
- package/lib/builder/buildScopedDatafile.js +107 -0
- package/lib/builder/buildScopedDatafile.js.map +1 -0
- package/lib/builder/buildScopedDatafile.spec.d.ts +1 -0
- package/lib/builder/buildScopedDatafile.spec.js +1988 -0
- package/lib/builder/buildScopedDatafile.spec.js.map +1 -0
- package/lib/builder/buildScopedSegments.d.ts +5 -0
- package/lib/builder/buildScopedSegments.js +99 -0
- package/lib/builder/buildScopedSegments.js.map +1 -0
- package/lib/builder/buildScopedSegments.spec.d.ts +1 -0
- package/lib/builder/buildScopedSegments.spec.js +1062 -0
- package/lib/builder/buildScopedSegments.spec.js.map +1 -0
- package/lib/builder/index.d.ts +1 -0
- package/lib/builder/index.js +1 -0
- package/lib/builder/index.js.map +1 -1
- package/lib/config/projectConfig.d.ts +9 -1
- package/lib/config/projectConfig.js +1 -0
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/datasource/adapter.d.ts +3 -1
- package/lib/datasource/adapter.js.map +1 -1
- package/lib/datasource/filesystemAdapter.js +3 -1
- package/lib/datasource/filesystemAdapter.js.map +1 -1
- package/lib/linter/testSchema.d.ts +5 -0
- package/lib/linter/testSchema.js +8 -0
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/list/matrix.js +5 -0
- package/lib/list/matrix.js.map +1 -1
- package/lib/tester/testFeature.d.ts +5 -3
- package/lib/tester/testFeature.js +34 -9
- package/lib/tester/testFeature.js.map +1 -1
- package/lib/tester/testProject.d.ts +3 -2
- package/lib/tester/testProject.js +40 -6
- package/lib/tester/testProject.js.map +1 -1
- package/package.json +5 -5
- package/src/builder/buildDatafile.ts +47 -0
- package/src/builder/buildProject.ts +58 -3
- package/src/builder/buildScopedConditions.spec.ts +2659 -0
- package/src/builder/buildScopedConditions.ts +134 -0
- package/src/builder/buildScopedDatafile.spec.ts +2236 -0
- package/src/builder/buildScopedDatafile.ts +173 -0
- package/src/builder/buildScopedSegments.spec.ts +1573 -0
- package/src/builder/buildScopedSegments.ts +153 -0
- package/src/builder/index.ts +1 -0
- package/src/config/projectConfig.ts +11 -1
- package/src/datasource/adapter.ts +4 -1
- package/src/datasource/filesystemAdapter.ts +4 -1
- package/src/linter/testSchema.ts +12 -0
- package/src/list/matrix.ts +7 -0
- package/src/tester/testFeature.ts +50 -16
- package/src/tester/testProject.ts +68 -8
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Condition,
|
|
3
|
+
AndCondition,
|
|
4
|
+
OrCondition,
|
|
5
|
+
NotCondition,
|
|
6
|
+
Context,
|
|
7
|
+
} from "@featurevisor/types";
|
|
8
|
+
import type { DatafileReader } from "@featurevisor/sdk";
|
|
9
|
+
|
|
10
|
+
export function buildScopedConditions(
|
|
11
|
+
datafileReader: DatafileReader,
|
|
12
|
+
conditions: Condition | Condition[],
|
|
13
|
+
context: Context,
|
|
14
|
+
): Condition | Condition[] {
|
|
15
|
+
const scoped = buildScopedCondition(datafileReader, conditions, context);
|
|
16
|
+
const removed = removeRedundantConditions(scoped);
|
|
17
|
+
|
|
18
|
+
return removed;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function removeRedundantConditions(
|
|
22
|
+
conditions: Condition | Condition[],
|
|
23
|
+
): Condition | Condition[] {
|
|
24
|
+
if (conditions === "*") {
|
|
25
|
+
return conditions;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (Array.isArray(conditions)) {
|
|
29
|
+
// Recursively process each condition
|
|
30
|
+
const processed = conditions.map((c) => removeRedundantConditions(c)) as Condition[];
|
|
31
|
+
|
|
32
|
+
// Filter out "*" values
|
|
33
|
+
const filtered = processed.filter((c) => c !== "*");
|
|
34
|
+
|
|
35
|
+
// If all were "*", return "*"
|
|
36
|
+
if (filtered.length === 0) {
|
|
37
|
+
return "*";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return filtered;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (typeof conditions === "object") {
|
|
44
|
+
if ("and" in conditions) {
|
|
45
|
+
const processed = conditions.and.map((c) => removeRedundantConditions(c)) as Condition[];
|
|
46
|
+
const filtered = processed.filter((c) => c !== "*");
|
|
47
|
+
|
|
48
|
+
// If all were "*", return "*"
|
|
49
|
+
if (filtered.length === 0) {
|
|
50
|
+
return "*";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
and: filtered,
|
|
55
|
+
} as AndCondition;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if ("or" in conditions) {
|
|
59
|
+
const processed = conditions.or.map((c) => removeRedundantConditions(c)) as Condition[];
|
|
60
|
+
const filtered = processed.filter((c) => c !== "*");
|
|
61
|
+
|
|
62
|
+
// If all were "*", return "*"
|
|
63
|
+
if (filtered.length === 0) {
|
|
64
|
+
return "*";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
or: filtered,
|
|
69
|
+
} as OrCondition;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if ("not" in conditions) {
|
|
73
|
+
const processed = conditions.not.map((c) => removeRedundantConditions(c)) as Condition[];
|
|
74
|
+
const filtered = processed.filter((c) => c !== "*");
|
|
75
|
+
|
|
76
|
+
// If all were "*", return "*"
|
|
77
|
+
if (filtered.length === 0) {
|
|
78
|
+
return "*";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
not: filtered,
|
|
83
|
+
} as NotCondition;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return conditions;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function buildScopedCondition(
|
|
91
|
+
datafileReader: DatafileReader,
|
|
92
|
+
condition: Condition | Condition[],
|
|
93
|
+
context: Context,
|
|
94
|
+
): Condition | Condition[] {
|
|
95
|
+
if (condition === "*") {
|
|
96
|
+
return condition;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (Array.isArray(condition)) {
|
|
100
|
+
return condition.map((c) => buildScopedCondition(datafileReader, c, context)) as Condition[];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (typeof condition === "object") {
|
|
104
|
+
// plain condition
|
|
105
|
+
if ("attribute" in condition) {
|
|
106
|
+
const matched = datafileReader.allConditionsAreMatched(condition, context);
|
|
107
|
+
|
|
108
|
+
if (matched) {
|
|
109
|
+
return "*";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// AND, OR, NOT conditions
|
|
114
|
+
if ("and" in condition) {
|
|
115
|
+
return {
|
|
116
|
+
and: condition.and.map((c) => buildScopedCondition(datafileReader, c, context)),
|
|
117
|
+
} as AndCondition;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if ("or" in condition) {
|
|
121
|
+
return {
|
|
122
|
+
or: condition.or.map((c) => buildScopedCondition(datafileReader, c, context)),
|
|
123
|
+
} as OrCondition;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if ("not" in condition) {
|
|
127
|
+
return {
|
|
128
|
+
not: condition.not.map((c) => buildScopedCondition(datafileReader, c, context)),
|
|
129
|
+
} as NotCondition;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return condition;
|
|
134
|
+
}
|