@featurevisor/core 2.17.0 → 2.19.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 +1692 -1196
- package/coverage/coverage-final.json +29 -22
- package/coverage/lcov-report/builder/allocator.ts.html +26 -26
- package/coverage/lcov-report/builder/buildDatafile.ts.html +2017 -0
- package/coverage/lcov-report/builder/buildScopedConditions.ts.html +35 -35
- package/coverage/lcov-report/builder/buildScopedDatafile.ts.html +213 -45
- package/coverage/lcov-report/builder/buildScopedSegments.ts.html +28 -28
- package/coverage/lcov-report/builder/convertToV1.ts.html +583 -0
- package/coverage/lcov-report/builder/getFeatureRanges.ts.html +268 -0
- package/coverage/lcov-report/builder/hashes.ts.html +412 -0
- package/coverage/lcov-report/builder/index.html +90 -30
- package/coverage/lcov-report/builder/mutateVariables.ts.html +66 -45
- package/coverage/lcov-report/builder/mutator.ts.html +95 -95
- package/coverage/lcov-report/builder/revision.ts.html +1 -1
- package/coverage/lcov-report/builder/traffic.ts.html +60 -57
- package/coverage/lcov-report/config/index.html +1 -1
- package/coverage/lcov-report/config/index.ts.html +2 -2
- package/coverage/lcov-report/config/projectConfig.ts.html +28 -28
- package/coverage/lcov-report/datasource/adapter.ts.html +2 -2
- package/coverage/lcov-report/datasource/datasource.ts.html +4 -4
- package/coverage/lcov-report/datasource/filesystemAdapter.ts.html +34 -34
- package/coverage/lcov-report/datasource/index.html +1 -1
- package/coverage/lcov-report/datasource/index.ts.html +1 -1
- package/coverage/lcov-report/index.html +39 -39
- package/coverage/lcov-report/linter/attributeSchema.ts.html +1 -1
- package/coverage/lcov-report/linter/checkCircularDependency.ts.html +1 -1
- package/coverage/lcov-report/linter/checkPercentageExceedingSlot.ts.html +1 -1
- package/coverage/lcov-report/linter/conditionSchema.ts.html +17 -17
- package/coverage/lcov-report/linter/featureSchema.ts.html +879 -417
- package/coverage/lcov-report/linter/groupSchema.ts.html +1 -1
- package/coverage/lcov-report/linter/index.html +34 -34
- package/coverage/lcov-report/linter/lintProject.ts.html +25 -25
- package/coverage/lcov-report/linter/mutationNotation.ts.html +224 -122
- package/coverage/lcov-report/linter/printError.ts.html +1 -1
- package/coverage/lcov-report/linter/schema.ts.html +175 -85
- package/coverage/lcov-report/linter/segmentSchema.ts.html +1 -1
- package/coverage/lcov-report/linter/testSchema.ts.html +5 -5
- 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 +1 -1
- package/coverage/lcov-report/parsers/index.ts.html +4 -4
- 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 +1 -1
- package/coverage/lcov-report/tester/helpers.ts.html +1 -1
- package/coverage/lcov-report/tester/index.html +1 -1
- package/coverage/lcov-report/utils/extractKeys.ts.html +493 -0
- package/coverage/lcov-report/utils/git.ts.html +3 -3
- package/coverage/lcov-report/utils/index.html +54 -9
- package/coverage/lcov-report/utils/index.ts.html +94 -0
- package/coverage/lcov-report/utils/pretty.ts.html +121 -0
- package/coverage/lcov.info +3206 -2260
- package/json-schema/attribute.json +25 -9
- package/json-schema/feature.json +319 -238
- package/json-schema/segment.json +76 -45
- package/lib/builder/buildDatafile.js +50 -3
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildDatafile.spec.d.ts +1 -0
- package/lib/builder/buildDatafile.spec.js +233 -0
- package/lib/builder/buildDatafile.spec.js.map +1 -0
- package/lib/builder/buildScopedDatafile.js +37 -1
- package/lib/builder/buildScopedDatafile.js.map +1 -1
- package/lib/builder/buildScopedDatafile.spec.js +289 -0
- package/lib/builder/buildScopedDatafile.spec.js.map +1 -1
- package/lib/builder/mutateVariables.d.ts +1 -1
- package/lib/builder/mutateVariables.js +4 -1
- package/lib/builder/mutateVariables.js.map +1 -1
- package/lib/builder/mutateVariables.spec.js +29 -0
- package/lib/builder/mutateVariables.spec.js.map +1 -1
- package/lib/builder/traffic.js +1 -0
- package/lib/builder/traffic.js.map +1 -1
- package/lib/builder/traffic.spec.js +26 -0
- package/lib/builder/traffic.spec.js.map +1 -1
- package/lib/generate-code/typescript.js +63 -20
- package/lib/generate-code/typescript.js.map +1 -1
- package/lib/linter/featureSchema.d.ts +237 -22
- package/lib/linter/featureSchema.js +175 -84
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/linter/featureSchema.spec.js +268 -0
- package/lib/linter/featureSchema.spec.js.map +1 -1
- package/lib/linter/mutationNotation.js +54 -19
- package/lib/linter/mutationNotation.js.map +1 -1
- package/lib/linter/mutationNotation.spec.js +49 -0
- package/lib/linter/mutationNotation.spec.js.map +1 -1
- package/lib/linter/schema.d.ts +1 -0
- package/lib/linter/schema.js +13 -0
- package/lib/linter/schema.js.map +1 -1
- package/lib/linter/schema.spec.js +51 -0
- package/lib/linter/schema.spec.js.map +1 -1
- package/package.json +5 -5
- package/src/builder/buildDatafile.spec.ts +267 -0
- package/src/builder/buildDatafile.ts +85 -4
- package/src/builder/buildScopedDatafile.spec.ts +330 -0
- package/src/builder/buildScopedDatafile.ts +57 -1
- package/src/builder/mutateVariables.spec.ts +45 -0
- package/src/builder/mutateVariables.ts +7 -0
- package/src/builder/traffic.spec.ts +33 -0
- package/src/builder/traffic.ts +1 -0
- package/src/generate-code/typescript.ts +87 -20
- package/src/linter/featureSchema.spec.ts +315 -0
- package/src/linter/featureSchema.ts +269 -115
- package/src/linter/mutationNotation.spec.ts +62 -0
- package/src/linter/mutationNotation.ts +47 -13
- package/src/linter/schema.spec.ts +72 -0
- package/src/linter/schema.ts +30 -0
|
@@ -88,9 +88,14 @@ export function resolveSchemaAtPath(
|
|
|
88
88
|
if (seg.key) {
|
|
89
89
|
if (current.type !== "object") return null;
|
|
90
90
|
const props = current.properties;
|
|
91
|
-
|
|
92
|
-
const next = props[seg.key];
|
|
93
|
-
if (next === undefined)
|
|
91
|
+
const additional = current.additionalProperties;
|
|
92
|
+
const next = props && typeof props === "object" ? props[seg.key] : undefined;
|
|
93
|
+
if (next === undefined) {
|
|
94
|
+
if (!additional || typeof additional !== "object") return null;
|
|
95
|
+
current = resolveSchemaRef(additional, schemasByKey);
|
|
96
|
+
if (!current) return null;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
94
99
|
current = resolveSchemaRef(next, schemasByKey);
|
|
95
100
|
if (!current) return null;
|
|
96
101
|
}
|
|
@@ -127,27 +132,56 @@ function getContainerSchemaAtPath(
|
|
|
127
132
|
const lastSegment = pathSegments[pathSegments.length - 1];
|
|
128
133
|
for (const seg of pathWithoutLast) {
|
|
129
134
|
if (isOneOfSchema(current)) return null;
|
|
135
|
+
if (seg.key) {
|
|
136
|
+
if (current.type !== "object") return null;
|
|
137
|
+
const props = current.properties;
|
|
138
|
+
const additional = current.additionalProperties;
|
|
139
|
+
const next = props && typeof props === "object" ? props[seg.key] : undefined;
|
|
140
|
+
if (next === undefined) {
|
|
141
|
+
if (!additional || typeof additional !== "object") return null;
|
|
142
|
+
current = resolveSchemaRef(additional, schemasByKey);
|
|
143
|
+
if (!current) return null;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
current = resolveSchemaRef(next, schemasByKey);
|
|
147
|
+
}
|
|
130
148
|
if ("index" in seg || "selector" in seg) {
|
|
131
|
-
if (current
|
|
149
|
+
if (current?.type !== "array") return null;
|
|
132
150
|
const itemSchema = current.items;
|
|
133
151
|
if (!itemSchema || typeof itemSchema !== "object") return null;
|
|
134
152
|
current = resolveSchemaRef(itemSchema, schemasByKey);
|
|
135
|
-
} else {
|
|
136
|
-
if (current.type !== "object") return null;
|
|
137
|
-
const props = current.properties;
|
|
138
|
-
if (!props || typeof props !== "object") return null;
|
|
139
|
-
const next = props[seg.key];
|
|
140
|
-
if (next === undefined) return null;
|
|
141
|
-
current = resolveSchemaRef(next, schemasByKey);
|
|
142
153
|
}
|
|
143
154
|
if (!current) return null;
|
|
144
155
|
}
|
|
145
156
|
if (!current) return null;
|
|
146
157
|
const parentSchema = current;
|
|
147
158
|
if ("index" in lastSegment || "selector" in lastSegment) {
|
|
148
|
-
|
|
159
|
+
let arraySchema: Schema | null = parentSchema;
|
|
160
|
+
if (lastSegment.key) {
|
|
161
|
+
if (arraySchema.type !== "object") return null;
|
|
162
|
+
const props = arraySchema.properties;
|
|
163
|
+
const additional = arraySchema.additionalProperties;
|
|
164
|
+
const next = props && typeof props === "object" ? props[lastSegment.key] : undefined;
|
|
165
|
+
if (next === undefined) {
|
|
166
|
+
if (!additional || typeof additional !== "object") return null;
|
|
167
|
+
arraySchema = resolveSchemaRef(additional, schemasByKey);
|
|
168
|
+
} else {
|
|
169
|
+
arraySchema = resolveSchemaRef(next, schemasByKey);
|
|
170
|
+
}
|
|
171
|
+
if (!arraySchema) return null;
|
|
172
|
+
}
|
|
173
|
+
const normalizedLastSegment =
|
|
174
|
+
"index" in lastSegment
|
|
175
|
+
? ({ key: "", index: lastSegment.index } as PathSegment)
|
|
176
|
+
: ({ key: "", selector: lastSegment.selector } as PathSegment);
|
|
177
|
+
return {
|
|
178
|
+
containerSchema: arraySchema,
|
|
179
|
+
lastSegment: normalizedLastSegment,
|
|
180
|
+
parentSchema: arraySchema,
|
|
181
|
+
};
|
|
149
182
|
}
|
|
150
|
-
const propSchema =
|
|
183
|
+
const propSchema =
|
|
184
|
+
parentSchema.properties?.[lastSegment.key] ?? parentSchema.additionalProperties;
|
|
151
185
|
const resolvedProp =
|
|
152
186
|
propSchema && typeof propSchema === "object"
|
|
153
187
|
? resolveSchemaRef(propSchema, schemasByKey)
|
|
@@ -142,6 +142,20 @@ describe("schema.ts :: refineEnumMatchesType", () => {
|
|
|
142
142
|
expect(issues[0].path).toEqual(["oneOf", 1, "enum", 1]);
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
+
it("recurses into additionalProperties", () => {
|
|
146
|
+
const { issues, ctx } = createRefinementCtx();
|
|
147
|
+
refineEnumMatchesType(
|
|
148
|
+
{
|
|
149
|
+
type: "object",
|
|
150
|
+
additionalProperties: { type: "string", enum: ["a", 1] },
|
|
151
|
+
},
|
|
152
|
+
[],
|
|
153
|
+
ctx,
|
|
154
|
+
);
|
|
155
|
+
expect(issues).toHaveLength(1);
|
|
156
|
+
expect(issues[0].path).toEqual(["additionalProperties", "enum", 1]);
|
|
157
|
+
});
|
|
158
|
+
|
|
145
159
|
it("does nothing when schema is null or not an object", () => {
|
|
146
160
|
const { issues: i1, ctx: c1 } = createRefinementCtx();
|
|
147
161
|
refineEnumMatchesType(null as any, [], c1);
|
|
@@ -215,6 +229,20 @@ describe("schema.ts :: refineMinimumMaximum", () => {
|
|
|
215
229
|
expect(issues).toHaveLength(1);
|
|
216
230
|
expect(issues[0].path).toEqual(["items", "minimum"]);
|
|
217
231
|
});
|
|
232
|
+
|
|
233
|
+
it("recurses into additionalProperties", () => {
|
|
234
|
+
const { issues, ctx } = createRefinementCtx();
|
|
235
|
+
refineMinimumMaximum(
|
|
236
|
+
{
|
|
237
|
+
type: "object",
|
|
238
|
+
additionalProperties: { type: "integer", minimum: 10, maximum: 5 },
|
|
239
|
+
},
|
|
240
|
+
[],
|
|
241
|
+
ctx,
|
|
242
|
+
);
|
|
243
|
+
expect(issues).toHaveLength(1);
|
|
244
|
+
expect(issues[0].path).toEqual(["additionalProperties", "minimum"]);
|
|
245
|
+
});
|
|
218
246
|
});
|
|
219
247
|
|
|
220
248
|
describe("schema.ts :: refineStringLengthPattern", () => {
|
|
@@ -288,6 +316,20 @@ describe("schema.ts :: refineStringLengthPattern", () => {
|
|
|
288
316
|
expect(issues).toHaveLength(1);
|
|
289
317
|
expect(issues[0].path).toEqual(["properties", "code", "minLength"]);
|
|
290
318
|
});
|
|
319
|
+
|
|
320
|
+
it("recurses into additionalProperties", () => {
|
|
321
|
+
const { issues, ctx } = createRefinementCtx();
|
|
322
|
+
refineStringLengthPattern(
|
|
323
|
+
{
|
|
324
|
+
type: "object",
|
|
325
|
+
additionalProperties: { type: "string", minLength: 10, maxLength: 5 },
|
|
326
|
+
},
|
|
327
|
+
[],
|
|
328
|
+
ctx,
|
|
329
|
+
);
|
|
330
|
+
expect(issues).toHaveLength(1);
|
|
331
|
+
expect(issues[0].path).toEqual(["additionalProperties", "minLength"]);
|
|
332
|
+
});
|
|
291
333
|
});
|
|
292
334
|
|
|
293
335
|
describe("schema.ts :: refineArrayItems", () => {
|
|
@@ -357,6 +399,25 @@ describe("schema.ts :: refineArrayItems", () => {
|
|
|
357
399
|
expect(issues).toHaveLength(1);
|
|
358
400
|
expect(issues[0].path).toEqual(["items", "minItems"]);
|
|
359
401
|
});
|
|
402
|
+
|
|
403
|
+
it("recurses into additionalProperties", () => {
|
|
404
|
+
const { issues, ctx } = createRefinementCtx();
|
|
405
|
+
refineArrayItems(
|
|
406
|
+
{
|
|
407
|
+
type: "object",
|
|
408
|
+
additionalProperties: {
|
|
409
|
+
type: "array",
|
|
410
|
+
minItems: 5,
|
|
411
|
+
maxItems: 2,
|
|
412
|
+
items: { type: "string" },
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
[],
|
|
416
|
+
ctx,
|
|
417
|
+
);
|
|
418
|
+
expect(issues).toHaveLength(1);
|
|
419
|
+
expect(issues[0].path).toEqual(["additionalProperties", "minItems"]);
|
|
420
|
+
});
|
|
360
421
|
});
|
|
361
422
|
|
|
362
423
|
describe("schema.ts :: getSchemaZodSchema", () => {
|
|
@@ -491,6 +552,17 @@ describe("schema.ts :: getSchemaZodSchema", () => {
|
|
|
491
552
|
expect(result.success).toBe(true);
|
|
492
553
|
});
|
|
493
554
|
|
|
555
|
+
it("accepts object schema with additionalProperties", () => {
|
|
556
|
+
const Schema = getSchemaZodSchema([]);
|
|
557
|
+
const result = Schema.safeParse({
|
|
558
|
+
type: "object",
|
|
559
|
+
additionalProperties: {
|
|
560
|
+
type: "string",
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
expect(result.success).toBe(true);
|
|
564
|
+
});
|
|
565
|
+
|
|
494
566
|
it("accepts array schema with items that reference another schema", () => {
|
|
495
567
|
const Schema = getSchemaZodSchema(["link"]);
|
|
496
568
|
const result = Schema.safeParse({
|
package/src/linter/schema.ts
CHANGED
|
@@ -35,6 +35,7 @@ type SchemaLike = {
|
|
|
35
35
|
uniqueItems?: boolean;
|
|
36
36
|
items?: unknown;
|
|
37
37
|
properties?: Record<string, unknown>;
|
|
38
|
+
additionalProperties?: unknown;
|
|
38
39
|
oneOf?: unknown[];
|
|
39
40
|
};
|
|
40
41
|
|
|
@@ -74,6 +75,13 @@ export function refineEnumMatchesType(
|
|
|
74
75
|
);
|
|
75
76
|
}
|
|
76
77
|
}
|
|
78
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
79
|
+
refineEnumMatchesType(
|
|
80
|
+
schema.additionalProperties as SchemaLike,
|
|
81
|
+
[...pathPrefix, "additionalProperties"],
|
|
82
|
+
ctx,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
77
85
|
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
78
86
|
schema.oneOf.forEach((branch, i) => {
|
|
79
87
|
if (branch && typeof branch === "object") {
|
|
@@ -157,6 +165,13 @@ export function refineMinimumMaximum(
|
|
|
157
165
|
);
|
|
158
166
|
}
|
|
159
167
|
}
|
|
168
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
169
|
+
refineMinimumMaximum(
|
|
170
|
+
schema.additionalProperties as SchemaLike,
|
|
171
|
+
[...pathPrefix, "additionalProperties"],
|
|
172
|
+
ctx,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
160
175
|
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
161
176
|
schema.oneOf.forEach((branch, i) => {
|
|
162
177
|
if (branch && typeof branch === "object") {
|
|
@@ -277,6 +292,13 @@ export function refineStringLengthPattern(
|
|
|
277
292
|
);
|
|
278
293
|
}
|
|
279
294
|
}
|
|
295
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
296
|
+
refineStringLengthPattern(
|
|
297
|
+
schema.additionalProperties as SchemaLike,
|
|
298
|
+
[...pathPrefix, "additionalProperties"],
|
|
299
|
+
ctx,
|
|
300
|
+
);
|
|
301
|
+
}
|
|
280
302
|
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
281
303
|
schema.oneOf.forEach((branch, i) => {
|
|
282
304
|
if (branch && typeof branch === "object") {
|
|
@@ -376,6 +398,13 @@ export function refineArrayItems(
|
|
|
376
398
|
refineArrayItems(schema.properties[k] as SchemaLike, [...pathPrefix, "properties", k], ctx);
|
|
377
399
|
}
|
|
378
400
|
}
|
|
401
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
402
|
+
refineArrayItems(
|
|
403
|
+
schema.additionalProperties as SchemaLike,
|
|
404
|
+
[...pathPrefix, "additionalProperties"],
|
|
405
|
+
ctx,
|
|
406
|
+
);
|
|
407
|
+
}
|
|
379
408
|
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
380
409
|
schema.oneOf.forEach((branch, i) => {
|
|
381
410
|
if (branch && typeof branch === "object") {
|
|
@@ -428,6 +457,7 @@ export function getSchemaZodSchema(schemaKeys: SchemaKey[] = []) {
|
|
|
428
457
|
uniqueItems: z.boolean().optional(),
|
|
429
458
|
required: z.array(z.string()).optional(),
|
|
430
459
|
properties: z.record(z.string(), schemaZodSchema).optional(),
|
|
460
|
+
additionalProperties: schemaZodSchema.optional(),
|
|
431
461
|
// Annotations: default?: Value; examples?: Value[];
|
|
432
462
|
|
|
433
463
|
schema: z
|