@usefragments/core 1.7.0 → 1.8.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-MZ4SW3TP.js +375 -0
- package/dist/chunk-MZ4SW3TP.js.map +1 -0
- package/dist/{chunk-WNMWKUYG.js → chunk-UUREQ4HD.js} +318 -6
- package/dist/chunk-UUREQ4HD.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-Cxk3SOQP.d.ts} +1005 -1005
- package/dist/index.d.ts +529 -477
- package/dist/index.js +78 -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/component-contract.ts +12 -0
- package/src/contract-parser.ts +2 -0
- package/src/governance-telemetry.test.ts +18 -0
- package/src/governance-telemetry.ts +398 -0
- package/src/index.ts +17 -0
- package/src/rules/index.ts +5 -1
- 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 +4 -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,290 @@ 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
|
+
location: factLocationSchema,
|
|
2501
|
+
evidence: z3.array(factEvidenceSchema).min(1),
|
|
2502
|
+
evidenceGrade: evidenceGradeSchema.optional(),
|
|
2503
|
+
fix: findingFixSchema.optional(),
|
|
2504
|
+
attributes: z3.record(z3.unknown()).optional(),
|
|
2505
|
+
/**
|
|
2506
|
+
* Product area this finding's file resolved to (topology layer). Optional —
|
|
2507
|
+
* absent when the repo has no `topology` config. See `topology/resolve-area`.
|
|
2508
|
+
*/
|
|
2509
|
+
area: z3.object({
|
|
2510
|
+
areaId: z3.string(),
|
|
2511
|
+
areaName: z3.string(),
|
|
2512
|
+
criticality: z3.enum(["low", "medium", "high", "revenue", "regulated"]),
|
|
2513
|
+
owners: z3.array(z3.string()),
|
|
2514
|
+
matchedGlob: z3.string()
|
|
2515
|
+
}).optional()
|
|
2516
|
+
});
|
|
2517
|
+
var violationSchema = z3.object({
|
|
2518
|
+
nodeId: z3.string(),
|
|
2519
|
+
nodeType: z3.string(),
|
|
2520
|
+
rule: z3.string(),
|
|
2521
|
+
severity: severitySchema,
|
|
2522
|
+
level: severityLevelSchema.optional(),
|
|
2523
|
+
code: z3.string().regex(/^FUI\d{4}$/).optional(),
|
|
2524
|
+
helpUrl: z3.string().url().optional(),
|
|
2525
|
+
message: z3.string(),
|
|
2526
|
+
path: z3.string().optional(),
|
|
2527
|
+
suggestion: z3.string().optional(),
|
|
2528
|
+
prop: z3.string().optional(),
|
|
2529
|
+
filePath: z3.string().optional(),
|
|
2530
|
+
line: z3.number().int().nonnegative().optional(),
|
|
2531
|
+
column: z3.number().int().nonnegative().optional(),
|
|
2532
|
+
rawValue: z3.string().optional(),
|
|
2533
|
+
extra: z3.record(z3.unknown()).optional()
|
|
2534
|
+
});
|
|
2535
|
+
var fixSchema = z3.object({
|
|
2536
|
+
nodeId: z3.string(),
|
|
2537
|
+
prop: z3.string().optional(),
|
|
2538
|
+
action: z3.enum(["remove", "replace", "add"]),
|
|
2539
|
+
value: z3.unknown().optional(),
|
|
2540
|
+
description: z3.string()
|
|
2541
|
+
});
|
|
2542
|
+
var validatorResultSchema = z3.object({
|
|
2543
|
+
validator: z3.string(),
|
|
2544
|
+
severity: severitySchema,
|
|
2545
|
+
passed: z3.boolean(),
|
|
2546
|
+
violations: z3.array(violationSchema),
|
|
2547
|
+
findings: z3.array(findingSchema).optional(),
|
|
2548
|
+
suggestions: z3.array(fixSchema).optional()
|
|
2549
|
+
});
|
|
2550
|
+
var governanceVerdictMetadataSchema = z3.object({
|
|
2551
|
+
runner: z3.string(),
|
|
2552
|
+
policyVersion: z3.string().optional(),
|
|
2553
|
+
duration: z3.number().nonnegative(),
|
|
2554
|
+
nodeCount: z3.number().int().nonnegative(),
|
|
2555
|
+
componentTypes: z3.array(z3.string())
|
|
2556
|
+
});
|
|
2557
|
+
var governanceVerdictSchema = z3.object({
|
|
2558
|
+
verdict: z3.enum(["pass", "warn", "fail"]).optional(),
|
|
2559
|
+
passed: z3.boolean(),
|
|
2560
|
+
score: z3.number(),
|
|
2561
|
+
results: z3.array(validatorResultSchema),
|
|
2562
|
+
metadata: governanceVerdictMetadataSchema
|
|
2563
|
+
});
|
|
2564
|
+
var suppressionDirectiveSchema = z3.object({
|
|
2565
|
+
ruleId: z3.string().optional(),
|
|
2566
|
+
reason: z3.string().min(1),
|
|
2567
|
+
expiresAt: z3.string().datetime().optional(),
|
|
2568
|
+
expiresOn: z3.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
2569
|
+
scope: z3.enum(["line", "block", "file"]).default("line"),
|
|
2570
|
+
code: z3.string().regex(/^FUI\d{4}$/).optional()
|
|
2571
|
+
});
|
|
2572
|
+
var agentPlanSchema = z3.object({
|
|
2573
|
+
tool: z3.enum([
|
|
2574
|
+
"design_system/list_primitives",
|
|
2575
|
+
"design_system/conform",
|
|
2576
|
+
"design_system/prove_compliant"
|
|
2577
|
+
]),
|
|
2578
|
+
args: z3.record(z3.unknown()),
|
|
2579
|
+
confidence: z3.number().min(0).max(1)
|
|
2580
|
+
});
|
|
2581
|
+
var agentFindingSchema = z3.object({
|
|
2582
|
+
code: z3.string().regex(/^FUI\d{4}$/).optional(),
|
|
2583
|
+
ruleId: z3.string(),
|
|
2584
|
+
filePath: z3.string(),
|
|
2585
|
+
line: z3.number().int().nonnegative(),
|
|
2586
|
+
col: z3.number().int().nonnegative(),
|
|
2587
|
+
severity: severitySchema,
|
|
2588
|
+
level: severityLevelSchema,
|
|
2589
|
+
message: z3.string(),
|
|
2590
|
+
evidenceGrade: evidenceGradeSchema.optional(),
|
|
2591
|
+
evidence: z3.array(factEvidenceSchema),
|
|
2592
|
+
plan: agentPlanSchema
|
|
2593
|
+
});
|
|
2594
|
+
var AGENT_FORMAT_SCHEMA_VERSION = "typestyle.agent.v2";
|
|
2595
|
+
var agentIntegritySchema = z3.object({
|
|
2596
|
+
rulesLoaded: z3.number().int().nonnegative(),
|
|
2597
|
+
status: z3.enum(["healthy", "degraded", "inert"]),
|
|
2598
|
+
healthy: z3.boolean(),
|
|
2599
|
+
inert: z3.boolean(),
|
|
2600
|
+
reasons: z3.array(z3.string())
|
|
2601
|
+
});
|
|
2602
|
+
var agentRunProvenanceSchema = z3.object({
|
|
2603
|
+
runId: z3.string().regex(/^run_[a-f0-9]{12}$/),
|
|
2604
|
+
fcid: z3.string().min(1),
|
|
2605
|
+
baselineId: z3.string().min(1).optional(),
|
|
2606
|
+
scope: z3.object({
|
|
2607
|
+
method: z3.enum(["three-dot", "tree-diff", "status", "fallback-full", "explicit", "full"]),
|
|
2608
|
+
gitOk: z3.boolean()
|
|
2609
|
+
}),
|
|
2610
|
+
engineVersion: z3.string().min(1),
|
|
2611
|
+
scopeHash: z3.string().regex(/^[a-f0-9]{64}$/),
|
|
2612
|
+
inputsHash: z3.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
2613
|
+
inputFilesHash: z3.string().regex(/^[a-f0-9]{64}$/)
|
|
2614
|
+
});
|
|
2615
|
+
var agentRunVerdictSchema = z3.object({
|
|
2616
|
+
exitCode: z3.union([z3.literal(0), z3.literal(1)]),
|
|
2617
|
+
reasons: z3.array(z3.string()),
|
|
2618
|
+
gatingFindingCount: z3.number().int().nonnegative()
|
|
2619
|
+
});
|
|
2620
|
+
var agentFormatBaseSchema = z3.object({
|
|
2621
|
+
schemaVersion: z3.literal(AGENT_FORMAT_SCHEMA_VERSION),
|
|
2622
|
+
summary: z3.string(),
|
|
2623
|
+
integrity: agentIntegritySchema,
|
|
2624
|
+
fix_first: z3.array(agentFindingSchema),
|
|
2625
|
+
remaining: z3.array(agentFindingSchema),
|
|
2626
|
+
suppression_template: z3.object({
|
|
2627
|
+
directive: z3.string(),
|
|
2628
|
+
requiredFields: z3.array(z3.string()),
|
|
2629
|
+
example: z3.string()
|
|
2630
|
+
}),
|
|
2631
|
+
budget: z3.object({
|
|
2632
|
+
iteration: z3.number().int().nonnegative(),
|
|
2633
|
+
maxIterations: z3.number().int().positive(),
|
|
2634
|
+
scoreDelta: z3.number()
|
|
2635
|
+
}),
|
|
2636
|
+
findings: z3.array(findingSchema).optional(),
|
|
2637
|
+
suppressions: z3.array(suppressionDirectiveSchema).optional(),
|
|
2638
|
+
provenance: agentRunProvenanceSchema.optional(),
|
|
2639
|
+
verdict: agentRunVerdictSchema.optional()
|
|
2640
|
+
});
|
|
2641
|
+
var agentFormatSchema = z3.union([
|
|
2642
|
+
agentFormatBaseSchema.extend({
|
|
2643
|
+
passed: z3.boolean(),
|
|
2644
|
+
score: z3.number(),
|
|
2645
|
+
status: z3.never().optional(),
|
|
2646
|
+
reasons: z3.never().optional(),
|
|
2647
|
+
integrity: agentIntegritySchema.extend({
|
|
2648
|
+
rulesLoaded: z3.number().int().positive()
|
|
2649
|
+
})
|
|
2650
|
+
}),
|
|
2651
|
+
agentFormatBaseSchema.extend({
|
|
2652
|
+
passed: z3.literal(false),
|
|
2653
|
+
score: z3.never().optional(),
|
|
2654
|
+
status: z3.literal("indeterminate"),
|
|
2655
|
+
reasons: z3.tuple([z3.literal("zero_rules_loaded")]),
|
|
2656
|
+
integrity: agentIntegritySchema.extend({
|
|
2657
|
+
rulesLoaded: z3.literal(0)
|
|
2658
|
+
})
|
|
2659
|
+
}),
|
|
2660
|
+
// A finalized Run can explicitly allow inert governance. Preserve the
|
|
2661
|
+
// indeterminate integrity truth while making `passed` match that Run's sole
|
|
2662
|
+
// verdict; requiring Run pins prevents generic zero-rule envelopes from
|
|
2663
|
+
// accidentally becoming green.
|
|
2664
|
+
agentFormatBaseSchema.extend({
|
|
2665
|
+
passed: z3.literal(true),
|
|
2666
|
+
score: z3.never().optional(),
|
|
2667
|
+
status: z3.literal("indeterminate"),
|
|
2668
|
+
reasons: z3.tuple([z3.literal("zero_rules_loaded")]),
|
|
2669
|
+
integrity: agentIntegritySchema.extend({
|
|
2670
|
+
rulesLoaded: z3.literal(0)
|
|
2671
|
+
}),
|
|
2672
|
+
provenance: agentRunProvenanceSchema,
|
|
2673
|
+
verdict: agentRunVerdictSchema.extend({ exitCode: z3.literal(0) })
|
|
2674
|
+
})
|
|
2675
|
+
]);
|
|
2676
|
+
var agentErrorEnvelopeSchema = z3.object({
|
|
2677
|
+
schemaVersion: z3.literal(AGENT_FORMAT_SCHEMA_VERSION),
|
|
2678
|
+
passed: z3.literal(false),
|
|
2679
|
+
error: z3.object({
|
|
2680
|
+
code: z3.string().min(1),
|
|
2681
|
+
message: z3.string().min(1)
|
|
2682
|
+
}),
|
|
2683
|
+
provenance: agentRunProvenanceSchema.optional(),
|
|
2684
|
+
verdict: agentRunVerdictSchema.optional(),
|
|
2685
|
+
cloudReport: z3.enum(["reported", "failed", "skipped"]).optional(),
|
|
2686
|
+
notices: z3.array(z3.string()).optional()
|
|
2687
|
+
});
|
|
2688
|
+
var agentOutputSchema = z3.union([agentFormatSchema, agentErrorEnvelopeSchema]);
|
|
2689
|
+
function normalizeSeverity(severity) {
|
|
2690
|
+
return severitySchema.safeParse(severity).success ? severity : severityFromLevel(legacySeverityLevelSchema.parse(severity));
|
|
2691
|
+
}
|
|
2692
|
+
function normalizeFinding(input) {
|
|
2693
|
+
const code2 = input.code === void 0 ? byRuleId.get(input.ruleId) : void 0;
|
|
2694
|
+
return {
|
|
2695
|
+
...input,
|
|
2696
|
+
code: input.code ?? code2?.code,
|
|
2697
|
+
helpUrl: input.helpUrl ?? code2?.explainUrl,
|
|
2698
|
+
evidenceGrade: input.evidenceGrade ?? "source_backed",
|
|
2699
|
+
level: input.level ?? severityLevel(input.severity)
|
|
2700
|
+
};
|
|
2701
|
+
}
|
|
2702
|
+
function normalizeViolation(input) {
|
|
2703
|
+
return {
|
|
2704
|
+
...input,
|
|
2705
|
+
level: input.level ?? severityLevel(input.severity)
|
|
2706
|
+
};
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2422
2709
|
// src/codes/source-finding-bridge.ts
|
|
2423
2710
|
function bridgeSourceViolation(input) {
|
|
2424
2711
|
const ruleId = input.canonicalRuleId ?? input.violation.rule;
|
|
@@ -2591,6 +2878,31 @@ export {
|
|
|
2591
2878
|
projectSupersededImportPathPreferences,
|
|
2592
2879
|
compileComponentFacts,
|
|
2593
2880
|
bridgeSourceViolation,
|
|
2594
|
-
bridgeSourceViolations
|
|
2881
|
+
bridgeSourceViolations,
|
|
2882
|
+
factLocationSchema,
|
|
2883
|
+
findingReplacePropValueFixSchema,
|
|
2884
|
+
findingReplaceStyleValueFixSchema,
|
|
2885
|
+
findingReplaceImportFixSchema,
|
|
2886
|
+
findingReplaceComponentFixSchema,
|
|
2887
|
+
findingReplaceClassTokenFixSchema,
|
|
2888
|
+
findingFixSchema,
|
|
2889
|
+
factEvidenceSchema,
|
|
2890
|
+
findingSchema,
|
|
2891
|
+
violationSchema,
|
|
2892
|
+
fixSchema,
|
|
2893
|
+
validatorResultSchema,
|
|
2894
|
+
governanceVerdictMetadataSchema,
|
|
2895
|
+
governanceVerdictSchema,
|
|
2896
|
+
suppressionDirectiveSchema,
|
|
2897
|
+
agentPlanSchema,
|
|
2898
|
+
agentFindingSchema,
|
|
2899
|
+
AGENT_FORMAT_SCHEMA_VERSION,
|
|
2900
|
+
agentIntegritySchema,
|
|
2901
|
+
agentFormatSchema,
|
|
2902
|
+
agentErrorEnvelopeSchema,
|
|
2903
|
+
agentOutputSchema,
|
|
2904
|
+
normalizeSeverity,
|
|
2905
|
+
normalizeFinding,
|
|
2906
|
+
normalizeViolation
|
|
2595
2907
|
};
|
|
2596
|
-
//# sourceMappingURL=chunk-
|
|
2908
|
+
//# sourceMappingURL=chunk-UUREQ4HD.js.map
|