@featurevisor/core 3.10.0 → 4.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/README.md +20 -2
- package/lib/assess-distribution/index.js +6 -2
- package/lib/assess-distribution/index.js.map +1 -1
- package/lib/benchmark/index.d.ts +1 -1
- package/lib/benchmark/index.js +15 -10
- package/lib/benchmark/index.js.map +1 -1
- package/lib/builder/applyContextToConditions.d.ts +5 -4
- package/lib/builder/applyContextToConditions.js +84 -89
- package/lib/builder/applyContextToConditions.js.map +1 -1
- package/lib/builder/applyContextToDatafile.d.ts +2 -2
- package/lib/builder/applyContextToDatafile.js +45 -149
- package/lib/builder/applyContextToDatafile.js.map +1 -1
- package/lib/builder/applyContextToSegments.d.ts +6 -4
- package/lib/builder/applyContextToSegments.js +9 -98
- package/lib/builder/applyContextToSegments.js.map +1 -1
- package/lib/builder/buildDatafile.d.ts +15 -6
- package/lib/builder/buildDatafile.js +320 -220
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildProject.d.ts +2 -1
- package/lib/builder/buildProject.js +36 -37
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/builder/buildRuntimeDatafiles.js +2 -0
- package/lib/builder/buildRuntimeDatafiles.js.map +1 -1
- package/lib/builder/environments.d.ts +3 -0
- package/lib/builder/environments.js +26 -0
- package/lib/builder/environments.js.map +1 -0
- package/lib/builder/hashes.d.ts +5 -5
- package/lib/builder/hashes.js +82 -100
- package/lib/builder/hashes.js.map +1 -1
- package/lib/builder/inflate.d.ts +7 -0
- package/lib/builder/inflate.js +26 -0
- package/lib/builder/inflate.js.map +1 -0
- package/lib/builder/mutateVariables.d.ts +6 -2
- package/lib/builder/mutateVariables.js +26 -18
- package/lib/builder/mutateVariables.js.map +1 -1
- package/lib/builder/mutationEntries.d.ts +5 -0
- package/lib/builder/mutationEntries.js +23 -0
- package/lib/builder/mutationEntries.js.map +1 -0
- package/lib/builder/mutator.d.ts +4 -2
- package/lib/builder/mutator.js +20 -209
- package/lib/builder/mutator.js.map +1 -1
- package/lib/builder/traffic.d.ts +2 -4
- package/lib/builder/traffic.js +48 -19
- package/lib/builder/traffic.js.map +1 -1
- package/lib/builder/variableOverrideProgram.d.ts +9 -0
- package/lib/builder/variableOverrideProgram.js +147 -0
- package/lib/builder/variableOverrideProgram.js.map +1 -0
- package/lib/catalog.d.ts +23 -0
- package/lib/catalog.js +117 -0
- package/lib/catalog.js.map +1 -0
- package/lib/cli/cli.d.ts +2 -0
- package/lib/cli/cli.js +38 -13
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/options.js +78 -17
- package/lib/cli/options.js.map +1 -1
- package/lib/cli/plugins.js +13 -3
- package/lib/cli/plugins.js.map +1 -1
- package/lib/cli/suggestions.d.ts +4 -0
- package/lib/cli/suggestions.js +61 -0
- package/lib/cli/suggestions.js.map +1 -0
- package/lib/config/allowedConditions.d.ts +9 -0
- package/lib/config/allowedConditions.js +44 -0
- package/lib/config/allowedConditions.js.map +1 -0
- package/lib/config/index.d.ts +1 -0
- package/lib/config/index.js +1 -0
- package/lib/config/index.js.map +1 -1
- package/lib/config/projectConfig.d.ts +9 -3
- package/lib/config/projectConfig.js +68 -11
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/config/removedGroups.d.ts +5 -0
- package/lib/config/removedGroups.js +62 -0
- package/lib/config/removedGroups.js.map +1 -0
- package/lib/datasource/adapter.d.ts +10 -1
- package/lib/datasource/adapter.js.map +1 -1
- package/lib/datasource/attributeNamespaces.d.ts +14 -0
- package/lib/datasource/attributeNamespaces.js +70 -0
- package/lib/datasource/attributeNamespaces.js.map +1 -0
- package/lib/datasource/composition.d.ts +5 -0
- package/lib/datasource/composition.js +19 -0
- package/lib/datasource/composition.js.map +1 -0
- package/lib/datasource/conditions.d.ts +20 -0
- package/lib/datasource/conditions.js +113 -0
- package/lib/datasource/conditions.js.map +1 -0
- package/lib/datasource/datasource.d.ts +18 -12
- package/lib/datasource/datasource.js +137 -76
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/dependencies.d.ts +52 -0
- package/lib/datasource/dependencies.js +347 -0
- package/lib/datasource/dependencies.js.map +1 -0
- package/lib/datasource/filesystemAdapter.d.ts +31 -1
- package/lib/datasource/filesystemAdapter.js +581 -99
- package/lib/datasource/filesystemAdapter.js.map +1 -1
- package/lib/datasource/index.d.ts +3 -0
- package/lib/datasource/index.js +3 -0
- package/lib/datasource/index.js.map +1 -1
- package/lib/datasource/parseError.d.ts +5 -0
- package/lib/datasource/parseError.js +68 -0
- package/lib/datasource/parseError.js.map +1 -0
- package/lib/datasource/testSpecs.d.ts +4 -0
- package/lib/datasource/testSpecs.js +40 -0
- package/lib/datasource/testSpecs.js.map +1 -0
- package/lib/diff/compare.d.ts +9 -0
- package/lib/diff/compare.js +31 -0
- package/lib/diff/compare.js.map +1 -0
- package/lib/diff/details.d.ts +11 -0
- package/lib/diff/details.js +210 -0
- package/lib/diff/details.js.map +1 -0
- package/lib/diff/git.d.ts +28 -0
- package/lib/diff/git.js +195 -0
- package/lib/diff/git.js.map +1 -0
- package/lib/diff/index.d.ts +36 -0
- package/lib/diff/index.js +229 -0
- package/lib/diff/index.js.map +1 -0
- package/lib/error.d.ts +1 -0
- package/lib/error.js +6 -0
- package/lib/error.js.map +1 -1
- package/lib/evaluate/explain.d.ts +15 -2
- package/lib/evaluate/explain.js +273 -79
- package/lib/evaluate/explain.js.map +1 -1
- package/lib/evaluate/index.js +128 -17
- package/lib/evaluate/index.js.map +1 -1
- package/lib/evaluate/probeConditions.d.ts +30 -0
- package/lib/evaluate/probeConditions.js +165 -0
- package/lib/evaluate/probeConditions.js.map +1 -0
- package/lib/evaluate/validateExplanation.js +175 -16
- package/lib/evaluate/validateExplanation.js.map +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.js +20 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.js.map +1 -1
- package/lib/find-usage/index.d.ts +14 -1
- package/lib/find-usage/index.js +359 -155
- package/lib/find-usage/index.js.map +1 -1
- package/lib/generate-code/typescript.js +156 -60
- package/lib/generate-code/typescript.js.map +1 -1
- package/lib/info/index.js +11 -5
- package/lib/info/index.js.map +1 -1
- package/lib/init/index.js +234 -28
- package/lib/init/index.js.map +1 -1
- package/lib/linter/attributeSchema.d.ts +6 -11
- package/lib/linter/attributeSchema.js +59 -53
- package/lib/linter/attributeSchema.js.map +1 -1
- package/lib/linter/comparisonOperators.d.ts +18 -0
- package/lib/linter/comparisonOperators.js +82 -0
- package/lib/linter/comparisonOperators.js.map +1 -0
- package/lib/linter/composedOverrideSchema.d.ts +5 -0
- package/lib/linter/composedOverrideSchema.js +243 -0
- package/lib/linter/composedOverrideSchema.js.map +1 -0
- package/lib/linter/compositionWarnings.d.ts +8 -0
- package/lib/linter/compositionWarnings.js +212 -0
- package/lib/linter/compositionWarnings.js.map +1 -0
- package/lib/linter/conditionKinds.d.ts +12 -0
- package/lib/linter/conditionKinds.js +129 -0
- package/lib/linter/conditionKinds.js.map +1 -0
- package/lib/linter/conditionSchema.d.ts +8 -2
- package/lib/linter/conditionSchema.js +253 -52
- package/lib/linter/conditionSchema.js.map +1 -1
- package/lib/linter/contextWarnings.d.ts +13 -0
- package/lib/linter/contextWarnings.js +241 -0
- package/lib/linter/contextWarnings.js.map +1 -0
- package/lib/linter/definitionReferences.d.ts +39 -0
- package/lib/linter/definitionReferences.js +234 -0
- package/lib/linter/definitionReferences.js.map +1 -0
- package/lib/linter/dependencyDepth.d.ts +14 -0
- package/lib/linter/dependencyDepth.js +106 -0
- package/lib/linter/dependencyDepth.js.map +1 -0
- package/lib/linter/diagnostics.d.ts +129 -0
- package/lib/linter/diagnostics.js +84 -0
- package/lib/linter/diagnostics.js.map +1 -0
- package/lib/linter/featureSchema.d.ts +189 -72
- package/lib/linter/featureSchema.js +385 -210
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/linter/lintProject.d.ts +4 -1
- package/lib/linter/lintProject.js +449 -143
- package/lib/linter/lintProject.js.map +1 -1
- package/lib/linter/mutationNotation.d.ts +7 -1
- package/lib/linter/mutationNotation.js +40 -20
- package/lib/linter/mutationNotation.js.map +1 -1
- package/lib/linter/mutationOrder.d.ts +6 -0
- package/lib/linter/mutationOrder.js +105 -0
- package/lib/linter/mutationOrder.js.map +1 -0
- package/lib/linter/mutationResultPaths.d.ts +4 -0
- package/lib/linter/mutationResultPaths.js +131 -0
- package/lib/linter/mutationResultPaths.js.map +1 -0
- package/lib/linter/mutationSchema.d.ts +3 -0
- package/lib/linter/mutationSchema.js +32 -0
- package/lib/linter/mutationSchema.js.map +1 -0
- package/lib/linter/printError.d.ts +3 -0
- package/lib/linter/printError.js +38 -25
- package/lib/linter/printError.js.map +1 -1
- package/lib/linter/regexSafety.d.ts +19 -0
- package/lib/linter/regexSafety.js +307 -0
- package/lib/linter/regexSafety.js.map +1 -0
- package/lib/linter/removedConditionFields.d.ts +10 -0
- package/lib/linter/removedConditionFields.js +47 -0
- package/lib/linter/removedConditionFields.js.map +1 -0
- package/lib/linter/requiredFeaturesSchema.d.ts +2 -2
- package/lib/linter/requiredFeaturesSchema.js +32 -28
- package/lib/linter/requiredFeaturesSchema.js.map +1 -1
- package/lib/linter/requiredVariableCost.d.ts +5 -0
- package/lib/linter/requiredVariableCost.js +60 -0
- package/lib/linter/requiredVariableCost.js.map +1 -0
- package/lib/linter/requiredVariablesSchema.d.ts +13 -0
- package/lib/linter/requiredVariablesSchema.js +498 -0
- package/lib/linter/requiredVariablesSchema.js.map +1 -0
- package/lib/linter/reservedNames.d.ts +12 -0
- package/lib/linter/reservedNames.js +52 -0
- package/lib/linter/reservedNames.js.map +1 -0
- package/lib/linter/schema.d.ts +12 -15
- package/lib/linter/schema.js +108 -26
- package/lib/linter/schema.js.map +1 -1
- package/lib/linter/schemaFormats.d.ts +35 -0
- package/lib/linter/schemaFormats.js +66 -0
- package/lib/linter/schemaFormats.js.map +1 -0
- package/lib/linter/segmentSchema.d.ts +11 -1
- package/lib/linter/segmentSchema.js +12 -2
- package/lib/linter/segmentSchema.js.map +1 -1
- package/lib/linter/testSchema.d.ts +394 -2
- package/lib/linter/testSchema.js +565 -34
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/linter/variableSchema.d.ts +60 -43
- package/lib/linter/variableSchema.js +459 -60
- package/lib/linter/variableSchema.js.map +1 -1
- package/lib/linter/zodHelpers.d.ts +8 -1
- package/lib/linter/zodHelpers.js +9 -1
- package/lib/linter/zodHelpers.js.map +1 -1
- package/lib/list/index.js +384 -66
- package/lib/list/index.js.map +1 -1
- package/lib/list/matrix.d.ts +2 -2
- package/lib/list/matrix.js +60 -39
- package/lib/list/matrix.js.map +1 -1
- package/lib/list/scenarios.d.ts +8 -0
- package/lib/list/scenarios.js +84 -0
- package/lib/list/scenarios.js.map +1 -0
- package/lib/promoter/index.d.ts +1 -1
- package/lib/promoter/index.js +469 -210
- package/lib/promoter/index.js.map +1 -1
- package/lib/sets.js +14 -5
- package/lib/sets.js.map +1 -1
- package/lib/tester/checks.d.ts +12 -0
- package/lib/tester/checks.js +418 -0
- package/lib/tester/checks.js.map +1 -0
- package/lib/tester/coverage.d.ts +16 -0
- package/lib/tester/coverage.js +64 -0
- package/lib/tester/coverage.js.map +1 -0
- package/lib/tester/datafileKey.d.ts +4 -0
- package/lib/tester/datafileKey.js +18 -0
- package/lib/tester/datafileKey.js.map +1 -0
- package/lib/tester/diagnostics.d.ts +5 -0
- package/lib/tester/diagnostics.js +32 -0
- package/lib/tester/diagnostics.js.map +1 -0
- package/lib/tester/index.d.ts +2 -0
- package/lib/tester/printTestResult.d.ts +3 -2
- package/lib/tester/printTestResult.js +53 -8
- package/lib/tester/printTestResult.js.map +1 -1
- package/lib/tester/provenance.d.ts +21 -0
- package/lib/tester/provenance.js +98 -0
- package/lib/tester/provenance.js.map +1 -0
- package/lib/tester/report.d.ts +78 -0
- package/lib/tester/report.js +246 -0
- package/lib/tester/report.js.map +1 -0
- package/lib/tester/segments.d.ts +23 -0
- package/lib/tester/segments.js +103 -0
- package/lib/tester/segments.js.map +1 -0
- package/lib/tester/testFeature.d.ts +2 -0
- package/lib/tester/testFeature.js +17 -8
- package/lib/tester/testFeature.js.map +1 -1
- package/lib/tester/testProject.d.ts +15 -3
- package/lib/tester/testProject.js +198 -83
- package/lib/tester/testProject.js.map +1 -1
- package/lib/tester/testSegment.d.ts +2 -4
- package/lib/tester/testSegment.js +89 -7
- package/lib/tester/testSegment.js.map +1 -1
- package/lib/tester/testVariable.d.ts +2 -2
- package/lib/tester/testVariable.js +195 -24
- package/lib/tester/testVariable.js.map +1 -1
- package/lib/utils/conditionReferences.d.ts +5 -0
- package/lib/utils/conditionReferences.js +30 -0
- package/lib/utils/conditionReferences.js.map +1 -0
- package/lib/utils/extractKeys.d.ts +7 -3
- package/lib/utils/extractKeys.js +32 -113
- package/lib/utils/extractKeys.js.map +1 -1
- package/lib/utils/git.d.ts +7 -2
- package/lib/utils/git.js +87 -72
- package/lib/utils/git.js.map +1 -1
- package/package.json +11 -8
- package/lib/builder/getFeatureRanges.d.ts +0 -11
- package/lib/builder/getFeatureRanges.js +0 -70
- package/lib/builder/getFeatureRanges.js.map +0 -1
- package/lib/datasource/requiredFeatures.d.ts +0 -14
- package/lib/datasource/requiredFeatures.js +0 -75
- package/lib/datasource/requiredFeatures.js.map +0 -1
- package/lib/linter/checkCircularDependency.d.ts +0 -3
- package/lib/linter/checkCircularDependency.js +0 -8
- package/lib/linter/checkCircularDependency.js.map +0 -1
- package/lib/linter/checkPercentageExceedingSlot.d.ts +0 -3
- package/lib/linter/checkPercentageExceedingSlot.js +0 -45
- package/lib/linter/checkPercentageExceedingSlot.js.map +0 -1
- package/lib/linter/groupSchema.d.ts +0 -11
- package/lib/linter/groupSchema.js +0 -31
- package/lib/linter/groupSchema.js.map +0 -1
|
@@ -3,157 +3,53 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.applyContextToDatafile = applyContextToDatafile;
|
|
4
4
|
const sdk_1 = require("@featurevisor/sdk");
|
|
5
5
|
const applyContextToConditions_1 = require("./applyContextToConditions");
|
|
6
|
-
const
|
|
6
|
+
const conditions_1 = require("../datasource/conditions");
|
|
7
7
|
const hashes_1 = require("./hashes");
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function applyContextToDatafile(originalDatafileContent, context) {
|
|
24
|
-
const originalFeaturevisor = (0, sdk_1.createFeaturevisor)({
|
|
25
|
-
datafile: originalDatafileContent,
|
|
26
|
-
logLevel: "fatal",
|
|
27
|
-
});
|
|
28
|
-
const contextualDatafileContent = JSON.parse(JSON.stringify(originalDatafileContent));
|
|
29
|
-
const removeSegments = [];
|
|
30
|
-
// segments
|
|
31
|
-
for (const segmentKey in contextualDatafileContent.segments) {
|
|
32
|
-
const segment = contextualDatafileContent.segments[segmentKey];
|
|
33
|
-
const originalConditions = parseIfStringified(segment.conditions);
|
|
34
|
-
const contextualConditions = (0, applyContextToConditions_1.applyContextToConditions)(originalFeaturevisor, originalConditions, context);
|
|
35
|
-
contextualDatafileContent.segments[segmentKey].conditions = contextualConditions;
|
|
36
|
-
if (contextualConditions === "*") {
|
|
37
|
-
removeSegments.push(segmentKey);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// features
|
|
41
|
-
for (const featureKey in contextualDatafileContent.features) {
|
|
42
|
-
const feature = contextualDatafileContent.features[featureKey];
|
|
43
|
-
// force
|
|
44
|
-
if (feature.force) {
|
|
45
|
-
for (let forceI = 0; forceI < feature.force.length; forceI++) {
|
|
46
|
-
const force = feature.force[forceI];
|
|
47
|
-
// segments
|
|
48
|
-
if (force.segments) {
|
|
49
|
-
const segments = parseIfStringified(force.segments);
|
|
50
|
-
feature.force[forceI].segments = (0, applyContextToSegments_1.applyContextToSegments)(originalFeaturevisor, segments, context, removeSegments);
|
|
51
|
-
}
|
|
52
|
-
// conditions
|
|
53
|
-
if (force.conditions) {
|
|
54
|
-
const conditions = parseIfStringified(force.conditions);
|
|
55
|
-
feature.force[forceI].conditions = (0, applyContextToConditions_1.applyContextToConditions)(originalFeaturevisor, conditions, context);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
8
|
+
function applyContextToDatafile(original, context) {
|
|
9
|
+
const featurevisor = (0, sdk_1.createFeaturevisor)({ datafile: original, logLevel: "fatal" });
|
|
10
|
+
const result = JSON.parse(JSON.stringify(original));
|
|
11
|
+
const referenced = new Set();
|
|
12
|
+
const specialize = (holder) => {
|
|
13
|
+
for (const field of ["conditions", "segments"]) {
|
|
14
|
+
if (holder[field] === undefined)
|
|
15
|
+
continue;
|
|
16
|
+
holder[field] = (0, applyContextToConditions_1.applyContextToConditions)(featurevisor, holder[field], context);
|
|
17
|
+
(0, conditions_1.getConditionReferences)(holder[field]).segments.forEach((key) => referenced.add(key));
|
|
58
18
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const variableOverride = variableOverrides[variableOverrideI];
|
|
77
|
-
// segments
|
|
78
|
-
if (variableOverride.segments) {
|
|
79
|
-
const segments = parseIfStringified(variableOverride.segments);
|
|
80
|
-
variableOverride.segments = (0, applyContextToSegments_1.applyContextToSegments)(originalFeaturevisor, segments, context, removeSegments);
|
|
81
|
-
}
|
|
82
|
-
// conditions
|
|
83
|
-
if (variableOverride.conditions) {
|
|
84
|
-
const conditions = parseIfStringified(variableOverride.conditions);
|
|
85
|
-
variableOverride.conditions = (0, applyContextToConditions_1.applyContextToConditions)(originalFeaturevisor, conditions, context);
|
|
86
|
-
}
|
|
87
|
-
variableOverrides[variableOverrideI] = variableOverride;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
19
|
+
};
|
|
20
|
+
// Segment references can survive inside a dynamic segment. Keep the complete
|
|
21
|
+
// specialised graph, then remove true segments only when no expression uses them.
|
|
22
|
+
for (const segment of Object.values(result.segments))
|
|
23
|
+
specialize(segment);
|
|
24
|
+
const overrides = (entries) => {
|
|
25
|
+
for (const group of Object.values(entries || {}))
|
|
26
|
+
for (const override of group)
|
|
27
|
+
specialize(override);
|
|
28
|
+
};
|
|
29
|
+
for (const feature of Object.values(result.features)) {
|
|
30
|
+
specialize(feature);
|
|
31
|
+
for (const entry of feature.force || [])
|
|
32
|
+
specialize(entry);
|
|
33
|
+
for (const entry of feature.traffic || []) {
|
|
34
|
+
specialize(entry);
|
|
35
|
+
overrides(entry.variableOverrides);
|
|
92
36
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (variableOverride.conditions) {
|
|
111
|
-
const conditions = parseIfStringified(variableOverride.conditions);
|
|
112
|
-
variableOverride.conditions = (0, applyContextToConditions_1.applyContextToConditions)(originalFeaturevisor, conditions, context);
|
|
113
|
-
}
|
|
114
|
-
variableOverrides[variableOverrideI] = variableOverride;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
feature.variations[variationI] = variation;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
// feature traffic consecutive segments with `*` removal
|
|
122
|
-
if (feature.traffic) {
|
|
123
|
-
const newTrafficArray = [];
|
|
124
|
-
let lastAddedTraffic;
|
|
125
|
-
for (let i = 0; i < feature.traffic.length; i++) {
|
|
126
|
-
let shouldAdd = true;
|
|
127
|
-
const currentTraffic = feature.traffic[i];
|
|
128
|
-
if (lastAddedTraffic &&
|
|
129
|
-
lastAddedTraffic.segments === "*" &&
|
|
130
|
-
currentTraffic.segments === "*") {
|
|
131
|
-
shouldAdd = false;
|
|
132
|
-
}
|
|
133
|
-
if (shouldAdd) {
|
|
134
|
-
newTrafficArray.push(currentTraffic);
|
|
135
|
-
lastAddedTraffic = currentTraffic;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
feature.traffic = newTrafficArray;
|
|
139
|
-
}
|
|
140
|
-
contextualDatafileContent.features[featureKey] = feature;
|
|
141
|
-
}
|
|
142
|
-
// global variables
|
|
143
|
-
for (const variable of Object.values(contextualDatafileContent.variables || {})) {
|
|
144
|
-
for (const override of variable.overrides || []) {
|
|
145
|
-
if (override.segments) {
|
|
146
|
-
override.segments = (0, applyContextToSegments_1.applyContextToSegments)(originalFeaturevisor, parseIfStringified(override.segments), context, removeSegments);
|
|
147
|
-
}
|
|
148
|
-
if (override.conditions) {
|
|
149
|
-
override.conditions = (0, applyContextToConditions_1.applyContextToConditions)(originalFeaturevisor, parseIfStringified(override.conditions), context);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
// remove segments
|
|
154
|
-
for (const removeSegment of removeSegments) {
|
|
155
|
-
delete contextualDatafileContent.segments[removeSegment];
|
|
156
|
-
}
|
|
157
|
-
return (0, hashes_1.refreshDatafileHashes)(contextualDatafileContent);
|
|
37
|
+
for (const variation of feature.variations || [])
|
|
38
|
+
overrides(variation.variableOverrides);
|
|
39
|
+
// Only consecutive catch all selectors are redundant. Allocation stays intact.
|
|
40
|
+
feature.traffic = feature.traffic.filter((entry, index, entries) => index === 0 ||
|
|
41
|
+
!((entry.conditions ?? entry.segments) === "*" &&
|
|
42
|
+
(entries[index - 1].conditions ?? entries[index - 1].segments) === "*"));
|
|
43
|
+
}
|
|
44
|
+
for (const variable of Object.values(result.variables || {})) {
|
|
45
|
+
specialize(variable);
|
|
46
|
+
for (const override of variable.overrideProgram || variable.overrides || [])
|
|
47
|
+
specialize(override);
|
|
48
|
+
}
|
|
49
|
+
for (const [key, segment] of Object.entries(result.segments)) {
|
|
50
|
+
if (segment.conditions === "*" && !referenced.has(key))
|
|
51
|
+
delete result.segments[key];
|
|
52
|
+
}
|
|
53
|
+
return (0, hashes_1.refreshDatafileHashes)(result);
|
|
158
54
|
}
|
|
159
55
|
//# sourceMappingURL=applyContextToDatafile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyContextToDatafile.js","sourceRoot":"","sources":["../../src/builder/applyContextToDatafile.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"applyContextToDatafile.js","sourceRoot":"","sources":["../../src/builder/applyContextToDatafile.ts"],"names":[],"mappings":";;AAMA,wDAkDC;AAvDD,2CAAuD;AACvD,yEAAsE;AACtE,yDAAkE;AAClE,qCAAiD;AAEjD,SAAgB,sBAAsB,CACpC,QAAyB,EACzB,OAAgB;IAEhB,MAAM,YAAY,GAAG,IAAA,wBAAkB,EAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACnF,MAAM,MAAM,GAAoB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrE,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,MAAM,UAAU,GAAG,CAAC,MAA0D,EAAE,EAAE;QAChF,KAAK,MAAM,KAAK,IAAI,CAAC,YAAY,EAAE,UAAU,CAAU,EAAE,CAAC;YACxD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,SAAS;gBAAE,SAAS;YAC1C,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,mDAAwB,EAAC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAE,EAAE,OAAO,CAAC,CAAC;YAChF,IAAA,mCAAsB,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACvF,CAAC;IACH,CAAC,CAAC;IACF,6EAA6E;IAC7E,kFAAkF;IAClF,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC1E,MAAM,SAAS,GAAG,CAChB,OAAqF,EACrF,EAAE;QACF,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;YAC9C,KAAK,MAAM,QAAQ,IAAI,KAAK;gBAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvD,CAAC,CAAC;IACF,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,UAAU,CAAC,OAAO,CAAC,CAAC;QACpB,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,EAAE;YAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QAC3D,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YAC1C,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,SAAS,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,IAAI,EAAE;YAAE,SAAS,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QACzF,+EAA+E;QAC/E,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CACtC,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CACxB,KAAK,KAAK,CAAC;YACX,CAAC,CACC,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG;gBAC5C,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,GAAG,CACvE,CACJ,CAAC;IACJ,CAAC;IACD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAAC;QAC7D,UAAU,CAAC,QAAQ,CAAC,CAAC;QACrB,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,eAAe,IAAI,QAAQ,CAAC,SAAS,IAAI,EAAE;YACzE,UAAU,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7D,IAAI,OAAO,CAAC,UAAU,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,IAAA,8BAAqB,EAAC,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Conditions, Context } from "@featurevisor/types";
|
|
2
2
|
import type { Featurevisor } from "@featurevisor/sdk";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
3
|
+
import { removeRedundantConditions } from "./applyContextToConditions";
|
|
4
|
+
/** Transitional internal entry points now share the mixed condition specializer. */
|
|
5
|
+
export declare function applyContextToSegments(featurevisor: Featurevisor, conditions: Conditions, context: Context, _removeSegments?: string[]): Conditions;
|
|
6
|
+
export declare const removeRedundantGroupSegments: typeof removeRedundantConditions;
|
|
7
|
+
export declare const applyContextToGroupSegments: typeof applyContextToSegments;
|
|
@@ -1,103 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyContextToGroupSegments = exports.removeRedundantGroupSegments = void 0;
|
|
3
4
|
exports.applyContextToSegments = applyContextToSegments;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return removed;
|
|
11
|
-
}
|
|
12
|
-
function removeRedundantGroupSegments(groupSegments) {
|
|
13
|
-
if (groupSegments === "*") {
|
|
14
|
-
return groupSegments;
|
|
15
|
-
}
|
|
16
|
-
if (Array.isArray(groupSegments)) {
|
|
17
|
-
// Recursively process each group segment
|
|
18
|
-
const processed = groupSegments.map((gs) => removeRedundantGroupSegments(gs));
|
|
19
|
-
// Filter out "*" values
|
|
20
|
-
const filtered = processed.filter((gs) => gs !== "*");
|
|
21
|
-
// If all were "*", return "*"
|
|
22
|
-
if (filtered.length === 0) {
|
|
23
|
-
return "*";
|
|
24
|
-
}
|
|
25
|
-
return filtered;
|
|
26
|
-
}
|
|
27
|
-
if (typeof groupSegments === "object") {
|
|
28
|
-
if ("and" in groupSegments) {
|
|
29
|
-
const processed = groupSegments.and.map((gs) => removeRedundantGroupSegments(gs));
|
|
30
|
-
const filtered = processed.filter((gs) => gs !== "*");
|
|
31
|
-
// If all were "*", return "*"
|
|
32
|
-
if (filtered.length === 0) {
|
|
33
|
-
return "*";
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
and: filtered,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
if ("or" in groupSegments) {
|
|
40
|
-
const processed = groupSegments.or.map((gs) => removeRedundantGroupSegments(gs));
|
|
41
|
-
// `or` is true as soon as any child is true.
|
|
42
|
-
if (processed.indexOf("*") !== -1) {
|
|
43
|
-
return "*";
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
or: processed,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if ("not" in groupSegments) {
|
|
50
|
-
const processed = groupSegments.not.map((gs) => removeRedundantGroupSegments(gs));
|
|
51
|
-
const filtered = processed.filter((gs) => gs !== "*");
|
|
52
|
-
// `not` negates the implicit AND of its children. Matched children are true
|
|
53
|
-
// and can be removed: not(true && X) becomes not(X). If every child was
|
|
54
|
-
// true, keep not("*") so it remains an always-false expression.
|
|
55
|
-
if (filtered.length === 0) {
|
|
56
|
-
return {
|
|
57
|
-
not: ["*"],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
not: filtered,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return groupSegments;
|
|
66
|
-
}
|
|
67
|
-
function applyContextToGroupSegments(featurevisor, groupSegments, context, removeSegments = []) {
|
|
68
|
-
if (groupSegments === "*") {
|
|
69
|
-
return groupSegments;
|
|
70
|
-
}
|
|
71
|
-
if (Array.isArray(groupSegments)) {
|
|
72
|
-
return groupSegments.map((gs) => applyContextToGroupSegments(featurevisor, gs, context, removeSegments));
|
|
73
|
-
}
|
|
74
|
-
if (typeof groupSegments === "string") {
|
|
75
|
-
if (removeSegments.includes(groupSegments)) {
|
|
76
|
-
return "*";
|
|
77
|
-
}
|
|
78
|
-
const matched = (0, sdk_1.allSegmentsAreMatched)(groupSegments, context, (segmentKey) => featurevisor.getSegment(segmentKey));
|
|
79
|
-
if (matched) {
|
|
80
|
-
return "*";
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (typeof groupSegments === "object") {
|
|
84
|
-
// AND, OR, NOT group segments
|
|
85
|
-
if ("and" in groupSegments) {
|
|
86
|
-
return {
|
|
87
|
-
and: groupSegments.and.map((gs) => applyContextToGroupSegments(featurevisor, gs, context, removeSegments)),
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
if ("or" in groupSegments) {
|
|
91
|
-
return {
|
|
92
|
-
or: groupSegments.or.map((gs) => applyContextToGroupSegments(featurevisor, gs, context, removeSegments)),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
if ("not" in groupSegments) {
|
|
96
|
-
return {
|
|
97
|
-
not: groupSegments.not.map((gs) => applyContextToGroupSegments(featurevisor, gs, context, removeSegments)),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return groupSegments;
|
|
5
|
+
const applyContextToConditions_1 = require("./applyContextToConditions");
|
|
6
|
+
/** Transitional internal entry points now share the mixed condition specializer. */
|
|
7
|
+
function applyContextToSegments(featurevisor, conditions, context, _removeSegments = []) {
|
|
8
|
+
// Old hints cannot override dependency expressions discovered at build time.
|
|
9
|
+
void _removeSegments;
|
|
10
|
+
return (0, applyContextToConditions_1.applyContextToConditions)(featurevisor, conditions, context);
|
|
102
11
|
}
|
|
12
|
+
exports.removeRedundantGroupSegments = applyContextToConditions_1.removeRedundantConditions;
|
|
13
|
+
exports.applyContextToGroupSegments = applyContextToSegments;
|
|
103
14
|
//# sourceMappingURL=applyContextToSegments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyContextToSegments.js","sourceRoot":"","sources":["../../src/builder/applyContextToSegments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"applyContextToSegments.js","sourceRoot":"","sources":["../../src/builder/applyContextToSegments.ts"],"names":[],"mappings":";;;AAKA,wDASC;AAZD,yEAAiG;AAEjG,oFAAoF;AACpF,SAAgB,sBAAsB,CACpC,YAA0B,EAC1B,UAAsB,EACtB,OAAgB,EAChB,kBAA4B,EAAE;IAE9B,6EAA6E;IAC7E,KAAK,eAAe,CAAC;IACrB,OAAO,IAAA,mDAAwB,EAAC,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AACY,QAAA,4BAA4B,GAAG,oDAAyB,CAAC;AACzD,QAAA,2BAA2B,GAAG,sBAAsB,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OrdinaryParsedVariable, ParsedVariableOverride, VariableKey, VariableValue } from "@featurevisor/types";
|
|
2
2
|
import { DatafileContent, ExistingState, FeatureKey } from "@featurevisor/types";
|
|
3
3
|
import { ProjectConfig } from "../config";
|
|
4
4
|
import { Datasource } from "../datasource";
|
|
5
|
+
/** Apply one authored global override's value or mutations to a base value. */
|
|
6
|
+
export declare function resolveVariableOverrideValue(variable: OrdinaryParsedVariable, override: ParsedVariableOverride, baseValue: VariableValue): VariableValue;
|
|
5
7
|
export interface CustomDatafileOptions {
|
|
6
8
|
featureKey?: string;
|
|
7
9
|
variableKey?: string;
|
|
@@ -14,8 +16,8 @@ export interface CustomDatafileOptions {
|
|
|
14
16
|
tags?: BuildTags;
|
|
15
17
|
includeFeatures?: "*" | FeatureKey[];
|
|
16
18
|
excludeFeatures?: "*" | FeatureKey[];
|
|
17
|
-
includeVariables?: "*" |
|
|
18
|
-
excludeVariables?: "*" |
|
|
19
|
+
includeVariables?: "*" | VariableKey[];
|
|
20
|
+
excludeVariables?: "*" | VariableKey[];
|
|
19
21
|
featurevisorVersion?: string;
|
|
20
22
|
revisionFromHash?: boolean;
|
|
21
23
|
}
|
|
@@ -28,6 +30,8 @@ export interface BuildAndTags {
|
|
|
28
30
|
}
|
|
29
31
|
export type BuildTags = BuildOrTags | BuildAndTags | string[];
|
|
30
32
|
export interface BuildOptions {
|
|
33
|
+
/** Names the trial completeness diagnostic without changing datafile contents. */
|
|
34
|
+
compositionTargetKey?: string;
|
|
31
35
|
revision: string;
|
|
32
36
|
featurevisorVersion?: string;
|
|
33
37
|
revisionFromHash?: boolean;
|
|
@@ -36,10 +40,15 @@ export interface BuildOptions {
|
|
|
36
40
|
tags?: BuildTags;
|
|
37
41
|
includeFeatures?: "*" | FeatureKey[];
|
|
38
42
|
excludeFeatures?: "*" | FeatureKey[];
|
|
39
|
-
includeVariables?: "*" |
|
|
40
|
-
excludeVariables?: "*" |
|
|
43
|
+
includeVariables?: "*" | VariableKey[];
|
|
44
|
+
excludeVariables?: "*" | VariableKey[];
|
|
41
45
|
features?: FeatureKey[];
|
|
42
|
-
variables?:
|
|
46
|
+
variables?: VariableKey[];
|
|
43
47
|
inflate?: number;
|
|
48
|
+
/**
|
|
49
|
+
* The dependency graph, when a caller builds several datafiles from the same
|
|
50
|
+
* definitions. It depends only on those definitions, never on the Target or environment.
|
|
51
|
+
*/
|
|
52
|
+
dependencyGraph?: Map<string, Set<string>>;
|
|
44
53
|
}
|
|
45
54
|
export declare function buildDatafile(projectConfig: ProjectConfig, datasource: Datasource, options: BuildOptions, existingState: ExistingState): Promise<DatafileContent>;
|