@featurevisor/core 3.1.0 → 3.3.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/lib/datasource/datasource.d.ts +1 -1
- package/lib/datasource/datasource.js +4 -14
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/requiredFeatures.d.ts +7 -0
- package/lib/datasource/requiredFeatures.js +38 -0
- package/lib/datasource/requiredFeatures.js.map +1 -0
- package/lib/linter/checkCircularDependency.d.ts +1 -1
- package/lib/linter/checkCircularDependency.js +3 -22
- package/lib/linter/checkCircularDependency.js.map +1 -1
- package/lib/linter/conditionSchema.js +27 -3
- package/lib/linter/conditionSchema.js.map +1 -1
- package/lib/linter/testSchema.d.ts +4 -0
- package/lib/linter/testSchema.js +46 -4
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/promoter/index.js +62 -1
- package/lib/promoter/index.js.map +1 -1
- package/lib/tester/testFeature.js +17 -16
- package/lib/tester/testFeature.js.map +1 -1
- package/package.json +10 -7
- package/CHANGELOG.md +0 -2246
- package/coverage/clover.xml +0 -5456
- package/coverage/coverage-final.json +0 -64
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -371
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/src/assess-distribution/index.html +0 -116
- package/coverage/lcov-report/src/assess-distribution/index.ts.html +0 -754
- package/coverage/lcov-report/src/benchmark/index.html +0 -116
- package/coverage/lcov-report/src/benchmark/index.ts.html +0 -793
- package/coverage/lcov-report/src/builder/allocator.ts.html +0 -220
- package/coverage/lcov-report/src/builder/applyContextToConditions.ts.html +0 -502
- package/coverage/lcov-report/src/builder/applyContextToDatafile.ts.html +0 -772
- package/coverage/lcov-report/src/builder/applyContextToSegments.ts.html +0 -580
- package/coverage/lcov-report/src/builder/buildDatafile.ts.html +0 -2053
- package/coverage/lcov-report/src/builder/buildProject.ts.html +0 -1117
- package/coverage/lcov-report/src/builder/buildRuntimeDatafiles.ts.html +0 -256
- package/coverage/lcov-report/src/builder/getFeatureRanges.ts.html +0 -268
- package/coverage/lcov-report/src/builder/hashes.ts.html +0 -412
- package/coverage/lcov-report/src/builder/index.html +0 -311
- package/coverage/lcov-report/src/builder/index.ts.html +0 -91
- package/coverage/lcov-report/src/builder/mutateVariables.ts.html +0 -421
- package/coverage/lcov-report/src/builder/mutator.ts.html +0 -796
- package/coverage/lcov-report/src/builder/revision.ts.html +0 -151
- package/coverage/lcov-report/src/builder/traffic.ts.html +0 -661
- package/coverage/lcov-report/src/cli/cli.ts.html +0 -400
- package/coverage/lcov-report/src/cli/index.html +0 -131
- package/coverage/lcov-report/src/cli/plugins.ts.html +0 -214
- package/coverage/lcov-report/src/config/index.html +0 -131
- package/coverage/lcov-report/src/config/index.ts.html +0 -88
- package/coverage/lcov-report/src/config/projectConfig.ts.html +0 -925
- package/coverage/lcov-report/src/datasource/adapter.ts.html +0 -253
- package/coverage/lcov-report/src/datasource/datasource.ts.html +0 -1000
- package/coverage/lcov-report/src/datasource/filesystemAdapter.ts.html +0 -1576
- package/coverage/lcov-report/src/datasource/index.html +0 -161
- package/coverage/lcov-report/src/datasource/index.ts.html +0 -94
- package/coverage/lcov-report/src/evaluate/index.html +0 -116
- package/coverage/lcov-report/src/evaluate/index.ts.html +0 -814
- package/coverage/lcov-report/src/find-duplicate-segments/findDuplicateSegments.ts.html +0 -313
- package/coverage/lcov-report/src/find-duplicate-segments/index.html +0 -131
- package/coverage/lcov-report/src/find-duplicate-segments/index.ts.html +0 -307
- package/coverage/lcov-report/src/find-usage/index.html +0 -116
- package/coverage/lcov-report/src/find-usage/index.ts.html +0 -1780
- package/coverage/lcov-report/src/generate-code/index.html +0 -131
- package/coverage/lcov-report/src/generate-code/index.ts.html +0 -403
- package/coverage/lcov-report/src/generate-code/typescript.ts.html +0 -1909
- package/coverage/lcov-report/src/index.html +0 -131
- package/coverage/lcov-report/src/info/index.html +0 -116
- package/coverage/lcov-report/src/info/index.ts.html +0 -472
- package/coverage/lcov-report/src/init/index.html +0 -116
- package/coverage/lcov-report/src/init/index.ts.html +0 -280
- package/coverage/lcov-report/src/linter/attributeSchema.ts.html +0 -1963
- package/coverage/lcov-report/src/linter/checkCircularDependency.ts.html +0 -220
- package/coverage/lcov-report/src/linter/checkPercentageExceedingSlot.ts.html +0 -268
- package/coverage/lcov-report/src/linter/conditionSchema.ts.html +0 -2224
- package/coverage/lcov-report/src/linter/featureSchema.ts.html +0 -5851
- package/coverage/lcov-report/src/linter/groupSchema.ts.html +0 -226
- package/coverage/lcov-report/src/linter/index.html +0 -326
- package/coverage/lcov-report/src/linter/index.ts.html +0 -88
- package/coverage/lcov-report/src/linter/lintProject.ts.html +0 -2704
- package/coverage/lcov-report/src/linter/mutationNotation.ts.html +0 -1411
- package/coverage/lcov-report/src/linter/printError.ts.html +0 -289
- package/coverage/lcov-report/src/linter/schema.ts.html +0 -1558
- package/coverage/lcov-report/src/linter/segmentSchema.ts.html +0 -139
- package/coverage/lcov-report/src/linter/targetSchema.ts.html +0 -223
- package/coverage/lcov-report/src/linter/testSchema.ts.html +0 -529
- package/coverage/lcov-report/src/linter/zodHelpers.ts.html +0 -133
- package/coverage/lcov-report/src/list/index.html +0 -131
- package/coverage/lcov-report/src/list/index.ts.html +0 -2065
- package/coverage/lcov-report/src/list/matrix.ts.html +0 -721
- package/coverage/lcov-report/src/promoter/index.html +0 -116
- package/coverage/lcov-report/src/promoter/index.ts.html +0 -3883
- package/coverage/lcov-report/src/sets.ts.html +0 -313
- package/coverage/lcov-report/src/targeting.ts.html +0 -403
- package/coverage/lcov-report/src/tester/cliFormat.ts.html +0 -133
- package/coverage/lcov-report/src/tester/helpers.ts.html +0 -313
- package/coverage/lcov-report/src/tester/index.html +0 -206
- package/coverage/lcov-report/src/tester/prettyDuration.ts.html +0 -187
- package/coverage/lcov-report/src/tester/printTestResult.ts.html +0 -337
- package/coverage/lcov-report/src/tester/testFeature.ts.html +0 -1186
- package/coverage/lcov-report/src/tester/testProject.ts.html +0 -1018
- package/coverage/lcov-report/src/tester/testSegment.ts.html +0 -316
- package/coverage/lcov-report/src/utils/extractKeys.ts.html +0 -493
- package/coverage/lcov-report/src/utils/git.ts.html +0 -559
- package/coverage/lcov-report/src/utils/index.html +0 -161
- package/coverage/lcov-report/src/utils/index.ts.html +0 -94
- package/coverage/lcov-report/src/utils/pretty.ts.html +0 -121
- package/coverage/lcov.info +0 -11615
- package/jest.config.js +0 -22
- package/json-schema/README.md +0 -5
- package/json-schema/attribute.json +0 -40
- package/json-schema/feature.json +0 -394
- package/json-schema/segment.json +0 -137
- package/src/assess-distribution/index.ts +0 -223
- package/src/benchmark/index.ts +0 -236
- package/src/builder/allocator.spec.ts +0 -105
- package/src/builder/allocator.ts +0 -45
- package/src/builder/applyContextToConditions.spec.ts +0 -2677
- package/src/builder/applyContextToConditions.ts +0 -139
- package/src/builder/applyContextToDatafile.spec.ts +0 -2626
- package/src/builder/applyContextToDatafile.ts +0 -229
- package/src/builder/applyContextToSegments.spec.ts +0 -1593
- package/src/builder/applyContextToSegments.ts +0 -165
- package/src/builder/buildDatafile.spec.ts +0 -445
- package/src/builder/buildDatafile.ts +0 -656
- package/src/builder/buildProject.ts +0 -344
- package/src/builder/buildRuntimeDatafiles.ts +0 -57
- package/src/builder/getFeatureRanges.ts +0 -61
- package/src/builder/hashes.ts +0 -109
- package/src/builder/index.ts +0 -2
- package/src/builder/mutateVariables.spec.ts +0 -1179
- package/src/builder/mutateVariables.ts +0 -112
- package/src/builder/mutator.spec.ts +0 -413
- package/src/builder/mutator.ts +0 -237
- package/src/builder/revision.spec.ts +0 -22
- package/src/builder/revision.ts +0 -22
- package/src/builder/traffic.spec.ts +0 -946
- package/src/builder/traffic.ts +0 -192
- package/src/cli/cli.ts +0 -105
- package/src/cli/index.ts +0 -2
- package/src/cli/plugins.ts +0 -43
- package/src/config/index.ts +0 -1
- package/src/config/projectConfig.spec.ts +0 -194
- package/src/config/projectConfig.ts +0 -280
- package/src/datasource/adapter.ts +0 -56
- package/src/datasource/datasource.ts +0 -305
- package/src/datasource/filesystemAdapter.spec.ts +0 -212
- package/src/datasource/filesystemAdapter.ts +0 -497
- package/src/datasource/index.ts +0 -3
- package/src/dependencies.ts +0 -13
- package/src/evaluate/index.ts +0 -243
- package/src/find-duplicate-segments/findDuplicateSegments.ts +0 -76
- package/src/find-duplicate-segments/index.ts +0 -74
- package/src/find-usage/index.ts +0 -565
- package/src/generate-code/index.ts +0 -106
- package/src/generate-code/typescript.spec.ts +0 -214
- package/src/generate-code/typescript.ts +0 -608
- package/src/index.ts +0 -20
- package/src/info/index.ts +0 -129
- package/src/init/index.ts +0 -65
- package/src/linter/attributeSchema.spec.ts +0 -342
- package/src/linter/attributeSchema.ts +0 -626
- package/src/linter/checkCircularDependency.ts +0 -45
- package/src/linter/checkPercentageExceedingSlot.ts +0 -61
- package/src/linter/conditionSchema.spec.ts +0 -510
- package/src/linter/conditionSchema.ts +0 -713
- package/src/linter/featureSchema.spec.ts +0 -1985
- package/src/linter/featureSchema.ts +0 -1922
- package/src/linter/groupSchema.ts +0 -47
- package/src/linter/index.ts +0 -1
- package/src/linter/lintProject.spec.ts +0 -336
- package/src/linter/lintProject.ts +0 -873
- package/src/linter/mutationNotation.spec.ts +0 -704
- package/src/linter/mutationNotation.ts +0 -442
- package/src/linter/printError.ts +0 -68
- package/src/linter/schema.spec.ts +0 -690
- package/src/linter/schema.ts +0 -491
- package/src/linter/segmentSchema.spec.ts +0 -358
- package/src/linter/segmentSchema.ts +0 -18
- package/src/linter/targetSchema.spec.ts +0 -159
- package/src/linter/targetSchema.ts +0 -46
- package/src/linter/testSchema.spec.ts +0 -258
- package/src/linter/testSchema.ts +0 -148
- package/src/linter/zodHelpers.ts +0 -16
- package/src/list/index.spec.ts +0 -135
- package/src/list/index.ts +0 -660
- package/src/list/matrix.spec.ts +0 -49
- package/src/list/matrix.ts +0 -212
- package/src/promoter/index.spec.ts +0 -617
- package/src/promoter/index.ts +0 -1266
- package/src/sets.ts +0 -76
- package/src/targeting.spec.ts +0 -74
- package/src/targeting.ts +0 -106
- package/src/tester/cliFormat.ts +0 -16
- package/src/tester/helpers.spec.ts +0 -149
- package/src/tester/helpers.ts +0 -76
- package/src/tester/index.ts +0 -2
- package/src/tester/prettyDuration.ts +0 -34
- package/src/tester/printTestResult.ts +0 -84
- package/src/tester/testFeature.ts +0 -367
- package/src/tester/testProject.spec.ts +0 -50
- package/src/tester/testProject.ts +0 -311
- package/src/tester/testSegment.ts +0 -77
- package/src/utils/extractKeys.ts +0 -136
- package/src/utils/git.ts +0 -158
- package/src/utils/index.ts +0 -3
- package/src/utils/pretty.ts +0 -12
- package/tsconfig.cjs.json +0 -13
- package/tsconfig.typecheck.json +0 -9
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Condition,
|
|
3
|
-
AndCondition,
|
|
4
|
-
OrCondition,
|
|
5
|
-
NotCondition,
|
|
6
|
-
Context,
|
|
7
|
-
} from "@featurevisor/types";
|
|
8
|
-
import { allConditionsAreMatched } from "@featurevisor/sdk";
|
|
9
|
-
import type { Featurevisor } from "@featurevisor/sdk";
|
|
10
|
-
|
|
11
|
-
export function applyContextToConditions(
|
|
12
|
-
featurevisor: Featurevisor,
|
|
13
|
-
conditions: Condition | Condition[],
|
|
14
|
-
context: Context,
|
|
15
|
-
): Condition | Condition[] {
|
|
16
|
-
const withContextApplied = applyContextToCondition(featurevisor, conditions, context);
|
|
17
|
-
const removed = removeRedundantConditions(withContextApplied);
|
|
18
|
-
|
|
19
|
-
return removed;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function removeRedundantConditions(
|
|
23
|
-
conditions: Condition | Condition[],
|
|
24
|
-
): Condition | Condition[] {
|
|
25
|
-
if (conditions === "*") {
|
|
26
|
-
return conditions;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (Array.isArray(conditions)) {
|
|
30
|
-
// Recursively process each condition
|
|
31
|
-
const processed = conditions.map((c) => removeRedundantConditions(c)) as Condition[];
|
|
32
|
-
|
|
33
|
-
// Filter out "*" values
|
|
34
|
-
const filtered = processed.filter((c) => c !== "*");
|
|
35
|
-
|
|
36
|
-
// If all were "*", return "*"
|
|
37
|
-
if (filtered.length === 0) {
|
|
38
|
-
return "*";
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return filtered;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (typeof conditions === "object") {
|
|
45
|
-
if ("and" in conditions) {
|
|
46
|
-
const processed = conditions.and.map((c) => removeRedundantConditions(c)) as Condition[];
|
|
47
|
-
const filtered = processed.filter((c) => c !== "*");
|
|
48
|
-
|
|
49
|
-
// If all were "*", return "*"
|
|
50
|
-
if (filtered.length === 0) {
|
|
51
|
-
return "*";
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
and: filtered,
|
|
56
|
-
} as AndCondition;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if ("or" in conditions) {
|
|
60
|
-
const processed = conditions.or.map((c) => removeRedundantConditions(c)) as Condition[];
|
|
61
|
-
const filtered = processed.filter((c) => c !== "*");
|
|
62
|
-
|
|
63
|
-
// If all were "*", return "*"
|
|
64
|
-
if (filtered.length === 0) {
|
|
65
|
-
return "*";
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
or: filtered,
|
|
70
|
-
} as OrCondition;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if ("not" in conditions) {
|
|
74
|
-
const processed = conditions.not.map((c) => removeRedundantConditions(c)) as Condition[];
|
|
75
|
-
const filtered = processed.filter((c) => c !== "*");
|
|
76
|
-
|
|
77
|
-
// `not` negates the implicit AND of its children. Matched children are true
|
|
78
|
-
// and can be removed: not(true && X) becomes not(X). If every child was
|
|
79
|
-
// true, keep not("*") so it remains an always-false expression.
|
|
80
|
-
if (filtered.length === 0) {
|
|
81
|
-
return {
|
|
82
|
-
not: ["*"],
|
|
83
|
-
} as NotCondition;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
not: filtered,
|
|
88
|
-
} as NotCondition;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return conditions;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function applyContextToCondition(
|
|
96
|
-
featurevisor: Featurevisor,
|
|
97
|
-
condition: Condition | Condition[],
|
|
98
|
-
context: Context,
|
|
99
|
-
): Condition | Condition[] {
|
|
100
|
-
if (condition === "*") {
|
|
101
|
-
return condition;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (Array.isArray(condition)) {
|
|
105
|
-
return condition.map((c) => applyContextToCondition(featurevisor, c, context)) as Condition[];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (typeof condition === "object") {
|
|
109
|
-
// plain condition
|
|
110
|
-
if ("attribute" in condition) {
|
|
111
|
-
const matched = allConditionsAreMatched(condition, context);
|
|
112
|
-
|
|
113
|
-
if (matched) {
|
|
114
|
-
return "*";
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// AND, OR, NOT conditions
|
|
119
|
-
if ("and" in condition) {
|
|
120
|
-
return {
|
|
121
|
-
and: condition.and.map((c) => applyContextToCondition(featurevisor, c, context)),
|
|
122
|
-
} as AndCondition;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if ("or" in condition) {
|
|
126
|
-
return {
|
|
127
|
-
or: condition.or.map((c) => applyContextToCondition(featurevisor, c, context)),
|
|
128
|
-
} as OrCondition;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if ("not" in condition) {
|
|
132
|
-
return {
|
|
133
|
-
not: condition.not.map((c) => applyContextToCondition(featurevisor, c, context)),
|
|
134
|
-
} as NotCondition;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return condition;
|
|
139
|
-
}
|