@featurevisor/core 2.12.0 → 2.14.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 +22 -0
- package/coverage/clover.xml +1663 -596
- package/coverage/coverage-final.json +24 -6
- package/coverage/lcov-report/builder/allocator.ts.html +1 -1
- package/coverage/lcov-report/builder/buildScopedConditions.ts.html +1 -1
- package/coverage/lcov-report/builder/buildScopedDatafile.ts.html +1 -1
- package/coverage/lcov-report/builder/buildScopedSegments.ts.html +1 -1
- package/coverage/lcov-report/builder/index.html +38 -8
- package/coverage/lcov-report/builder/mutateVariables.ts.html +400 -0
- package/coverage/lcov-report/builder/mutator.ts.html +796 -0
- package/coverage/lcov-report/builder/revision.ts.html +1 -1
- package/coverage/lcov-report/builder/traffic.ts.html +1 -1
- package/coverage/lcov-report/config/index.html +116 -0
- package/coverage/lcov-report/config/projectConfig.ts.html +676 -0
- package/coverage/lcov-report/datasource/adapter.ts.html +235 -0
- package/coverage/lcov-report/datasource/datasource.ts.html +862 -0
- package/coverage/lcov-report/datasource/filesystemAdapter.ts.html +1354 -0
- package/coverage/lcov-report/datasource/index.html +161 -0
- package/coverage/lcov-report/datasource/index.ts.html +94 -0
- package/coverage/lcov-report/index.html +83 -38
- package/coverage/lcov-report/linter/attributeSchema.ts.html +175 -0
- package/coverage/lcov-report/linter/checkCircularDependency.ts.html +220 -0
- package/coverage/lcov-report/linter/checkPercentageExceedingSlot.ts.html +268 -0
- package/coverage/lcov-report/linter/conditionSchema.ts.html +38 -38
- package/coverage/lcov-report/linter/featureSchema.ts.html +956 -485
- package/coverage/lcov-report/linter/groupSchema.ts.html +226 -0
- package/coverage/lcov-report/linter/index.html +139 -19
- package/coverage/lcov-report/linter/lintProject.ts.html +1840 -0
- package/coverage/lcov-report/linter/mutationNotation.ts.html +1309 -0
- package/coverage/lcov-report/linter/printError.ts.html +238 -0
- package/coverage/lcov-report/linter/schema.ts.html +116 -116
- package/coverage/lcov-report/linter/segmentSchema.ts.html +5 -5
- package/coverage/lcov-report/linter/testSchema.ts.html +550 -0
- package/coverage/lcov-report/list/index.html +1 -1
- package/coverage/lcov-report/list/matrix.ts.html +1 -1
- package/coverage/lcov-report/parsers/index.html +20 -5
- package/coverage/lcov-report/parsers/index.ts.html +151 -0
- package/coverage/lcov-report/parsers/json.ts.html +2 -2
- package/coverage/lcov-report/parsers/yml.ts.html +6 -6
- package/coverage/lcov-report/tester/cliFormat.ts.html +103 -0
- package/coverage/lcov-report/tester/helpers.ts.html +1 -1
- package/coverage/lcov-report/tester/index.html +20 -5
- package/coverage/lcov-report/utils/git.ts.html +481 -0
- package/coverage/lcov-report/utils/index.html +116 -0
- package/coverage/lcov.info +3253 -1214
- package/lib/builder/buildDatafile.js +8 -3
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/mutateVariables.d.ts +14 -0
- package/lib/builder/mutateVariables.js +90 -0
- package/lib/builder/mutateVariables.js.map +1 -0
- package/lib/builder/mutateVariables.spec.d.ts +1 -0
- package/lib/builder/mutateVariables.spec.js +1045 -0
- package/lib/builder/mutateVariables.spec.js.map +1 -0
- package/lib/builder/mutator.d.ts +20 -0
- package/lib/builder/mutator.js +223 -0
- package/lib/builder/mutator.js.map +1 -0
- package/lib/builder/mutator.spec.d.ts +1 -0
- package/lib/builder/mutator.spec.js +368 -0
- package/lib/builder/mutator.spec.js.map +1 -0
- package/lib/linter/featureSchema.d.ts +7 -7
- package/lib/linter/featureSchema.js +138 -62
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/linter/featureSchema.spec.js +150 -0
- package/lib/linter/featureSchema.spec.js.map +1 -1
- package/lib/linter/lintProject.d.ts +17 -1
- package/lib/linter/lintProject.js +191 -198
- package/lib/linter/lintProject.js.map +1 -1
- package/lib/linter/lintProject.spec.d.ts +1 -0
- package/lib/linter/lintProject.spec.js +86 -0
- package/lib/linter/lintProject.spec.js.map +1 -0
- package/lib/linter/mutationNotation.d.ts +47 -0
- package/lib/linter/mutationNotation.js +381 -0
- package/lib/linter/mutationNotation.js.map +1 -0
- package/lib/linter/mutationNotation.spec.d.ts +1 -0
- package/lib/linter/mutationNotation.spec.js +549 -0
- package/lib/linter/mutationNotation.spec.js.map +1 -0
- package/lib/linter/printError.d.ts +7 -0
- package/lib/linter/printError.js +30 -15
- package/lib/linter/printError.js.map +1 -1
- package/package.json +2 -2
- package/src/builder/buildDatafile.ts +29 -3
- package/src/builder/mutateVariables.spec.ts +1134 -0
- package/src/builder/mutateVariables.ts +105 -0
- package/src/builder/mutator.spec.ts +413 -0
- package/src/builder/mutator.ts +237 -0
- package/src/linter/featureSchema.spec.ts +182 -0
- package/src/linter/featureSchema.ts +254 -97
- package/src/linter/lintProject.spec.ts +115 -0
- package/src/linter/lintProject.ts +256 -254
- package/src/linter/mutationNotation.spec.ts +642 -0
- package/src/linter/mutationNotation.ts +408 -0
- package/src/linter/printError.ts +40 -16
package/lib/linter/printError.js
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLintIssuesFromZodError = getLintIssuesFromZodError;
|
|
3
4
|
exports.printZodError = printZodError;
|
|
4
5
|
const cliFormat_1 = require("../tester/cliFormat");
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (issue.code === "invalid_union" &&
|
|
9
|
-
|
|
6
|
+
function getLintIssuesFromZodError(e) {
|
|
7
|
+
return e.issues
|
|
8
|
+
.map((issue) => {
|
|
9
|
+
if (issue.code === "invalid_union" &&
|
|
10
|
+
issue.path.length === 0 &&
|
|
11
|
+
issue.unionErrors.length > 0) {
|
|
10
12
|
const lastUnionError = issue.unionErrors[issue.unionErrors.length - 1];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
const nestedIssue = lastUnionError.issues[0];
|
|
14
|
+
return {
|
|
15
|
+
message: nestedIssue.message,
|
|
16
|
+
path: nestedIssue.path,
|
|
17
|
+
code: nestedIssue.code,
|
|
18
|
+
value: nestedIssue.received,
|
|
19
|
+
};
|
|
13
20
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
return {
|
|
22
|
+
message: issue.message,
|
|
23
|
+
path: issue.path,
|
|
24
|
+
code: issue.code,
|
|
25
|
+
value: issue.received,
|
|
26
|
+
};
|
|
27
|
+
})
|
|
28
|
+
.filter(Boolean);
|
|
29
|
+
}
|
|
30
|
+
function printZodError(e) {
|
|
31
|
+
const issues = getLintIssuesFromZodError(e);
|
|
32
|
+
issues.forEach((issue) => {
|
|
33
|
+
console.error(cliFormat_1.CLI_FORMAT_RED, ` => Error: ${issue.message}`);
|
|
34
|
+
console.error(" Path:", issue.path.join("."));
|
|
35
|
+
if (typeof issue.value !== "undefined" && issue.value !== "undefined") {
|
|
36
|
+
console.error(" Value:", issue.value);
|
|
22
37
|
}
|
|
23
38
|
console.error("");
|
|
24
39
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printError.js","sourceRoot":"","sources":["../../src/linter/printError.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"printError.js","sourceRoot":"","sources":["../../src/linter/printError.ts"],"names":[],"mappings":";;AAWA,8DA2BC;AAED,sCAUC;AAhDD,mDAAqD;AASrD,SAAgB,yBAAyB,CAAC,CAAW;IACnD,OAAO,CAAC,CAAC,MAAM;SACZ,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,IACE,KAAK,CAAC,IAAI,KAAK,eAAe;YAC9B,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;YACvB,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAC5B,CAAC;YACD,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAA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": "Core package of Featurevisor for Node.js usage",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"yargs": "^17.7.2",
|
|
50
50
|
"zod": "^3.22.4"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "626b7b14c3811d495dad8ac89980210f1bcdf226"
|
|
53
53
|
}
|
|
@@ -30,6 +30,10 @@ import { generateHashForDatafile, generateHashForFeature, getSegmentHashes } fro
|
|
|
30
30
|
import { getTraffic } from "./traffic";
|
|
31
31
|
import { getFeatureRanges } from "./getFeatureRanges";
|
|
32
32
|
import { convertToV1 } from "./convertToV1";
|
|
33
|
+
import {
|
|
34
|
+
resolveMutationsForMultipleVariables,
|
|
35
|
+
resolveMutationsForSingleVariable,
|
|
36
|
+
} from "./mutateVariables";
|
|
33
37
|
|
|
34
38
|
export interface CustomDatafileOptions {
|
|
35
39
|
featureKey?: string;
|
|
@@ -210,7 +214,10 @@ export async function buildDatafile(
|
|
|
210
214
|
const mappedVariation: any = {
|
|
211
215
|
value: variation.value,
|
|
212
216
|
weight: variation.weight, // @NOTE: added so state files can maintain weight info, but datafiles don't need this. find a way to remove it from datafiles later
|
|
213
|
-
variables:
|
|
217
|
+
variables: resolveMutationsForMultipleVariables(
|
|
218
|
+
parsedFeature.variablesSchema,
|
|
219
|
+
variation.variables,
|
|
220
|
+
),
|
|
214
221
|
variableOverrides: variation.variableOverrides,
|
|
215
222
|
};
|
|
216
223
|
|
|
@@ -235,7 +242,11 @@ export async function buildDatafile(
|
|
|
235
242
|
projectConfig.stringify && typeof override.conditions !== "string"
|
|
236
243
|
? JSON.stringify(override.conditions)
|
|
237
244
|
: override.conditions,
|
|
238
|
-
value:
|
|
245
|
+
value: resolveMutationsForSingleVariable(
|
|
246
|
+
parsedFeature.variablesSchema,
|
|
247
|
+
variableKey,
|
|
248
|
+
override.value,
|
|
249
|
+
),
|
|
239
250
|
};
|
|
240
251
|
}
|
|
241
252
|
|
|
@@ -252,7 +263,11 @@ export async function buildDatafile(
|
|
|
252
263
|
projectConfig.stringify && typeof override.segments !== "string"
|
|
253
264
|
? JSON.stringify(override.segments)
|
|
254
265
|
: override.segments,
|
|
255
|
-
value:
|
|
266
|
+
value: resolveMutationsForSingleVariable(
|
|
267
|
+
parsedFeature.variablesSchema,
|
|
268
|
+
variableKey,
|
|
269
|
+
override.value,
|
|
270
|
+
),
|
|
256
271
|
};
|
|
257
272
|
}
|
|
258
273
|
|
|
@@ -272,6 +287,10 @@ export async function buildDatafile(
|
|
|
272
287
|
).map((t: Traffic) => {
|
|
273
288
|
return {
|
|
274
289
|
...t,
|
|
290
|
+
variables: resolveMutationsForMultipleVariables(
|
|
291
|
+
parsedFeature.variablesSchema,
|
|
292
|
+
t.variables,
|
|
293
|
+
),
|
|
275
294
|
segments:
|
|
276
295
|
typeof t.segments !== "string" && projectConfig.stringify
|
|
277
296
|
? JSON.stringify(t.segments)
|
|
@@ -352,6 +371,13 @@ export async function buildDatafile(
|
|
|
352
371
|
: f.conditions;
|
|
353
372
|
}
|
|
354
373
|
|
|
374
|
+
if (f.variables) {
|
|
375
|
+
f.variables = resolveMutationsForMultipleVariables(
|
|
376
|
+
parsedFeature.variablesSchema,
|
|
377
|
+
f.variables,
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
|
|
355
381
|
return f;
|
|
356
382
|
});
|
|
357
383
|
}
|