design-constraint-validator 2.0.1 → 2.2.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.
Files changed (118) hide show
  1. package/README.md +89 -23
  2. package/cli/commands/build.d.ts.map +1 -1
  3. package/cli/commands/build.js +32 -24
  4. package/cli/commands/build.ts +26 -17
  5. package/cli/commands/graph.d.ts.map +1 -1
  6. package/cli/commands/graph.js +35 -18
  7. package/cli/commands/graph.ts +30 -17
  8. package/cli/commands/patch-apply.d.ts.map +1 -1
  9. package/cli/commands/patch-apply.js +4 -1
  10. package/cli/commands/patch-apply.ts +4 -1
  11. package/cli/commands/set.d.ts.map +1 -1
  12. package/cli/commands/set.js +18 -19
  13. package/cli/commands/set.ts +19 -19
  14. package/cli/commands/utils.d.ts +1 -0
  15. package/cli/commands/utils.d.ts.map +1 -1
  16. package/cli/commands/utils.js +20 -1
  17. package/cli/commands/utils.ts +23 -1
  18. package/cli/commands/validate.d.ts.map +1 -1
  19. package/cli/commands/validate.js +45 -23
  20. package/cli/commands/validate.ts +47 -26
  21. package/cli/commands/why.d.ts.map +1 -1
  22. package/cli/commands/why.js +22 -10
  23. package/cli/commands/why.ts +20 -9
  24. package/cli/config-schema.d.ts +171 -166
  25. package/cli/config-schema.d.ts.map +1 -1
  26. package/cli/config-schema.js +29 -7
  27. package/cli/config-schema.ts +31 -7
  28. package/cli/config.d.ts.map +1 -1
  29. package/cli/config.js +8 -2
  30. package/cli/config.ts +8 -2
  31. package/cli/constraint-registry.d.ts +16 -0
  32. package/cli/constraint-registry.d.ts.map +1 -1
  33. package/cli/constraint-registry.js +115 -44
  34. package/cli/constraint-registry.ts +118 -47
  35. package/cli/cross-axis-loader.d.ts +62 -0
  36. package/cli/cross-axis-loader.d.ts.map +1 -1
  37. package/cli/cross-axis-loader.js +186 -31
  38. package/cli/cross-axis-loader.ts +199 -24
  39. package/cli/dcv.js +31 -25
  40. package/cli/dcv.ts +31 -21
  41. package/cli/json-output.d.ts +3 -1
  42. package/cli/json-output.d.ts.map +1 -1
  43. package/cli/json-output.js +11 -4
  44. package/cli/json-output.ts +13 -4
  45. package/cli/types.d.ts +21 -9
  46. package/cli/types.d.ts.map +1 -1
  47. package/cli/types.ts +25 -10
  48. package/cli/validate-api.d.ts +40 -0
  49. package/cli/validate-api.d.ts.map +1 -0
  50. package/cli/validate-api.js +90 -0
  51. package/cli/validate-api.ts +131 -0
  52. package/core/breakpoints.d.ts +8 -2
  53. package/core/breakpoints.d.ts.map +1 -1
  54. package/core/breakpoints.js +24 -3
  55. package/core/breakpoints.ts +22 -3
  56. package/core/color.js +4 -4
  57. package/core/color.ts +4 -4
  58. package/core/constraints/cross-axis.d.ts.map +1 -1
  59. package/core/constraints/cross-axis.js +37 -9
  60. package/core/constraints/cross-axis.ts +37 -9
  61. package/core/constraints/monotonic-lightness.d.ts.map +1 -1
  62. package/core/constraints/monotonic-lightness.js +9 -5
  63. package/core/constraints/monotonic-lightness.ts +9 -4
  64. package/core/constraints/monotonic.d.ts.map +1 -1
  65. package/core/constraints/monotonic.js +32 -8
  66. package/core/constraints/monotonic.ts +29 -8
  67. package/core/constraints/threshold.d.ts.map +1 -1
  68. package/core/constraints/threshold.js +24 -4
  69. package/core/constraints/threshold.ts +23 -4
  70. package/core/constraints/wcag.d.ts.map +1 -1
  71. package/core/constraints/wcag.js +7 -1
  72. package/core/constraints/wcag.ts +7 -1
  73. package/core/dtcg.d.ts +38 -0
  74. package/core/dtcg.d.ts.map +1 -0
  75. package/core/dtcg.js +88 -0
  76. package/core/dtcg.ts +102 -0
  77. package/core/engine.d.ts +6 -0
  78. package/core/engine.d.ts.map +1 -1
  79. package/core/engine.ts +7 -0
  80. package/core/flatten.d.ts +5 -3
  81. package/core/flatten.d.ts.map +1 -1
  82. package/core/flatten.js +32 -10
  83. package/core/flatten.ts +48 -16
  84. package/core/image-export.d.ts.map +1 -1
  85. package/core/image-export.js +10 -7
  86. package/core/image-export.ts +9 -6
  87. package/core/index.d.ts +2 -0
  88. package/core/index.d.ts.map +1 -1
  89. package/core/index.js +4 -0
  90. package/core/index.ts +6 -0
  91. package/core/poset.d.ts +6 -1
  92. package/core/poset.d.ts.map +1 -1
  93. package/core/poset.js +7 -2
  94. package/core/poset.ts +7 -2
  95. package/core/why.d.ts +1 -1
  96. package/core/why.d.ts.map +1 -1
  97. package/core/why.ts +1 -1
  98. package/mcp/contracts.d.ts +1561 -0
  99. package/mcp/contracts.d.ts.map +1 -0
  100. package/mcp/contracts.js +74 -0
  101. package/mcp/contracts.ts +105 -0
  102. package/mcp/index.d.ts +11 -0
  103. package/mcp/index.d.ts.map +1 -0
  104. package/mcp/index.js +35 -0
  105. package/mcp/index.ts +97 -0
  106. package/mcp/insights.d.ts +94 -0
  107. package/mcp/insights.d.ts.map +1 -0
  108. package/mcp/insights.js +445 -0
  109. package/mcp/insights.ts +541 -0
  110. package/mcp/tools.d.ts +63 -0
  111. package/mcp/tools.d.ts.map +1 -0
  112. package/mcp/tools.js +299 -0
  113. package/mcp/tools.ts +431 -0
  114. package/package.json +36 -26
  115. package/server.json +21 -0
  116. package/cli/constraints-loader.d.ts.map +0 -1
  117. package/cli/engine-helpers.d.ts.map +0 -1
  118. package/core/cross-axis-config.d.ts.map +0 -1
@@ -4,232 +4,237 @@ export declare const WcagRuleSchema: z.ZodObject<{
4
4
  background: z.ZodString;
5
5
  ratio: z.ZodOptional<z.ZodNumber>;
6
6
  description: z.ZodOptional<z.ZodString>;
7
- }, "strip", z.ZodTypeAny, {
7
+ backdrop: z.ZodOptional<z.ZodString>;
8
+ }, "strict", z.ZodTypeAny, {
8
9
  foreground: string;
9
10
  background: string;
10
11
  description?: string | undefined;
11
12
  ratio?: number | undefined;
13
+ backdrop?: string | undefined;
12
14
  }, {
13
15
  foreground: string;
14
16
  background: string;
15
17
  description?: string | undefined;
16
18
  ratio?: number | undefined;
19
+ backdrop?: string | undefined;
20
+ }>;
21
+ export declare const ThresholdRuleSchema: z.ZodObject<{
22
+ id: z.ZodString;
23
+ op: z.ZodEnum<["<=", ">="]>;
24
+ valuePx: z.ZodNumber;
25
+ where: z.ZodOptional<z.ZodString>;
26
+ level: z.ZodOptional<z.ZodEnum<["error", "warn"]>>;
27
+ }, "strict", z.ZodTypeAny, {
28
+ id: string;
29
+ op: "<=" | ">=";
30
+ valuePx: number;
31
+ where?: string | undefined;
32
+ level?: "error" | "warn" | undefined;
33
+ }, {
34
+ id: string;
35
+ op: "<=" | ">=";
36
+ valuePx: number;
37
+ where?: string | undefined;
38
+ level?: "error" | "warn" | undefined;
17
39
  }>;
18
40
  export declare const ConstraintsSchema: z.ZodObject<{
41
+ enableBuiltInWcagDefaults: z.ZodOptional<z.ZodBoolean>;
42
+ enableBuiltInThreshold: z.ZodOptional<z.ZodBoolean>;
19
43
  wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
44
  foreground: z.ZodString;
21
45
  background: z.ZodString;
22
46
  ratio: z.ZodOptional<z.ZodNumber>;
23
47
  description: z.ZodOptional<z.ZodString>;
24
- }, "strip", z.ZodTypeAny, {
48
+ backdrop: z.ZodOptional<z.ZodString>;
49
+ }, "strict", z.ZodTypeAny, {
25
50
  foreground: string;
26
51
  background: string;
27
52
  description?: string | undefined;
28
53
  ratio?: number | undefined;
54
+ backdrop?: string | undefined;
29
55
  }, {
30
56
  foreground: string;
31
57
  background: string;
32
58
  description?: string | undefined;
33
59
  ratio?: number | undefined;
60
+ backdrop?: string | undefined;
34
61
  }>, "many">>;
35
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
36
- wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
37
- foreground: z.ZodString;
38
- background: z.ZodString;
39
- ratio: z.ZodOptional<z.ZodNumber>;
40
- description: z.ZodOptional<z.ZodString>;
41
- }, "strip", z.ZodTypeAny, {
42
- foreground: string;
43
- background: string;
44
- description?: string | undefined;
45
- ratio?: number | undefined;
62
+ thresholds: z.ZodOptional<z.ZodArray<z.ZodObject<{
63
+ id: z.ZodString;
64
+ op: z.ZodEnum<["<=", ">="]>;
65
+ valuePx: z.ZodNumber;
66
+ where: z.ZodOptional<z.ZodString>;
67
+ level: z.ZodOptional<z.ZodEnum<["error", "warn"]>>;
68
+ }, "strict", z.ZodTypeAny, {
69
+ id: string;
70
+ op: "<=" | ">=";
71
+ valuePx: number;
72
+ where?: string | undefined;
73
+ level?: "error" | "warn" | undefined;
46
74
  }, {
47
- foreground: string;
48
- background: string;
49
- description?: string | undefined;
50
- ratio?: number | undefined;
75
+ id: string;
76
+ op: "<=" | ">=";
77
+ valuePx: number;
78
+ where?: string | undefined;
79
+ level?: "error" | "warn" | undefined;
51
80
  }>, "many">>;
52
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
53
- wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
54
- foreground: z.ZodString;
55
- background: z.ZodString;
56
- ratio: z.ZodOptional<z.ZodNumber>;
57
- description: z.ZodOptional<z.ZodString>;
58
- }, "strip", z.ZodTypeAny, {
81
+ }, "strict", z.ZodTypeAny, {
82
+ enableBuiltInWcagDefaults?: boolean | undefined;
83
+ enableBuiltInThreshold?: boolean | undefined;
84
+ wcag?: {
59
85
  foreground: string;
60
86
  background: string;
61
87
  description?: string | undefined;
62
88
  ratio?: number | undefined;
63
- }, {
89
+ backdrop?: string | undefined;
90
+ }[] | undefined;
91
+ thresholds?: {
92
+ id: string;
93
+ op: "<=" | ">=";
94
+ valuePx: number;
95
+ where?: string | undefined;
96
+ level?: "error" | "warn" | undefined;
97
+ }[] | undefined;
98
+ }, {
99
+ enableBuiltInWcagDefaults?: boolean | undefined;
100
+ enableBuiltInThreshold?: boolean | undefined;
101
+ wcag?: {
64
102
  foreground: string;
65
103
  background: string;
66
104
  description?: string | undefined;
67
105
  ratio?: number | undefined;
68
- }>, "many">>;
69
- }, z.ZodTypeAny, "passthrough">>;
106
+ backdrop?: string | undefined;
107
+ }[] | undefined;
108
+ thresholds?: {
109
+ id: string;
110
+ op: "<=" | ">=";
111
+ valuePx: number;
112
+ where?: string | undefined;
113
+ level?: "error" | "warn" | undefined;
114
+ }[] | undefined;
115
+ }>;
70
116
  export declare const DcvConfigSchema: z.ZodObject<{
117
+ $schema: z.ZodOptional<z.ZodString>;
71
118
  version: z.ZodOptional<z.ZodString>;
72
119
  constraints: z.ZodOptional<z.ZodObject<{
120
+ enableBuiltInWcagDefaults: z.ZodOptional<z.ZodBoolean>;
121
+ enableBuiltInThreshold: z.ZodOptional<z.ZodBoolean>;
73
122
  wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
74
123
  foreground: z.ZodString;
75
124
  background: z.ZodString;
76
125
  ratio: z.ZodOptional<z.ZodNumber>;
77
126
  description: z.ZodOptional<z.ZodString>;
78
- }, "strip", z.ZodTypeAny, {
127
+ backdrop: z.ZodOptional<z.ZodString>;
128
+ }, "strict", z.ZodTypeAny, {
79
129
  foreground: string;
80
130
  background: string;
81
131
  description?: string | undefined;
82
132
  ratio?: number | undefined;
133
+ backdrop?: string | undefined;
83
134
  }, {
84
135
  foreground: string;
85
136
  background: string;
86
137
  description?: string | undefined;
87
138
  ratio?: number | undefined;
139
+ backdrop?: string | undefined;
88
140
  }>, "many">>;
89
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
90
- wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
91
- foreground: z.ZodString;
92
- background: z.ZodString;
93
- ratio: z.ZodOptional<z.ZodNumber>;
94
- description: z.ZodOptional<z.ZodString>;
95
- }, "strip", z.ZodTypeAny, {
96
- foreground: string;
97
- background: string;
98
- description?: string | undefined;
99
- ratio?: number | undefined;
141
+ thresholds: z.ZodOptional<z.ZodArray<z.ZodObject<{
142
+ id: z.ZodString;
143
+ op: z.ZodEnum<["<=", ">="]>;
144
+ valuePx: z.ZodNumber;
145
+ where: z.ZodOptional<z.ZodString>;
146
+ level: z.ZodOptional<z.ZodEnum<["error", "warn"]>>;
147
+ }, "strict", z.ZodTypeAny, {
148
+ id: string;
149
+ op: "<=" | ">=";
150
+ valuePx: number;
151
+ where?: string | undefined;
152
+ level?: "error" | "warn" | undefined;
100
153
  }, {
101
- foreground: string;
102
- background: string;
103
- description?: string | undefined;
104
- ratio?: number | undefined;
154
+ id: string;
155
+ op: "<=" | ">=";
156
+ valuePx: number;
157
+ where?: string | undefined;
158
+ level?: "error" | "warn" | undefined;
105
159
  }>, "many">>;
106
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
107
- wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
108
- foreground: z.ZodString;
109
- background: z.ZodString;
110
- ratio: z.ZodOptional<z.ZodNumber>;
111
- description: z.ZodOptional<z.ZodString>;
112
- }, "strip", z.ZodTypeAny, {
113
- foreground: string;
114
- background: string;
115
- description?: string | undefined;
116
- ratio?: number | undefined;
117
- }, {
118
- foreground: string;
119
- background: string;
120
- description?: string | undefined;
121
- ratio?: number | undefined;
122
- }>, "many">>;
123
- }, z.ZodTypeAny, "passthrough">>>;
124
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
125
- version: z.ZodOptional<z.ZodString>;
126
- constraints: z.ZodOptional<z.ZodObject<{
127
- wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
128
- foreground: z.ZodString;
129
- background: z.ZodString;
130
- ratio: z.ZodOptional<z.ZodNumber>;
131
- description: z.ZodOptional<z.ZodString>;
132
- }, "strip", z.ZodTypeAny, {
133
- foreground: string;
134
- background: string;
135
- description?: string | undefined;
136
- ratio?: number | undefined;
137
- }, {
160
+ }, "strict", z.ZodTypeAny, {
161
+ enableBuiltInWcagDefaults?: boolean | undefined;
162
+ enableBuiltInThreshold?: boolean | undefined;
163
+ wcag?: {
138
164
  foreground: string;
139
165
  background: string;
140
166
  description?: string | undefined;
141
167
  ratio?: number | undefined;
142
- }>, "many">>;
143
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
144
- wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
145
- foreground: z.ZodString;
146
- background: z.ZodString;
147
- ratio: z.ZodOptional<z.ZodNumber>;
148
- description: z.ZodOptional<z.ZodString>;
149
- }, "strip", z.ZodTypeAny, {
150
- foreground: string;
151
- background: string;
152
- description?: string | undefined;
153
- ratio?: number | undefined;
154
- }, {
155
- foreground: string;
156
- background: string;
157
- description?: string | undefined;
158
- ratio?: number | undefined;
159
- }>, "many">>;
160
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
161
- wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
162
- foreground: z.ZodString;
163
- background: z.ZodString;
164
- ratio: z.ZodOptional<z.ZodNumber>;
165
- description: z.ZodOptional<z.ZodString>;
166
- }, "strip", z.ZodTypeAny, {
167
- foreground: string;
168
- background: string;
169
- description?: string | undefined;
170
- ratio?: number | undefined;
171
- }, {
172
- foreground: string;
173
- background: string;
174
- description?: string | undefined;
175
- ratio?: number | undefined;
176
- }>, "many">>;
177
- }, z.ZodTypeAny, "passthrough">>>;
178
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
179
- version: z.ZodOptional<z.ZodString>;
180
- constraints: z.ZodOptional<z.ZodObject<{
181
- wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
182
- foreground: z.ZodString;
183
- background: z.ZodString;
184
- ratio: z.ZodOptional<z.ZodNumber>;
185
- description: z.ZodOptional<z.ZodString>;
186
- }, "strip", z.ZodTypeAny, {
187
- foreground: string;
188
- background: string;
189
- description?: string | undefined;
190
- ratio?: number | undefined;
191
- }, {
192
- foreground: string;
193
- background: string;
194
- description?: string | undefined;
195
- ratio?: number | undefined;
196
- }>, "many">>;
197
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
198
- wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
199
- foreground: z.ZodString;
200
- background: z.ZodString;
201
- ratio: z.ZodOptional<z.ZodNumber>;
202
- description: z.ZodOptional<z.ZodString>;
203
- }, "strip", z.ZodTypeAny, {
204
- foreground: string;
205
- background: string;
206
- description?: string | undefined;
207
- ratio?: number | undefined;
208
- }, {
209
- foreground: string;
210
- background: string;
211
- description?: string | undefined;
212
- ratio?: number | undefined;
213
- }>, "many">>;
214
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
215
- wcag: z.ZodOptional<z.ZodArray<z.ZodObject<{
216
- foreground: z.ZodString;
217
- background: z.ZodString;
218
- ratio: z.ZodOptional<z.ZodNumber>;
219
- description: z.ZodOptional<z.ZodString>;
220
- }, "strip", z.ZodTypeAny, {
221
- foreground: string;
222
- background: string;
223
- description?: string | undefined;
224
- ratio?: number | undefined;
225
- }, {
226
- foreground: string;
227
- background: string;
228
- description?: string | undefined;
229
- ratio?: number | undefined;
230
- }>, "many">>;
231
- }, z.ZodTypeAny, "passthrough">>>;
232
- }, z.ZodTypeAny, "passthrough">>;
168
+ backdrop?: string | undefined;
169
+ }[] | undefined;
170
+ thresholds?: {
171
+ id: string;
172
+ op: "<=" | ">=";
173
+ valuePx: number;
174
+ where?: string | undefined;
175
+ level?: "error" | "warn" | undefined;
176
+ }[] | undefined;
177
+ }, {
178
+ enableBuiltInWcagDefaults?: boolean | undefined;
179
+ enableBuiltInThreshold?: boolean | undefined;
180
+ wcag?: {
181
+ foreground: string;
182
+ background: string;
183
+ description?: string | undefined;
184
+ ratio?: number | undefined;
185
+ backdrop?: string | undefined;
186
+ }[] | undefined;
187
+ thresholds?: {
188
+ id: string;
189
+ op: "<=" | ">=";
190
+ valuePx: number;
191
+ where?: string | undefined;
192
+ level?: "error" | "warn" | undefined;
193
+ }[] | undefined;
194
+ }>>;
195
+ }, "strict", z.ZodTypeAny, {
196
+ $schema?: string | undefined;
197
+ version?: string | undefined;
198
+ constraints?: {
199
+ enableBuiltInWcagDefaults?: boolean | undefined;
200
+ enableBuiltInThreshold?: boolean | undefined;
201
+ wcag?: {
202
+ foreground: string;
203
+ background: string;
204
+ description?: string | undefined;
205
+ ratio?: number | undefined;
206
+ backdrop?: string | undefined;
207
+ }[] | undefined;
208
+ thresholds?: {
209
+ id: string;
210
+ op: "<=" | ">=";
211
+ valuePx: number;
212
+ where?: string | undefined;
213
+ level?: "error" | "warn" | undefined;
214
+ }[] | undefined;
215
+ } | undefined;
216
+ }, {
217
+ $schema?: string | undefined;
218
+ version?: string | undefined;
219
+ constraints?: {
220
+ enableBuiltInWcagDefaults?: boolean | undefined;
221
+ enableBuiltInThreshold?: boolean | undefined;
222
+ wcag?: {
223
+ foreground: string;
224
+ background: string;
225
+ description?: string | undefined;
226
+ ratio?: number | undefined;
227
+ backdrop?: string | undefined;
228
+ }[] | undefined;
229
+ thresholds?: {
230
+ id: string;
231
+ op: "<=" | ">=";
232
+ valuePx: number;
233
+ where?: string | undefined;
234
+ level?: "error" | "warn" | undefined;
235
+ }[] | undefined;
236
+ } | undefined;
237
+ }>;
233
238
  export type DcvConfigParsed = z.infer<typeof DcvConfigSchema>;
234
239
  export declare function validateConfig(raw: unknown): {
235
240
  value?: DcvConfigParsed;
@@ -1 +1 @@
1
- {"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EAKzB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAEd,CAAC;AAEjB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAGZ,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,KAAK,CAAC,EAAE,eAAe,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAM3F"}
1
+ {"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;EAMhB,CAAC;AAEZ,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;EAMrB,CAAC;AAEZ,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKnB,CAAC;AAEZ,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMjB,CAAC;AAEZ,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,KAAK,CAAC,EAAE,eAAe,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAO3F"}
@@ -1,21 +1,43 @@
1
1
  import { z } from 'zod';
2
+ // Schemas are `.strict()` on purpose (TASK-037): a validator must never silently
3
+ // accept a typo'd key, because "the rule never ran" is indistinguishable from
4
+ // "the rule passed" — a false green. A misspelled block (`wcagg`), a typo'd
5
+ // field (`levle`), or an out-of-range bound is rejected loudly, not dropped.
6
+ // WCAG contrast ratios are bounded by the spec to (1:1, 21:1]: 1 means "no
7
+ // contrast required" (a no-op rule) and 21 is the maximum achievable (#000 on
8
+ // #fff). Anything outside that is a config error, not a stricter policy.
2
9
  export const WcagRuleSchema = z.object({
3
10
  foreground: z.string(),
4
11
  background: z.string(),
5
- ratio: z.number().positive().optional(),
6
- description: z.string().optional()
7
- });
12
+ ratio: z.number().finite().gt(1).max(21).optional(),
13
+ description: z.string().optional(),
14
+ backdrop: z.string().optional()
15
+ }).strict();
16
+ export const ThresholdRuleSchema = z.object({
17
+ id: z.string(),
18
+ op: z.enum(['<=', '>=']),
19
+ valuePx: z.number().finite().nonnegative(),
20
+ where: z.string().optional(),
21
+ level: z.enum(['error', 'warn']).optional()
22
+ }).strict();
8
23
  export const ConstraintsSchema = z.object({
9
- wcag: z.array(WcagRuleSchema).optional()
10
- }).passthrough();
24
+ enableBuiltInWcagDefaults: z.boolean().optional(),
25
+ enableBuiltInThreshold: z.boolean().optional(),
26
+ wcag: z.array(WcagRuleSchema).optional(),
27
+ thresholds: z.array(ThresholdRuleSchema).optional()
28
+ }).strict();
11
29
  export const DcvConfigSchema = z.object({
30
+ // `$schema` is the conventional editor-hint key; allow it so strictness does
31
+ // not punish a well-formed config, but still reject unknown top-level typos.
32
+ $schema: z.string().optional(),
12
33
  version: z.string().optional(),
13
34
  constraints: ConstraintsSchema.optional()
14
- }).passthrough();
35
+ }).strict();
15
36
  export function validateConfig(raw) {
16
37
  const res = DcvConfigSchema.safeParse(raw);
17
38
  if (!res.success) {
18
- return { errors: res.error.errors.map(e => `${e.path.join('.') || '<root>'}: ${e.message}`) };
39
+ // zod v4 renamed ZodError.errors -> .issues (the .errors getter was removed).
40
+ return { errors: res.error.issues.map((e) => `${e.path.join('.') || '<root>'}: ${e.message}`) };
19
41
  }
20
42
  return { value: res.data };
21
43
  }
@@ -1,27 +1,51 @@
1
1
  import { z } from 'zod';
2
2
 
3
+ // Schemas are `.strict()` on purpose (TASK-037): a validator must never silently
4
+ // accept a typo'd key, because "the rule never ran" is indistinguishable from
5
+ // "the rule passed" — a false green. A misspelled block (`wcagg`), a typo'd
6
+ // field (`levle`), or an out-of-range bound is rejected loudly, not dropped.
7
+
8
+ // WCAG contrast ratios are bounded by the spec to (1:1, 21:1]: 1 means "no
9
+ // contrast required" (a no-op rule) and 21 is the maximum achievable (#000 on
10
+ // #fff). Anything outside that is a config error, not a stricter policy.
3
11
  export const WcagRuleSchema = z.object({
4
12
  foreground: z.string(),
5
13
  background: z.string(),
6
- ratio: z.number().positive().optional(),
7
- description: z.string().optional()
8
- });
14
+ ratio: z.number().finite().gt(1).max(21).optional(),
15
+ description: z.string().optional(),
16
+ backdrop: z.string().optional()
17
+ }).strict();
18
+
19
+ export const ThresholdRuleSchema = z.object({
20
+ id: z.string(),
21
+ op: z.enum(['<=', '>=']),
22
+ valuePx: z.number().finite().nonnegative(),
23
+ where: z.string().optional(),
24
+ level: z.enum(['error', 'warn']).optional()
25
+ }).strict();
9
26
 
10
27
  export const ConstraintsSchema = z.object({
11
- wcag: z.array(WcagRuleSchema).optional()
12
- }).passthrough();
28
+ enableBuiltInWcagDefaults: z.boolean().optional(),
29
+ enableBuiltInThreshold: z.boolean().optional(),
30
+ wcag: z.array(WcagRuleSchema).optional(),
31
+ thresholds: z.array(ThresholdRuleSchema).optional()
32
+ }).strict();
13
33
 
14
34
  export const DcvConfigSchema = z.object({
35
+ // `$schema` is the conventional editor-hint key; allow it so strictness does
36
+ // not punish a well-formed config, but still reject unknown top-level typos.
37
+ $schema: z.string().optional(),
15
38
  version: z.string().optional(),
16
39
  constraints: ConstraintsSchema.optional()
17
- }).passthrough();
40
+ }).strict();
18
41
 
19
42
  export type DcvConfigParsed = z.infer<typeof DcvConfigSchema>;
20
43
 
21
44
  export function validateConfig(raw: unknown): { value?: DcvConfigParsed; errors?: string[] } {
22
45
  const res = DcvConfigSchema.safeParse(raw);
23
46
  if (!res.success) {
24
- return { errors: res.error.errors.map(e => `${e.path.join('.')||'<root>'}: ${e.message}`) };
47
+ // zod v4 renamed ZodError.errors -> .issues (the .errors getter was removed).
48
+ return { errors: res.error.issues.map((e) => `${e.path.join('.') || '<root>'}: ${e.message}`) };
25
49
  }
26
50
  return { value: res.data };
27
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,wBAAgB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CA6BzE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,wBAAgB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAkCzE"}
package/cli/config.js CHANGED
@@ -1,20 +1,26 @@
1
1
  import { readFileSync, existsSync } from 'node:fs';
2
+ import { basename, extname } from 'node:path';
2
3
  import { validateConfig } from './config-schema.js';
3
4
  import { ok, err } from './result.js';
4
5
  export function loadConfig(configPath) {
6
+ if (configPath && !existsSync(configPath)) {
7
+ return err(`Config file not found: ${configPath}`);
8
+ }
5
9
  const candidates = configPath ? [configPath] : [
6
10
  'dcv.config.json',
7
- 'dcv.config.js',
8
11
  '.dcvrc.json',
9
12
  'package.json'
10
13
  ];
11
14
  for (const p of candidates) {
12
15
  if (!existsSync(p))
13
16
  continue;
17
+ if (extname(p) === '.js') {
18
+ return err(`Unsupported config file ${p}: use JSON config (dcv.config.json, .dcvrc.json, or package.json "dcv").`);
19
+ }
14
20
  try {
15
21
  const rawTxt = readFileSync(p, 'utf8');
16
22
  let raw = JSON.parse(rawTxt);
17
- if (p === 'package.json' && raw && typeof raw === 'object') {
23
+ if (basename(p) === 'package.json' && raw && typeof raw === 'object') {
18
24
  const pkg = raw;
19
25
  if ('dcv' in pkg) {
20
26
  raw = pkg.dcv;
package/cli/config.ts CHANGED
@@ -1,21 +1,27 @@
1
1
  import { readFileSync, existsSync } from 'node:fs';
2
+ import { basename, extname } from 'node:path';
2
3
  import { validateConfig } from './config-schema.js';
3
4
  import { ok, err, type Result } from './result.js';
4
5
  import type { DcvConfig } from './types.js';
5
6
 
6
7
  export function loadConfig(configPath?: string): Result<DcvConfig, string> {
8
+ if (configPath && !existsSync(configPath)) {
9
+ return err(`Config file not found: ${configPath}`);
10
+ }
7
11
  const candidates = configPath ? [configPath] : [
8
12
  'dcv.config.json',
9
- 'dcv.config.js',
10
13
  '.dcvrc.json',
11
14
  'package.json'
12
15
  ];
13
16
  for (const p of candidates) {
14
17
  if (!existsSync(p)) continue;
18
+ if (extname(p) === '.js') {
19
+ return err(`Unsupported config file ${p}: use JSON config (dcv.config.json, .dcvrc.json, or package.json "dcv").`);
20
+ }
15
21
  try {
16
22
  const rawTxt = readFileSync(p, 'utf8');
17
23
  let raw: unknown = JSON.parse(rawTxt);
18
- if (p === 'package.json' && raw && typeof raw === 'object') {
24
+ if (basename(p) === 'package.json' && raw && typeof raw === 'object') {
19
25
  const pkg = raw as Record<string, unknown>;
20
26
  if ('dcv' in pkg) {
21
27
  raw = pkg.dcv;
@@ -67,6 +67,8 @@ export type AttachOptions = {
67
67
  knownIds: Set<string>;
68
68
  crossAxisDebug?: boolean;
69
69
  };
70
+ export declare const DEFAULT_WCAG_PAIRS: WcagRule[];
71
+ export declare const DEFAULT_THRESHOLDS: ThresholdRule[];
70
72
  /**
71
73
  * Discover all constraint sources for a given configuration and breakpoint.
72
74
  *
@@ -98,4 +100,18 @@ export declare function attachConstraints(engine: Engine, sources: ConstraintSou
98
100
  * @param attachOpts Attachment options
99
101
  */
100
102
  export declare function setupConstraints(engine: Engine, discoveryOpts: DiscoveryOptions, attachOpts: AttachOptions): ConstraintSource[];
103
+ /**
104
+ * Collect the token ids referenced by the active constraint sources, plus
105
+ * whether that coverage is fully enumerable.
106
+ *
107
+ * Used to detect the silent-pass case: a token file that validates with zero
108
+ * errors only because no active constraint references any of its tokens. Cross-
109
+ * axis rule ids are not enumerated here, so when any cross-axis source is present
110
+ * `coverageKnown` is false and callers must stay conservative (never claim
111
+ * "nothing was checked" when they cannot be sure).
112
+ */
113
+ export declare function collectReferencedIds(sources: ConstraintSource[]): {
114
+ ids: Set<string>;
115
+ coverageKnown: boolean;
116
+ };
101
117
  //# sourceMappingURL=constraint-registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constraint-registry.d.ts","sourceRoot":"","sources":["constraint-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAY5C,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;AAEtD,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,IAAI,GAAG,IAAI,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC/C;I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