@usefragments/core 1.7.1 → 1.9.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/dist/{chunk-WNMWKUYG.js → chunk-DGHZQTLH.js} +324 -6
- package/dist/chunk-DGHZQTLH.js.map +1 -0
- package/dist/chunk-MZ4SW3TP.js +375 -0
- package/dist/chunk-MZ4SW3TP.js.map +1 -0
- package/dist/codes/index.d.ts +1 -1
- package/dist/codes/index.js +1 -2
- package/dist/compiled-types/index.d.ts +1 -1
- package/dist/generate/index.d.ts +1 -1
- package/dist/governance-telemetry.d.ts +316 -0
- package/dist/governance-telemetry.js +11 -0
- package/dist/governance-telemetry.js.map +1 -0
- package/dist/{index-hZAlYCli.d.ts → index-DtHxs0Pf.d.ts} +1099 -1009
- package/dist/index.d.ts +503 -477
- package/dist/index.js +94 -37
- package/dist/index.js.map +1 -1
- package/dist/react-types.d.ts +1 -1
- package/dist/registry.d.ts +146 -146
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.js +3 -1
- package/dist/test-utils.d.ts +1 -1
- package/package.json +5 -1
- package/src/governance-telemetry.test.ts +18 -0
- package/src/governance-telemetry.ts +398 -0
- package/src/index.ts +17 -0
- package/src/rules/finding.ts +22 -0
- package/src/rules/index.ts +5 -1
- package/src/rules/jsx-preferred-import-path.ts +18 -0
- package/src/rules/rules.test.ts +114 -0
- package/src/rules/tokens-css-vars-must-be-defined.test.ts +66 -1
- package/src/rules/tokens-css-vars-must-be-defined.ts +88 -16
- package/src/schemas/index.ts +10 -0
- package/src/schemas/normalize-finding.test.ts +50 -0
- package/dist/chunk-WNMWKUYG.js.map +0 -1
- package/dist/chunk-ZHS52OT4.js +0 -317
- package/dist/chunk-ZHS52OT4.js.map +0 -1
- package/dist/{governance-D9KtH-vg.d.ts → governance-eEzCyfes.d.ts} +154 -154
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
normalizeFinding,
|
|
3
|
-
normalizeViolation
|
|
4
|
-
} from "./chunk-ZHS52OT4.js";
|
|
5
1
|
import {
|
|
6
2
|
authorOwnedImport,
|
|
7
3
|
canonicalizeOwnedComponentId,
|
|
@@ -13,6 +9,13 @@ import {
|
|
|
13
9
|
import {
|
|
14
10
|
portableRepoPathError
|
|
15
11
|
} from "./chunk-EIYNNS77.js";
|
|
12
|
+
import {
|
|
13
|
+
legacySeverityLevelSchema,
|
|
14
|
+
severityFromLevel,
|
|
15
|
+
severityLevel,
|
|
16
|
+
severityLevelSchema,
|
|
17
|
+
severitySchema
|
|
18
|
+
} from "./chunk-V4VQB57N.js";
|
|
16
19
|
|
|
17
20
|
// src/rules/fix-availability.ts
|
|
18
21
|
var RULE_FIX_AVAILABLE = {
|
|
@@ -2419,6 +2422,296 @@ function compileComponentGovernanceRecord(componentId2, record) {
|
|
|
2419
2422
|
}
|
|
2420
2423
|
}
|
|
2421
2424
|
|
|
2425
|
+
// src/schemas/index.ts
|
|
2426
|
+
import { z as z3 } from "zod";
|
|
2427
|
+
var evidenceGradeSchema = z3.enum([
|
|
2428
|
+
"none",
|
|
2429
|
+
"runtime_advisory",
|
|
2430
|
+
"provenance_bound",
|
|
2431
|
+
"source_backed",
|
|
2432
|
+
"receipt_backed"
|
|
2433
|
+
]);
|
|
2434
|
+
var factLocationSchema = z3.object({
|
|
2435
|
+
file: z3.string(),
|
|
2436
|
+
line: z3.number().int().nonnegative(),
|
|
2437
|
+
column: z3.number().int().nonnegative(),
|
|
2438
|
+
endLine: z3.number().int().nonnegative().optional(),
|
|
2439
|
+
endColumn: z3.number().int().nonnegative().optional()
|
|
2440
|
+
});
|
|
2441
|
+
var findingReplacePropValueFixSchema = z3.object({
|
|
2442
|
+
kind: z3.literal("replacePropValue"),
|
|
2443
|
+
title: z3.string(),
|
|
2444
|
+
prop: z3.string(),
|
|
2445
|
+
value: z3.unknown(),
|
|
2446
|
+
deterministic: z3.boolean().optional()
|
|
2447
|
+
});
|
|
2448
|
+
var findingReplaceStyleValueFixSchema = z3.object({
|
|
2449
|
+
kind: z3.literal("replaceStyleValue"),
|
|
2450
|
+
title: z3.string(),
|
|
2451
|
+
property: z3.string(),
|
|
2452
|
+
value: z3.string(),
|
|
2453
|
+
deterministic: z3.boolean().optional()
|
|
2454
|
+
});
|
|
2455
|
+
var findingReplaceImportFixSchema = z3.object({
|
|
2456
|
+
kind: z3.literal("replaceImport"),
|
|
2457
|
+
title: z3.string(),
|
|
2458
|
+
from: z3.string(),
|
|
2459
|
+
to: z3.string(),
|
|
2460
|
+
deterministic: z3.boolean().optional()
|
|
2461
|
+
});
|
|
2462
|
+
var findingReplaceComponentFixSchema = z3.object({
|
|
2463
|
+
kind: z3.literal("replaceComponent"),
|
|
2464
|
+
title: z3.string(),
|
|
2465
|
+
from: z3.string(),
|
|
2466
|
+
to: z3.string(),
|
|
2467
|
+
deterministic: z3.boolean().optional()
|
|
2468
|
+
});
|
|
2469
|
+
var findingReplaceClassTokenFixSchema = z3.object({
|
|
2470
|
+
kind: z3.literal("replaceClassToken"),
|
|
2471
|
+
title: z3.string(),
|
|
2472
|
+
from: z3.string(),
|
|
2473
|
+
to: z3.string().nullable(),
|
|
2474
|
+
utility: z3.string(),
|
|
2475
|
+
deterministic: z3.boolean().optional()
|
|
2476
|
+
});
|
|
2477
|
+
var findingFixSchema = z3.discriminatedUnion("kind", [
|
|
2478
|
+
findingReplacePropValueFixSchema,
|
|
2479
|
+
findingReplaceStyleValueFixSchema,
|
|
2480
|
+
findingReplaceImportFixSchema,
|
|
2481
|
+
findingReplaceComponentFixSchema,
|
|
2482
|
+
findingReplaceClassTokenFixSchema
|
|
2483
|
+
]);
|
|
2484
|
+
var factEvidenceSchema = z3.object({
|
|
2485
|
+
factId: z3.string(),
|
|
2486
|
+
fact: z3.object({
|
|
2487
|
+
kind: z3.string(),
|
|
2488
|
+
location: factLocationSchema.optional()
|
|
2489
|
+
}).passthrough()
|
|
2490
|
+
});
|
|
2491
|
+
var findingSchema = z3.object({
|
|
2492
|
+
ruleId: z3.string(),
|
|
2493
|
+
ruleVersion: z3.string(),
|
|
2494
|
+
severity: severitySchema,
|
|
2495
|
+
level: severityLevelSchema,
|
|
2496
|
+
code: z3.string().regex(/^FUI\d{4}$/).optional(),
|
|
2497
|
+
helpUrl: z3.string().url().optional(),
|
|
2498
|
+
message: z3.string(),
|
|
2499
|
+
fingerprint: z3.string(),
|
|
2500
|
+
/**
|
|
2501
|
+
* Fingerprint this finding carried before a fingerprint-identity migration.
|
|
2502
|
+
* Emitted only by migrated rules during the grace window so baseline
|
|
2503
|
+
* records keyed on the legacy hash keep matching instead of churning.
|
|
2504
|
+
*/
|
|
2505
|
+
previousFingerprint: z3.string().optional(),
|
|
2506
|
+
location: factLocationSchema,
|
|
2507
|
+
evidence: z3.array(factEvidenceSchema).min(1),
|
|
2508
|
+
evidenceGrade: evidenceGradeSchema.optional(),
|
|
2509
|
+
fix: findingFixSchema.optional(),
|
|
2510
|
+
attributes: z3.record(z3.unknown()).optional(),
|
|
2511
|
+
/**
|
|
2512
|
+
* Product area this finding's file resolved to (topology layer). Optional —
|
|
2513
|
+
* absent when the repo has no `topology` config. See `topology/resolve-area`.
|
|
2514
|
+
*/
|
|
2515
|
+
area: z3.object({
|
|
2516
|
+
areaId: z3.string(),
|
|
2517
|
+
areaName: z3.string(),
|
|
2518
|
+
criticality: z3.enum(["low", "medium", "high", "revenue", "regulated"]),
|
|
2519
|
+
owners: z3.array(z3.string()),
|
|
2520
|
+
matchedGlob: z3.string()
|
|
2521
|
+
}).optional()
|
|
2522
|
+
});
|
|
2523
|
+
var violationSchema = z3.object({
|
|
2524
|
+
nodeId: z3.string(),
|
|
2525
|
+
nodeType: z3.string(),
|
|
2526
|
+
rule: z3.string(),
|
|
2527
|
+
severity: severitySchema,
|
|
2528
|
+
level: severityLevelSchema.optional(),
|
|
2529
|
+
code: z3.string().regex(/^FUI\d{4}$/).optional(),
|
|
2530
|
+
helpUrl: z3.string().url().optional(),
|
|
2531
|
+
message: z3.string(),
|
|
2532
|
+
path: z3.string().optional(),
|
|
2533
|
+
suggestion: z3.string().optional(),
|
|
2534
|
+
prop: z3.string().optional(),
|
|
2535
|
+
filePath: z3.string().optional(),
|
|
2536
|
+
line: z3.number().int().nonnegative().optional(),
|
|
2537
|
+
column: z3.number().int().nonnegative().optional(),
|
|
2538
|
+
rawValue: z3.string().optional(),
|
|
2539
|
+
extra: z3.record(z3.unknown()).optional()
|
|
2540
|
+
});
|
|
2541
|
+
var fixSchema = z3.object({
|
|
2542
|
+
nodeId: z3.string(),
|
|
2543
|
+
prop: z3.string().optional(),
|
|
2544
|
+
action: z3.enum(["remove", "replace", "add"]),
|
|
2545
|
+
value: z3.unknown().optional(),
|
|
2546
|
+
description: z3.string()
|
|
2547
|
+
});
|
|
2548
|
+
var validatorResultSchema = z3.object({
|
|
2549
|
+
validator: z3.string(),
|
|
2550
|
+
severity: severitySchema,
|
|
2551
|
+
passed: z3.boolean(),
|
|
2552
|
+
violations: z3.array(violationSchema),
|
|
2553
|
+
findings: z3.array(findingSchema).optional(),
|
|
2554
|
+
suggestions: z3.array(fixSchema).optional()
|
|
2555
|
+
});
|
|
2556
|
+
var governanceVerdictMetadataSchema = z3.object({
|
|
2557
|
+
runner: z3.string(),
|
|
2558
|
+
policyVersion: z3.string().optional(),
|
|
2559
|
+
duration: z3.number().nonnegative(),
|
|
2560
|
+
nodeCount: z3.number().int().nonnegative(),
|
|
2561
|
+
componentTypes: z3.array(z3.string())
|
|
2562
|
+
});
|
|
2563
|
+
var governanceVerdictSchema = z3.object({
|
|
2564
|
+
verdict: z3.enum(["pass", "warn", "fail"]).optional(),
|
|
2565
|
+
passed: z3.boolean(),
|
|
2566
|
+
score: z3.number(),
|
|
2567
|
+
results: z3.array(validatorResultSchema),
|
|
2568
|
+
metadata: governanceVerdictMetadataSchema
|
|
2569
|
+
});
|
|
2570
|
+
var suppressionDirectiveSchema = z3.object({
|
|
2571
|
+
ruleId: z3.string().optional(),
|
|
2572
|
+
reason: z3.string().min(1),
|
|
2573
|
+
expiresAt: z3.string().datetime().optional(),
|
|
2574
|
+
expiresOn: z3.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
2575
|
+
scope: z3.enum(["line", "block", "file"]).default("line"),
|
|
2576
|
+
code: z3.string().regex(/^FUI\d{4}$/).optional()
|
|
2577
|
+
});
|
|
2578
|
+
var agentPlanSchema = z3.object({
|
|
2579
|
+
tool: z3.enum([
|
|
2580
|
+
"design_system/list_primitives",
|
|
2581
|
+
"design_system/conform",
|
|
2582
|
+
"design_system/prove_compliant"
|
|
2583
|
+
]),
|
|
2584
|
+
args: z3.record(z3.unknown()),
|
|
2585
|
+
confidence: z3.number().min(0).max(1)
|
|
2586
|
+
});
|
|
2587
|
+
var agentFindingSchema = z3.object({
|
|
2588
|
+
code: z3.string().regex(/^FUI\d{4}$/).optional(),
|
|
2589
|
+
ruleId: z3.string(),
|
|
2590
|
+
filePath: z3.string(),
|
|
2591
|
+
line: z3.number().int().nonnegative(),
|
|
2592
|
+
col: z3.number().int().nonnegative(),
|
|
2593
|
+
severity: severitySchema,
|
|
2594
|
+
level: severityLevelSchema,
|
|
2595
|
+
message: z3.string(),
|
|
2596
|
+
evidenceGrade: evidenceGradeSchema.optional(),
|
|
2597
|
+
evidence: z3.array(factEvidenceSchema),
|
|
2598
|
+
plan: agentPlanSchema
|
|
2599
|
+
});
|
|
2600
|
+
var AGENT_FORMAT_SCHEMA_VERSION = "typestyle.agent.v2";
|
|
2601
|
+
var agentIntegritySchema = z3.object({
|
|
2602
|
+
rulesLoaded: z3.number().int().nonnegative(),
|
|
2603
|
+
status: z3.enum(["healthy", "degraded", "inert"]),
|
|
2604
|
+
healthy: z3.boolean(),
|
|
2605
|
+
inert: z3.boolean(),
|
|
2606
|
+
reasons: z3.array(z3.string())
|
|
2607
|
+
});
|
|
2608
|
+
var agentRunProvenanceSchema = z3.object({
|
|
2609
|
+
runId: z3.string().regex(/^run_[a-f0-9]{12}$/),
|
|
2610
|
+
fcid: z3.string().min(1),
|
|
2611
|
+
baselineId: z3.string().min(1).optional(),
|
|
2612
|
+
scope: z3.object({
|
|
2613
|
+
method: z3.enum(["three-dot", "tree-diff", "status", "fallback-full", "explicit", "full"]),
|
|
2614
|
+
gitOk: z3.boolean()
|
|
2615
|
+
}),
|
|
2616
|
+
engineVersion: z3.string().min(1),
|
|
2617
|
+
scopeHash: z3.string().regex(/^[a-f0-9]{64}$/),
|
|
2618
|
+
inputsHash: z3.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
2619
|
+
inputFilesHash: z3.string().regex(/^[a-f0-9]{64}$/)
|
|
2620
|
+
});
|
|
2621
|
+
var agentRunVerdictSchema = z3.object({
|
|
2622
|
+
exitCode: z3.union([z3.literal(0), z3.literal(1)]),
|
|
2623
|
+
reasons: z3.array(z3.string()),
|
|
2624
|
+
gatingFindingCount: z3.number().int().nonnegative()
|
|
2625
|
+
});
|
|
2626
|
+
var agentFormatBaseSchema = z3.object({
|
|
2627
|
+
schemaVersion: z3.literal(AGENT_FORMAT_SCHEMA_VERSION),
|
|
2628
|
+
summary: z3.string(),
|
|
2629
|
+
integrity: agentIntegritySchema,
|
|
2630
|
+
fix_first: z3.array(agentFindingSchema),
|
|
2631
|
+
remaining: z3.array(agentFindingSchema),
|
|
2632
|
+
suppression_template: z3.object({
|
|
2633
|
+
directive: z3.string(),
|
|
2634
|
+
requiredFields: z3.array(z3.string()),
|
|
2635
|
+
example: z3.string()
|
|
2636
|
+
}),
|
|
2637
|
+
budget: z3.object({
|
|
2638
|
+
iteration: z3.number().int().nonnegative(),
|
|
2639
|
+
maxIterations: z3.number().int().positive(),
|
|
2640
|
+
scoreDelta: z3.number()
|
|
2641
|
+
}),
|
|
2642
|
+
findings: z3.array(findingSchema).optional(),
|
|
2643
|
+
suppressions: z3.array(suppressionDirectiveSchema).optional(),
|
|
2644
|
+
provenance: agentRunProvenanceSchema.optional(),
|
|
2645
|
+
verdict: agentRunVerdictSchema.optional()
|
|
2646
|
+
});
|
|
2647
|
+
var agentFormatSchema = z3.union([
|
|
2648
|
+
agentFormatBaseSchema.extend({
|
|
2649
|
+
passed: z3.boolean(),
|
|
2650
|
+
score: z3.number(),
|
|
2651
|
+
status: z3.never().optional(),
|
|
2652
|
+
reasons: z3.never().optional(),
|
|
2653
|
+
integrity: agentIntegritySchema.extend({
|
|
2654
|
+
rulesLoaded: z3.number().int().positive()
|
|
2655
|
+
})
|
|
2656
|
+
}),
|
|
2657
|
+
agentFormatBaseSchema.extend({
|
|
2658
|
+
passed: z3.literal(false),
|
|
2659
|
+
score: z3.never().optional(),
|
|
2660
|
+
status: z3.literal("indeterminate"),
|
|
2661
|
+
reasons: z3.tuple([z3.literal("zero_rules_loaded")]),
|
|
2662
|
+
integrity: agentIntegritySchema.extend({
|
|
2663
|
+
rulesLoaded: z3.literal(0)
|
|
2664
|
+
})
|
|
2665
|
+
}),
|
|
2666
|
+
// A finalized Run can explicitly allow inert governance. Preserve the
|
|
2667
|
+
// indeterminate integrity truth while making `passed` match that Run's sole
|
|
2668
|
+
// verdict; requiring Run pins prevents generic zero-rule envelopes from
|
|
2669
|
+
// accidentally becoming green.
|
|
2670
|
+
agentFormatBaseSchema.extend({
|
|
2671
|
+
passed: z3.literal(true),
|
|
2672
|
+
score: z3.never().optional(),
|
|
2673
|
+
status: z3.literal("indeterminate"),
|
|
2674
|
+
reasons: z3.tuple([z3.literal("zero_rules_loaded")]),
|
|
2675
|
+
integrity: agentIntegritySchema.extend({
|
|
2676
|
+
rulesLoaded: z3.literal(0)
|
|
2677
|
+
}),
|
|
2678
|
+
provenance: agentRunProvenanceSchema,
|
|
2679
|
+
verdict: agentRunVerdictSchema.extend({ exitCode: z3.literal(0) })
|
|
2680
|
+
})
|
|
2681
|
+
]);
|
|
2682
|
+
var agentErrorEnvelopeSchema = z3.object({
|
|
2683
|
+
schemaVersion: z3.literal(AGENT_FORMAT_SCHEMA_VERSION),
|
|
2684
|
+
passed: z3.literal(false),
|
|
2685
|
+
error: z3.object({
|
|
2686
|
+
code: z3.string().min(1),
|
|
2687
|
+
message: z3.string().min(1)
|
|
2688
|
+
}),
|
|
2689
|
+
provenance: agentRunProvenanceSchema.optional(),
|
|
2690
|
+
verdict: agentRunVerdictSchema.optional(),
|
|
2691
|
+
cloudReport: z3.enum(["reported", "failed", "skipped"]).optional(),
|
|
2692
|
+
notices: z3.array(z3.string()).optional()
|
|
2693
|
+
});
|
|
2694
|
+
var agentOutputSchema = z3.union([agentFormatSchema, agentErrorEnvelopeSchema]);
|
|
2695
|
+
function normalizeSeverity(severity) {
|
|
2696
|
+
return severitySchema.safeParse(severity).success ? severity : severityFromLevel(legacySeverityLevelSchema.parse(severity));
|
|
2697
|
+
}
|
|
2698
|
+
function normalizeFinding(input) {
|
|
2699
|
+
const code2 = input.code === void 0 ? byRuleId.get(input.ruleId) : void 0;
|
|
2700
|
+
return {
|
|
2701
|
+
...input,
|
|
2702
|
+
code: input.code ?? code2?.code,
|
|
2703
|
+
helpUrl: input.helpUrl ?? code2?.explainUrl,
|
|
2704
|
+
evidenceGrade: input.evidenceGrade ?? "source_backed",
|
|
2705
|
+
level: input.level ?? severityLevel(input.severity)
|
|
2706
|
+
};
|
|
2707
|
+
}
|
|
2708
|
+
function normalizeViolation(input) {
|
|
2709
|
+
return {
|
|
2710
|
+
...input,
|
|
2711
|
+
level: input.level ?? severityLevel(input.severity)
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2422
2715
|
// src/codes/source-finding-bridge.ts
|
|
2423
2716
|
function bridgeSourceViolation(input) {
|
|
2424
2717
|
const ruleId = input.canonicalRuleId ?? input.violation.rule;
|
|
@@ -2591,6 +2884,31 @@ export {
|
|
|
2591
2884
|
projectSupersededImportPathPreferences,
|
|
2592
2885
|
compileComponentFacts,
|
|
2593
2886
|
bridgeSourceViolation,
|
|
2594
|
-
bridgeSourceViolations
|
|
2887
|
+
bridgeSourceViolations,
|
|
2888
|
+
factLocationSchema,
|
|
2889
|
+
findingReplacePropValueFixSchema,
|
|
2890
|
+
findingReplaceStyleValueFixSchema,
|
|
2891
|
+
findingReplaceImportFixSchema,
|
|
2892
|
+
findingReplaceComponentFixSchema,
|
|
2893
|
+
findingReplaceClassTokenFixSchema,
|
|
2894
|
+
findingFixSchema,
|
|
2895
|
+
factEvidenceSchema,
|
|
2896
|
+
findingSchema,
|
|
2897
|
+
violationSchema,
|
|
2898
|
+
fixSchema,
|
|
2899
|
+
validatorResultSchema,
|
|
2900
|
+
governanceVerdictMetadataSchema,
|
|
2901
|
+
governanceVerdictSchema,
|
|
2902
|
+
suppressionDirectiveSchema,
|
|
2903
|
+
agentPlanSchema,
|
|
2904
|
+
agentFindingSchema,
|
|
2905
|
+
AGENT_FORMAT_SCHEMA_VERSION,
|
|
2906
|
+
agentIntegritySchema,
|
|
2907
|
+
agentFormatSchema,
|
|
2908
|
+
agentErrorEnvelopeSchema,
|
|
2909
|
+
agentOutputSchema,
|
|
2910
|
+
normalizeSeverity,
|
|
2911
|
+
normalizeFinding,
|
|
2912
|
+
normalizeViolation
|
|
2595
2913
|
};
|
|
2596
|
-
//# sourceMappingURL=chunk-
|
|
2914
|
+
//# sourceMappingURL=chunk-DGHZQTLH.js.map
|