@code-pushup/models
Advanced tools
Comparing version 0.5.0 to 0.5.2
58
index.js
@@ -185,2 +185,19 @@ // packages/models/src/lib/category-config.ts | ||
} | ||
var categoriesSchema = z2.array(categoryConfigSchema, { | ||
description: "Categorization of individual audits" | ||
}).min(1).refine( | ||
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg), | ||
(categoryCfg) => ({ | ||
message: duplicateSlugCategoriesErrorMsg(categoryCfg) | ||
}) | ||
); | ||
function duplicateSlugCategoriesErrorMsg(categories) { | ||
const duplicateStringSlugs = getDuplicateSlugCategories(categories); | ||
return `In the categories, the following slugs are duplicated: ${errorItems( | ||
duplicateStringSlugs | ||
)}`; | ||
} | ||
function getDuplicateSlugCategories(categories) { | ||
return hasDuplicateStrings(categories.map(({ slug }) => slug)); | ||
} | ||
@@ -194,6 +211,6 @@ // packages/models/src/lib/core-config.ts | ||
var persistConfigSchema = z3.object({ | ||
outputDir: filePathSchema("Artifacts folder"), | ||
filename: fileNameSchema("Artifacts file name (without extension)").default( | ||
"report" | ||
), | ||
outputDir: filePathSchema("Artifacts folder").optional(), | ||
filename: fileNameSchema( | ||
"Artifacts file name (without extension)" | ||
).optional(), | ||
format: z3.array(formatSchema).default(["json"]).optional() | ||
@@ -434,13 +451,6 @@ // @TODO remove default or optional value and otherwise it will not set defaults. | ||
/** portal configuration for persisting results */ | ||
persist: persistConfigSchema, | ||
persist: persistConfigSchema.optional(), | ||
/** portal configuration for uploading results */ | ||
upload: uploadConfigSchema.optional(), | ||
categories: z11.array(categoryConfigSchema, { | ||
description: "Categorization of individual audits" | ||
}).min(1).refine( | ||
(categories) => !getDuplicateSlugCategories(categories), | ||
(categories) => ({ | ||
message: duplicateSlugCategoriesErrorMsg(categories) | ||
}) | ||
) | ||
categories: categoriesSchema | ||
}); | ||
@@ -496,12 +506,8 @@ var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema); | ||
} | ||
function duplicateSlugCategoriesErrorMsg(categories) { | ||
const duplicateStringSlugs = getDuplicateSlugCategories(categories); | ||
return `In the categories, the following slugs are duplicated: ${errorItems( | ||
duplicateStringSlugs | ||
)}`; | ||
} | ||
function getDuplicateSlugCategories(categories) { | ||
return hasDuplicateStrings(categories.map(({ slug }) => slug)); | ||
} | ||
// packages/models/src/lib/implementation/constants.ts | ||
var PERSIST_OUTPUT_DIR = ".code-pushup"; | ||
var PERSIST_FORMAT = ["json"]; | ||
var PERSIST_FILENAME = "report"; | ||
// packages/models/src/lib/report.ts | ||
@@ -541,2 +547,5 @@ import { z as z12 } from "zod"; | ||
MAX_TITLE_LENGTH, | ||
PERSIST_FILENAME, | ||
PERSIST_FORMAT, | ||
PERSIST_OUTPUT_DIR, | ||
auditGroupSchema, | ||
@@ -549,2 +558,4 @@ auditOutputsSchema, | ||
coreConfigSchema, | ||
fileNameSchema, | ||
filePathSchema, | ||
formatSchema, | ||
@@ -561,3 +572,4 @@ materialIconSchema, | ||
unrefinedCoreConfigSchema, | ||
uploadConfigSchema | ||
uploadConfigSchema, | ||
urlSchema | ||
}; |
{ | ||
"name": "@code-pushup/models", | ||
"version": "0.5.0", | ||
"version": "0.5.2", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "zod": "^3.22.1", |
export { CategoryConfig, CategoryRef, categoryConfigSchema, categoryRefSchema, } from './lib/category-config'; | ||
export { CoreConfig, coreConfigSchema, refineCoreConfig, unrefinedCoreConfigSchema, } from './lib/core-config'; | ||
export { MAX_DESCRIPTION_LENGTH, MAX_SLUG_LENGTH, MAX_TITLE_LENGTH, } from './lib/implementation/limits'; | ||
export { materialIconSchema } from './lib/implementation/schemas'; | ||
export { PERSIST_FILENAME, PERSIST_OUTPUT_DIR, PERSIST_FORMAT, } from './lib/implementation/constants'; | ||
export { materialIconSchema, filePathSchema, fileNameSchema, urlSchema, } from './lib/implementation/schemas'; | ||
export { Format, PersistConfig, formatSchema, persistConfigSchema, } from './lib/persist-config'; | ||
@@ -6,0 +7,0 @@ export { PluginConfig, pluginConfigSchema, PluginMeta, } from './lib/plugin-config'; |
@@ -88,1 +88,92 @@ import { z } from 'zod'; | ||
export declare function duplicateRefsInCategoryMetricsErrorMsg(metrics: CategoryRef[]): string; | ||
export declare const categoriesSchema: z.ZodEffects<z.ZodArray<z.ZodObject<{ | ||
description: z.ZodOptional<z.ZodString>; | ||
title: z.ZodString; | ||
docsUrl: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodString]>; | ||
slug: z.ZodString; | ||
refs: z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodObject<{ | ||
slug: z.ZodString; | ||
weight: z.ZodNumber; | ||
type: z.ZodEnum<["audit", "group"]>; | ||
plugin: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}, { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}>, "many">, { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}[], { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}[]>, { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}[], { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}[]>; | ||
isBinary: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
title: string; | ||
slug: string; | ||
refs: { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}[]; | ||
description?: string | undefined; | ||
docsUrl?: string | undefined; | ||
isBinary?: boolean | undefined; | ||
}, { | ||
title: string; | ||
slug: string; | ||
refs: { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}[]; | ||
description?: string | undefined; | ||
docsUrl?: string | undefined; | ||
isBinary?: boolean | undefined; | ||
}>, "many">, { | ||
title: string; | ||
slug: string; | ||
refs: { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}[]; | ||
description?: string | undefined; | ||
docsUrl?: string | undefined; | ||
isBinary?: boolean | undefined; | ||
}[], { | ||
title: string; | ||
slug: string; | ||
refs: { | ||
type: "audit" | "group"; | ||
slug: string; | ||
weight: number; | ||
plugin: string; | ||
}[]; | ||
description?: string | undefined; | ||
docsUrl?: string | undefined; | ||
isBinary?: boolean | undefined; | ||
}[]>; |
@@ -5,11 +5,11 @@ import { z } from 'zod'; | ||
export declare const persistConfigSchema: z.ZodObject<{ | ||
outputDir: z.ZodString; | ||
filename: z.ZodDefault<z.ZodString>; | ||
outputDir: z.ZodOptional<z.ZodString>; | ||
filename: z.ZodOptional<z.ZodString>; | ||
format: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodEnum<["json", "md"]>, "many">>>; | ||
}, "strip", z.ZodTypeAny, { | ||
outputDir: string; | ||
filename: string; | ||
outputDir?: string | undefined; | ||
filename?: string | undefined; | ||
format?: ("json" | "md")[] | undefined; | ||
}, { | ||
outputDir: string; | ||
outputDir?: string | undefined; | ||
filename?: string | undefined; | ||
@@ -16,0 +16,0 @@ format?: ("json" | "md")[] | undefined; |
Sorry, the diff of this file is too big to display
1190259
19
15686