@featurevisor/core 3.11.0 → 4.0.1
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 +9 -3
- package/lib/assess-distribution/index.js.map +1 -1
- package/lib/benchmark/index.d.ts +1 -1
- package/lib/benchmark/index.js +18 -11
- 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 +72 -17
- package/lib/cli/options.js.map +1 -1
- package/lib/cli/plugins.js +11 -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/details.js +31 -0
- package/lib/diff/details.js.map +1 -1
- package/lib/diff/index.d.ts +1 -1
- package/lib/diff/index.js +11 -4
- package/lib/diff/index.js.map +1 -1
- 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 +191 -74
- package/lib/linter/featureSchema.js +415 -214
- 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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const removedConditionFields: {
|
|
3
|
+
segments: z.ZodOptional<z.ZodUnknown>;
|
|
4
|
+
requiredFeatures: z.ZodOptional<z.ZodUnknown>;
|
|
5
|
+
requiredVariables: z.ZodOptional<z.ZodUnknown>;
|
|
6
|
+
};
|
|
7
|
+
export declare function refineRequiredConditions(value: {
|
|
8
|
+
conditions?: unknown;
|
|
9
|
+
}, ctx: z.RefinementCtx): void;
|
|
10
|
+
export declare function refineRemovedConditionFields(value: object, ctx: z.RefinementCtx): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removedConditionFields = void 0;
|
|
4
|
+
exports.refineRequiredConditions = refineRequiredConditions;
|
|
5
|
+
exports.refineRemovedConditionFields = refineRemovedConditionFields;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
exports.removedConditionFields = {
|
|
8
|
+
segments: zod_1.z.unknown().optional(),
|
|
9
|
+
requiredFeatures: zod_1.z.unknown().optional(),
|
|
10
|
+
requiredVariables: zod_1.z.unknown().optional(),
|
|
11
|
+
};
|
|
12
|
+
function refineRequiredConditions(value, ctx) {
|
|
13
|
+
refineRemovedConditionFields(value, ctx);
|
|
14
|
+
if (value.conditions === undefined &&
|
|
15
|
+
!Object.keys(exports.removedConditionFields).some((key) => Object.prototype.hasOwnProperty.call(value, key))) {
|
|
16
|
+
ctx.addIssue({
|
|
17
|
+
code: "custom",
|
|
18
|
+
path: ["conditions"],
|
|
19
|
+
message: "A selector must define `conditions`. Use `conditions: '*'` to match everything.",
|
|
20
|
+
params: { code: "missing_conditions" },
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function refineRemovedConditionFields(value, ctx) {
|
|
25
|
+
const messages = {
|
|
26
|
+
segments: "Replace `segments` with `conditions`. Segment keys stay as strings.",
|
|
27
|
+
requiredFeatures: "Move into `conditions`. Write each feature key as { feature: <key> }. Object entries keep their shape.",
|
|
28
|
+
requiredVariables: "Move into `conditions`. Each entry keeps its shape.",
|
|
29
|
+
};
|
|
30
|
+
const fields = Object.keys(messages).filter((key) => Object.prototype.hasOwnProperty.call(value, key));
|
|
31
|
+
for (const field of fields)
|
|
32
|
+
ctx.addIssue({
|
|
33
|
+
code: "custom",
|
|
34
|
+
path: [field],
|
|
35
|
+
message: messages[field],
|
|
36
|
+
params: { code: "removed_condition_field" },
|
|
37
|
+
});
|
|
38
|
+
if (fields.length + Number(Object.prototype.hasOwnProperty.call(value, "conditions")) > 1) {
|
|
39
|
+
ctx.addIssue({
|
|
40
|
+
code: "custom",
|
|
41
|
+
path: ["conditions"],
|
|
42
|
+
message: "Combine `segments`, `conditions`, `requiredFeatures` and `requiredVariables` into one `conditions` array. An array means AND.",
|
|
43
|
+
params: { code: "removed_condition_field" },
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=removedConditionFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removedConditionFields.js","sourceRoot":"","sources":["../../src/linter/removedConditionFields.ts"],"names":[],"mappings":";;;AAQA,4DAkBC;AAED,oEA0BC;AAtDD,6BAAwB;AAEX,QAAA,sBAAsB,GAAG;IACpC,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,gBAAgB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACxC,iBAAiB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAC1C,CAAC;AAEF,SAAgB,wBAAwB,CACtC,KAA+B,EAC/B,GAAoB;IAEpB,4BAA4B,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzC,IACE,KAAK,CAAC,UAAU,KAAK,SAAS;QAC9B,CAAC,MAAM,CAAC,IAAI,CAAC,8BAAsB,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAChD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CACjD,EACD,CAAC;QACD,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,YAAY,CAAC;YACpB,OAAO,EAAE,iFAAiF;YAC1F,MAAM,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE;SACvC,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAgB,4BAA4B,CAAC,KAAa,EAAE,GAAoB;IAC9E,MAAM,QAAQ,GAAG;QACf,QAAQ,EAAE,qEAAqE;QAC/E,gBAAgB,EACd,wGAAwG;QAC1G,iBAAiB,EAAE,qDAAqD;KACzE,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAClD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CACjD,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,MAAM;QACxB,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,KAAK,CAAC;YACb,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC;YACxB,MAAM,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE;SAC5C,CAAC,CAAC;IACL,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1F,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,YAAY,CAAC;YACpB,OAAO,EACL,+HAA+H;YACjI,MAAM,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ParsedFeature } from "@featurevisor/types";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function getFeatureConditionZodSchema(featuresByKey: Record<string, ParsedFeature>, availableFeatureKeys?: string[]): z.ZodObject<{
|
|
4
4
|
feature: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
5
5
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
6
6
|
variation: z.ZodOptional<z.ZodString>;
|
|
7
|
-
}, z.core.$strict
|
|
7
|
+
}, z.core.$strict>;
|
|
@@ -1,34 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getFeatureConditionZodSchema = getFeatureConditionZodSchema;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const zodHelpers_1 = require("./zodHelpers");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
6
|
+
const diagnostics_1 = require("./diagnostics");
|
|
7
|
+
function getFeatureConditionZodSchema(featuresByKey, availableFeatureKeys = Object.keys(featuresByKey)) {
|
|
8
|
+
// References to archived features are checked separately, see definitionReferences.
|
|
9
|
+
const featureKeySchema = (0, zodHelpers_1.refineWithMessage)(zod_1.z.string().min(1), (key) => availableFeatureKeys.indexOf(key) !== -1, (key) => `Unknown feature "${key}".${(0, diagnostics_1.suggestKey)(key, availableFeatureKeys)}`, () => zodHelpers_1.UNKNOWN_REFERENCE);
|
|
10
|
+
const objectSchema = zod_1.z
|
|
11
|
+
.object({
|
|
12
|
+
feature: featureKeySchema,
|
|
13
|
+
enabled: zod_1.z.boolean().optional(),
|
|
14
|
+
variation: zod_1.z.string().min(1).optional(),
|
|
15
|
+
})
|
|
16
|
+
.strict()
|
|
17
|
+
.superRefine((required, ctx) => {
|
|
18
|
+
if (typeof required.variation === "undefined")
|
|
19
|
+
return;
|
|
20
|
+
// An unknown feature is reported once, by the key itself.
|
|
21
|
+
if (!Object.prototype.hasOwnProperty.call(featuresByKey, required.feature))
|
|
22
|
+
return;
|
|
23
|
+
const feature = featuresByKey[required.feature];
|
|
24
|
+
const values = [
|
|
25
|
+
...(feature?.variations || []).map((item) => item.value),
|
|
26
|
+
...(feature?.disabledVariationValue !== undefined ? [feature.disabledVariationValue] : []),
|
|
27
|
+
];
|
|
28
|
+
if (values.indexOf(required.variation) === -1) {
|
|
29
|
+
ctx.addIssue({
|
|
30
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
31
|
+
message: `Unknown variation "${required.variation}" for feature "${required.feature}"`,
|
|
32
|
+
path: ["variation"],
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return objectSchema;
|
|
33
37
|
}
|
|
34
38
|
//# sourceMappingURL=requiredFeaturesSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requiredFeaturesSchema.js","sourceRoot":"","sources":["../../src/linter/requiredFeaturesSchema.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"requiredFeaturesSchema.js","sourceRoot":"","sources":["../../src/linter/requiredFeaturesSchema.ts"],"names":[],"mappings":";;AAMA,oEAqCC;AA1CD,6BAAwB;AAExB,6CAAoE;AACpE,+CAA2C;AAE3C,SAAgB,4BAA4B,CAC1C,aAA4C,EAC5C,uBAAiC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;IAE3D,oFAAoF;IACpF,MAAM,gBAAgB,GAAG,IAAA,8BAAiB,EACxC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EACjB,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EACjD,CAAC,GAAG,EA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,CAAC,OAAO,GAAG;gBACtF,IAAI,EAAE,CAAC,WAAW,CAAC;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IACL,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.estimateDependencyExpansion = estimateDependencyExpansion;
|
|
4
|
+
/** Count distinct immediate dependency edges reachable in one memoized request. */
|
|
5
|
+
function estimateDependencyExpansion(graph, threshold = 1000) {
|
|
6
|
+
const neighbours = new Map();
|
|
7
|
+
for (const [node, children] of graph) {
|
|
8
|
+
if (!neighbours.has(node))
|
|
9
|
+
neighbours.set(node, new Set());
|
|
10
|
+
for (const child of children) {
|
|
11
|
+
if (!neighbours.has(child))
|
|
12
|
+
neighbours.set(child, new Set());
|
|
13
|
+
neighbours.get(node).add(child);
|
|
14
|
+
neighbours.get(child).add(node);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const seen = new Set();
|
|
18
|
+
const warnings = [];
|
|
19
|
+
for (const start of neighbours.keys()) {
|
|
20
|
+
if (seen.has(start))
|
|
21
|
+
continue;
|
|
22
|
+
const cluster = [];
|
|
23
|
+
const pending = [start];
|
|
24
|
+
seen.add(start);
|
|
25
|
+
while (pending.length > 0) {
|
|
26
|
+
const node = pending.pop();
|
|
27
|
+
cluster.push(node);
|
|
28
|
+
for (const neighbour of neighbours.get(node) || []) {
|
|
29
|
+
if (seen.has(neighbour))
|
|
30
|
+
continue;
|
|
31
|
+
seen.add(neighbour);
|
|
32
|
+
pending.push(neighbour);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// A cluster with at most threshold edges cannot exceed this static estimate.
|
|
36
|
+
const edgeCount = cluster.reduce((count, node) => count + (graph.get(node)?.size || 0), 0);
|
|
37
|
+
if (edgeCount <= threshold)
|
|
38
|
+
continue;
|
|
39
|
+
for (const root of cluster) {
|
|
40
|
+
const visited = new Set([root]);
|
|
41
|
+
const reachable = [root];
|
|
42
|
+
let cost = 0;
|
|
43
|
+
while (reachable.length > 0 && cost <= threshold) {
|
|
44
|
+
for (const child of graph.get(reachable.pop()) || []) {
|
|
45
|
+
cost++;
|
|
46
|
+
if (!visited.has(child)) {
|
|
47
|
+
visited.add(child);
|
|
48
|
+
reachable.push(child);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (cost > threshold) {
|
|
53
|
+
warnings.push({ root, cost: Math.min(cost, threshold + 1) });
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return warnings;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=requiredVariableCost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requiredVariableCost.js","sourceRoot":"","sources":["../../src/linter/requiredVariableCost.ts"],"names":[],"mappings":";;AACA,kEAuDC;AAxDD,mFAAmF;AACnF,SAAgB,2BAA2B,CACzC,KAA+B,EAC/B,SAAS,GAAG,IAAI;IAEhB,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;IAClD,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAC;QACrC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAC3D,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;YAC7D,UAAU,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACjC,UAAU,CAAC,GAAG,CA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AC;YAChC,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,CAAC;YACzB,IAAI,IAAI,GAAG,CAAC,CAAC;YACb,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,IAAI,SAAS,EAAE,CAAC;gBACjD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAG,CAAC,IAAI,EAAE,EAAE,CAAC;oBACtD,IAAI,EAAE,CAAC;oBACP,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;wBACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;wBACnB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC;YACD,IAAI,IAAI,GAAG,SAAS,EAAE,CAAC;gBACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC7D,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ParsedFeature, ParsedVariable, Schema } from "@featurevisor/types";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ProjectConfig } from "../config";
|
|
4
|
+
export declare function getVariableConditionZodSchema(featuresByKey: Record<string, ParsedFeature>, variablesByKey: Record<string, ParsedVariable>, schemasByKey?: Record<string, Schema>, projectConfig?: Pick<ProjectConfig, "disallowOperators">): z.ZodObject<{
|
|
5
|
+
feature: z.ZodOptional<z.ZodString>;
|
|
6
|
+
variable: z.ZodString;
|
|
7
|
+
path: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
8
|
+
operator: z.ZodEnum<{
|
|
9
|
+
[x: string]: string;
|
|
10
|
+
}>;
|
|
11
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
12
|
+
regexFlags: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strict>;
|