@code-pushup/models
Advanced tools
Comparing version 0.4.5 to 0.5.0
17
index.js
@@ -121,3 +121,3 @@ // packages/models/src/lib/category-config.ts | ||
slug: slugSchema('Human-readable unique ID, e.g. "performance"'), | ||
refs: z.array(refSchema).refine( | ||
refs: z.array(refSchema).min(1).refine( | ||
(refs) => !duplicateCheckFn(refs), | ||
@@ -127,3 +127,5 @@ (refs) => ({ | ||
}) | ||
) | ||
).refine(hasWeightedRefsInCategories, () => ({ | ||
message: `In a category there has to be at least one ref with weight > 0` | ||
})) | ||
}, | ||
@@ -137,2 +139,5 @@ { description } | ||
); | ||
function hasWeightedRefsInCategories(categoryRefs) { | ||
return categoryRefs.reduce((acc, { weight }) => weight + acc, 0) !== 0; | ||
} | ||
@@ -435,6 +440,6 @@ // packages/models/src/lib/category-config.ts | ||
description: "Categorization of individual audits" | ||
}).refine( | ||
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg), | ||
(categoryCfg) => ({ | ||
message: duplicateSlugCategoriesErrorMsg(categoryCfg) | ||
}).min(1).refine( | ||
(categories) => !getDuplicateSlugCategories(categories), | ||
(categories) => ({ | ||
message: duplicateSlugCategoriesErrorMsg(categories) | ||
}) | ||
@@ -441,0 +446,0 @@ ) |
{ | ||
"name": "@code-pushup/models", | ||
"version": "0.4.5", | ||
"version": "0.5.0", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "zod": "^3.22.1", |
@@ -24,3 +24,3 @@ import { z } from 'zod'; | ||
slug: z.ZodString; | ||
refs: z.ZodEffects<z.ZodArray<z.ZodObject<{ | ||
refs: z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodObject<{ | ||
slug: z.ZodString; | ||
@@ -50,2 +50,12 @@ weight: z.ZodNumber; | ||
plugin: string; | ||
}[]>, { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}[], { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}[]>; | ||
@@ -52,0 +62,0 @@ isBinary: z.ZodOptional<z.ZodBoolean>; |
@@ -111,3 +111,3 @@ import { z } from 'zod'; | ||
slug: z.ZodString; | ||
refs: z.ZodEffects<z.ZodArray<T, "many">, T["_output"][], T["_input"][]>; | ||
refs: z.ZodEffects<z.ZodEffects<z.ZodArray<T, "many">, T["_output"][], T["_input"][]>, T["_output"][], T["_input"][]>; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -114,0 +114,0 @@ slug: string; |
@@ -29,3 +29,3 @@ import { z } from 'zod'; | ||
slug: z.ZodString; | ||
refs: z.ZodEffects<z.ZodArray<z.ZodObject<{ | ||
refs: z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodObject<{ | ||
slug: z.ZodString; | ||
@@ -45,2 +45,8 @@ weight: z.ZodNumber; | ||
weight: number; | ||
}[]>, { | ||
slug: string; | ||
weight: number; | ||
}[], { | ||
slug: string; | ||
weight: number; | ||
}[]>; | ||
@@ -72,3 +78,3 @@ title: z.ZodString; | ||
slug: z.ZodString; | ||
refs: z.ZodEffects<z.ZodArray<z.ZodObject<{ | ||
refs: z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodObject<{ | ||
slug: z.ZodString; | ||
@@ -88,2 +94,8 @@ weight: z.ZodNumber; | ||
weight: number; | ||
}[]>, { | ||
slug: string; | ||
weight: number; | ||
}[], { | ||
slug: string; | ||
weight: number; | ||
}[]>; | ||
@@ -90,0 +102,0 @@ title: z.ZodString; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
779441
10302