@@ -16,7 +16,9 @@ import { filenameRegex, slugRegex } from './utils.js';
1616
1717export const tableCellValueSchema = z
1818 . union ( [ z . string ( ) , z . number ( ) , z . boolean ( ) , z . null ( ) ] )
19- . default ( null ) ;
19+ . default ( null )
20+ . meta ( { title : 'TableCellValue' } ) ;
21+
2022export type TableCellValue = z . infer < typeof tableCellValueSchema > ;
2123
2224/**
@@ -47,17 +49,23 @@ export const slugSchema = z
4749 . max ( MAX_SLUG_LENGTH , {
4850 message : `The slug can be max ${ MAX_SLUG_LENGTH } characters long` ,
4951 } )
50- . meta ( { description : 'Unique ID (human-readable, URL-safe)' } ) ;
52+ . meta ( {
53+ title : 'Slug' ,
54+ description : 'Unique ID (human-readable, URL-safe)' ,
55+ } ) ;
5156
5257/** Schema for a general description property */
5358export const descriptionSchema = z
5459 . string ( )
5560 . max ( MAX_DESCRIPTION_LENGTH )
56- . meta ( { description : 'Description (markdown)' } )
61+ . meta ( {
62+ title : 'Description' ,
63+ description : 'Description (markdown)' ,
64+ } )
5765 . optional ( ) ;
5866
5967/* Schema for a URL */
60- export const urlSchema = z . string ( ) . url ( ) ;
68+ export const urlSchema = z . string ( ) . url ( ) . meta ( { title : 'URL' } ) ;
6169
6270/** Schema for a docsUrl */
6371export const docsUrlSchema = urlSchema
@@ -79,23 +87,25 @@ export const docsUrlSchema = urlSchema
7987 }
8088 throw new ZodError ( ctx . error . issues ) ;
8189 } )
82- . meta ( { description : 'Documentation site' } ) ;
90+ . meta ( { title : 'DocsUrl' , description : 'Documentation site' } ) ;
8391
8492/** Schema for a title of a plugin, category and audit */
85- export const titleSchema = z
86- . string ( )
87- . max ( MAX_TITLE_LENGTH )
88- . meta ( { description : 'Descriptive name' } ) ;
93+ export const titleSchema = z . string ( ) . max ( MAX_TITLE_LENGTH ) . meta ( {
94+ title : 'Title' ,
95+ description : 'Descriptive name' ,
96+ } ) ;
8997
9098/** Schema for score of audit, category or group */
91- export const scoreSchema = z
92- . number ( )
93- . min ( 0 )
94- . max ( 1 )
95- . meta ( { description : 'Value between 0 and 1' } ) ;
99+ export const scoreSchema = z . number ( ) . min ( 0 ) . max ( 1 ) . meta ( {
100+ title : 'Score' ,
101+ description : 'Value between 0 and 1' ,
102+ } ) ;
96103
97104/** Schema for a property indicating whether an entity is filtered out */
98- export const isSkippedSchema = z . boolean ( ) . optional ( ) ;
105+ export const isSkippedSchema = z
106+ . boolean ( )
107+ . optional ( )
108+ . meta ( { title : 'IsSkipped' } ) ;
99109
100110/**
101111 * Used for categories, plugins and audits
@@ -136,7 +146,8 @@ export function metaSchema(options?: {
136146export const filePathSchema = z
137147 . string ( )
138148 . trim ( )
139- . min ( 1 , { message : 'The path is invalid' } ) ;
149+ . min ( 1 , { message : 'The path is invalid' } )
150+ . meta ( { title : 'FilePath' } ) ;
140151
141152/**
142153 * Regex for glob patterns - validates file paths and glob patterns
@@ -149,11 +160,9 @@ export const globPathSchema = z
149160 . string ( )
150161 . trim ( )
151162 . min ( 1 , { message : 'The glob pattern is invalid' } )
152- . regex ( globRegex , {
153- message :
154- 'The path must be a valid file path or glob pattern (supports *, **, {}, [], !, ?)' ,
155- } )
163+ . regex ( globRegex )
156164 . meta ( {
165+ title : 'GlobPath' ,
157166 description :
158167 'Schema for a glob pattern (supports wildcards like *, **, {}, !, etc.)' ,
159168 } ) ;
@@ -162,15 +171,21 @@ export const globPathSchema = z
162171export const fileNameSchema = z
163172 . string ( )
164173 . trim ( )
165- . regex ( filenameRegex , {
166- message : `The filename has to be valid` ,
167- } )
168- . min ( 1 , { message : 'The file name is invalid' } ) ;
174+ . regex ( filenameRegex )
175+ . min ( 1 )
176+ . meta ( { title : 'FileName' } ) ;
169177
170178/** Schema for a positiveInt */
171- export const positiveIntSchema = z . number ( ) . int ( ) . positive ( ) ;
179+ export const positiveIntSchema = z
180+ . number ( )
181+ . int ( )
182+ . positive ( )
183+ . meta ( { title : 'PositiveInt' } ) ;
172184
173- export const nonnegativeNumberSchema = z . number ( ) . nonnegative ( ) ;
185+ export const nonnegativeNumberSchema = z
186+ . number ( )
187+ . nonnegative ( )
188+ . meta ( { title : 'NonnegativeNumber' } ) ;
174189
175190export function packageVersionSchema <
176191 TRequired extends boolean = false ,
@@ -195,11 +210,15 @@ export function packageVersionSchema<
195210/** Schema for a binary score threshold */
196211export const scoreTargetSchema = nonnegativeNumberSchema
197212 . max ( 1 )
198- . meta ( { description : 'Pass/fail score threshold (0-1)' } )
213+ . meta ( {
214+ title : 'ScoreTarget' ,
215+ description : 'Pass/fail score threshold (0-1)' ,
216+ } )
199217 . optional ( ) ;
200218
201219/** Schema for a weight */
202220export const weightSchema = nonnegativeNumberSchema . meta ( {
221+ title : 'Weight' ,
203222 description :
204223 'Coefficient for the given score (use weight 0 if only for display)' ,
205224} ) ;
@@ -243,9 +262,10 @@ export function scorableSchema<T extends ReturnType<typeof weightedRefSchema>>(
243262 . describe ( description ) ;
244263}
245264
246- export const materialIconSchema = z
247- . enum ( MATERIAL_ICONS )
248- . meta ( { description : 'Icon from VSCode Material Icons extension' } ) ;
265+ export const materialIconSchema = z . enum ( MATERIAL_ICONS ) . meta ( {
266+ title : 'MaterialIcon' ,
267+ description : 'Icon from VSCode Material Icons extension' ,
268+ } ) ;
249269export type MaterialIcon = z . infer < typeof materialIconSchema > ;
250270
251271type Ref = { weight : number } ;
@@ -263,4 +283,7 @@ export const filePositionSchema = z
263283 endLine : positiveIntSchema . meta ( { description : 'End line' } ) . optional ( ) ,
264284 endColumn : positiveIntSchema . meta ( { description : 'End column' } ) . optional ( ) ,
265285 } )
266- . meta ( { description : 'Location in file' } ) ;
286+ . meta ( {
287+ title : 'FilePosition' ,
288+ description : 'Location in file' ,
289+ } ) ;
0 commit comments