@code-pushup/models 0.4.5 → 0.5.2
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/index.js +42 -25
- package/package.json +1 -1
- package/src/index.d.ts +2 -1
- package/src/lib/category-config.d.ts +102 -1
- package/src/lib/core-config.d.ts +4551 -31
- package/src/lib/implementation/constants.d.ts +3 -0
- package/src/lib/implementation/schemas.d.ts +1 -1
- package/src/lib/persist-config.d.ts +5 -5
- package/src/lib/plugin-config-groups.d.ts +14 -2
- package/src/lib/plugin-config.d.ts +14 -2
- package/src/lib/report.d.ts +25 -3
package/index.js
CHANGED
|
@@ -118,12 +118,14 @@ function scorableSchema(description, refSchema, duplicateCheckFn, duplicateMessa
|
|
|
118
118
|
return z.object(
|
|
119
119
|
{
|
|
120
120
|
slug: slugSchema('Human-readable unique ID, e.g. "performance"'),
|
|
121
|
-
refs: z.array(refSchema).refine(
|
|
121
|
+
refs: z.array(refSchema).min(1).refine(
|
|
122
122
|
(refs) => !duplicateCheckFn(refs),
|
|
123
123
|
(refs) => ({
|
|
124
124
|
message: duplicateMessageFn(refs)
|
|
125
125
|
})
|
|
126
|
-
)
|
|
126
|
+
).refine(hasWeightedRefsInCategories, () => ({
|
|
127
|
+
message: `In a category there has to be at least one ref with weight > 0`
|
|
128
|
+
}))
|
|
127
129
|
},
|
|
128
130
|
{ description }
|
|
129
131
|
);
|
|
@@ -132,6 +134,9 @@ var materialIconSchema = z.enum(
|
|
|
132
134
|
MATERIAL_ICONS,
|
|
133
135
|
{ description: "Icon from VSCode Material Icons extension" }
|
|
134
136
|
);
|
|
137
|
+
function hasWeightedRefsInCategories(categoryRefs) {
|
|
138
|
+
return categoryRefs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
|
|
139
|
+
}
|
|
135
140
|
|
|
136
141
|
// packages/models/src/lib/category-config.ts
|
|
137
142
|
var categoryRefSchema = weightedRefSchema(
|
|
@@ -177,6 +182,23 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
|
|
|
177
182
|
metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
|
|
178
183
|
);
|
|
179
184
|
}
|
|
185
|
+
var categoriesSchema = z2.array(categoryConfigSchema, {
|
|
186
|
+
description: "Categorization of individual audits"
|
|
187
|
+
}).min(1).refine(
|
|
188
|
+
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
|
|
189
|
+
(categoryCfg) => ({
|
|
190
|
+
message: duplicateSlugCategoriesErrorMsg(categoryCfg)
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
function duplicateSlugCategoriesErrorMsg(categories) {
|
|
194
|
+
const duplicateStringSlugs = getDuplicateSlugCategories(categories);
|
|
195
|
+
return `In the categories, the following slugs are duplicated: ${errorItems(
|
|
196
|
+
duplicateStringSlugs
|
|
197
|
+
)}`;
|
|
198
|
+
}
|
|
199
|
+
function getDuplicateSlugCategories(categories) {
|
|
200
|
+
return hasDuplicateStrings(categories.map(({ slug }) => slug));
|
|
201
|
+
}
|
|
180
202
|
|
|
181
203
|
// packages/models/src/lib/core-config.ts
|
|
182
204
|
import { z as z11 } from "zod";
|
|
@@ -185,10 +207,10 @@ import { z as z11 } from "zod";
|
|
|
185
207
|
import { z as z3 } from "zod";
|
|
186
208
|
var formatSchema = z3.enum(["json", "md"]);
|
|
187
209
|
var persistConfigSchema = z3.object({
|
|
188
|
-
outputDir: filePathSchema("Artifacts folder"),
|
|
189
|
-
filename: fileNameSchema(
|
|
190
|
-
"
|
|
191
|
-
),
|
|
210
|
+
outputDir: filePathSchema("Artifacts folder").optional(),
|
|
211
|
+
filename: fileNameSchema(
|
|
212
|
+
"Artifacts file name (without extension)"
|
|
213
|
+
).optional(),
|
|
192
214
|
format: z3.array(formatSchema).default(["json"]).optional()
|
|
193
215
|
// @TODO remove default or optional value and otherwise it will not set defaults.
|
|
194
216
|
});
|
|
@@ -424,17 +446,10 @@ var unrefinedCoreConfigSchema = z11.object({
|
|
|
424
446
|
description: "List of plugins to be used (official, community-provided, or custom)"
|
|
425
447
|
}),
|
|
426
448
|
/** portal configuration for persisting results */
|
|
427
|
-
persist: persistConfigSchema,
|
|
449
|
+
persist: persistConfigSchema.optional(),
|
|
428
450
|
/** portal configuration for uploading results */
|
|
429
451
|
upload: uploadConfigSchema.optional(),
|
|
430
|
-
categories:
|
|
431
|
-
description: "Categorization of individual audits"
|
|
432
|
-
}).refine(
|
|
433
|
-
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
|
|
434
|
-
(categoryCfg) => ({
|
|
435
|
-
message: duplicateSlugCategoriesErrorMsg(categoryCfg)
|
|
436
|
-
})
|
|
437
|
-
)
|
|
452
|
+
categories: categoriesSchema
|
|
438
453
|
});
|
|
439
454
|
var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
|
|
440
455
|
function refineCoreConfig(schema) {
|
|
@@ -485,15 +500,11 @@ function getMissingRefsForCategories(coreCfg) {
|
|
|
485
500
|
}
|
|
486
501
|
return missingRefs.length ? missingRefs : false;
|
|
487
502
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}
|
|
494
|
-
function getDuplicateSlugCategories(categories) {
|
|
495
|
-
return hasDuplicateStrings(categories.map(({ slug }) => slug));
|
|
496
|
-
}
|
|
503
|
+
|
|
504
|
+
// packages/models/src/lib/implementation/constants.ts
|
|
505
|
+
var PERSIST_OUTPUT_DIR = ".code-pushup";
|
|
506
|
+
var PERSIST_FORMAT = ["json"];
|
|
507
|
+
var PERSIST_FILENAME = "report";
|
|
497
508
|
|
|
498
509
|
// packages/models/src/lib/report.ts
|
|
499
510
|
import { z as z12 } from "zod";
|
|
@@ -529,6 +540,9 @@ export {
|
|
|
529
540
|
MAX_DESCRIPTION_LENGTH,
|
|
530
541
|
MAX_SLUG_LENGTH,
|
|
531
542
|
MAX_TITLE_LENGTH,
|
|
543
|
+
PERSIST_FILENAME,
|
|
544
|
+
PERSIST_FORMAT,
|
|
545
|
+
PERSIST_OUTPUT_DIR,
|
|
532
546
|
auditGroupSchema,
|
|
533
547
|
auditOutputsSchema,
|
|
534
548
|
auditReportSchema,
|
|
@@ -536,6 +550,8 @@ export {
|
|
|
536
550
|
categoryConfigSchema,
|
|
537
551
|
categoryRefSchema,
|
|
538
552
|
coreConfigSchema,
|
|
553
|
+
fileNameSchema,
|
|
554
|
+
filePathSchema,
|
|
539
555
|
formatSchema,
|
|
540
556
|
materialIconSchema,
|
|
541
557
|
onProgressSchema,
|
|
@@ -547,5 +563,6 @@ export {
|
|
|
547
563
|
reportSchema,
|
|
548
564
|
runnerConfigSchema,
|
|
549
565
|
unrefinedCoreConfigSchema,
|
|
550
|
-
uploadConfigSchema
|
|
566
|
+
uploadConfigSchema,
|
|
567
|
+
urlSchema
|
|
551
568
|
};
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { CategoryConfig, CategoryRef, categoryConfigSchema, categoryRefSchema, } from './lib/category-config';
|
|
2
2
|
export { CoreConfig, coreConfigSchema, refineCoreConfig, unrefinedCoreConfigSchema, } from './lib/core-config';
|
|
3
3
|
export { MAX_DESCRIPTION_LENGTH, MAX_SLUG_LENGTH, MAX_TITLE_LENGTH, } from './lib/implementation/limits';
|
|
4
|
-
export {
|
|
4
|
+
export { PERSIST_FILENAME, PERSIST_OUTPUT_DIR, PERSIST_FORMAT, } from './lib/implementation/constants';
|
|
5
|
+
export { materialIconSchema, filePathSchema, fileNameSchema, urlSchema, } from './lib/implementation/schemas';
|
|
5
6
|
export { Format, PersistConfig, formatSchema, persistConfigSchema, } from './lib/persist-config';
|
|
6
7
|
export { PluginConfig, pluginConfigSchema, PluginMeta, } from './lib/plugin-config';
|
|
7
8
|
export { Audit, auditSchema, pluginAuditsSchema, } from './lib/plugin-config-audits';
|
|
@@ -21,7 +21,7 @@ export declare const categoryConfigSchema: z.ZodObject<{
|
|
|
21
21
|
title: z.ZodString;
|
|
22
22
|
docsUrl: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodString]>;
|
|
23
23
|
slug: z.ZodString;
|
|
24
|
-
refs: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
24
|
+
refs: z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
25
25
|
slug: z.ZodString;
|
|
26
26
|
weight: z.ZodNumber;
|
|
27
27
|
type: z.ZodEnum<["audit", "group"]>;
|
|
@@ -46,6 +46,16 @@ export declare const categoryConfigSchema: z.ZodObject<{
|
|
|
46
46
|
slug: string;
|
|
47
47
|
weight: number;
|
|
48
48
|
plugin: string;
|
|
49
|
+
}[]>, {
|
|
50
|
+
type: "audit" | "group";
|
|
51
|
+
slug: string;
|
|
52
|
+
weight: number;
|
|
53
|
+
plugin: string;
|
|
54
|
+
}[], {
|
|
55
|
+
type: "audit" | "group";
|
|
56
|
+
slug: string;
|
|
57
|
+
weight: number;
|
|
58
|
+
plugin: string;
|
|
49
59
|
}[]>;
|
|
50
60
|
isBinary: z.ZodOptional<z.ZodBoolean>;
|
|
51
61
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -75,3 +85,94 @@ export declare const categoryConfigSchema: z.ZodObject<{
|
|
|
75
85
|
}>;
|
|
76
86
|
export type CategoryConfig = z.infer<typeof categoryConfigSchema>;
|
|
77
87
|
export declare function duplicateRefsInCategoryMetricsErrorMsg(metrics: CategoryRef[]): string;
|
|
88
|
+
export declare const categoriesSchema: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
89
|
+
description: z.ZodOptional<z.ZodString>;
|
|
90
|
+
title: z.ZodString;
|
|
91
|
+
docsUrl: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodString]>;
|
|
92
|
+
slug: z.ZodString;
|
|
93
|
+
refs: z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
94
|
+
slug: z.ZodString;
|
|
95
|
+
weight: z.ZodNumber;
|
|
96
|
+
type: z.ZodEnum<["audit", "group"]>;
|
|
97
|
+
plugin: z.ZodString;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
type: "audit" | "group";
|
|
100
|
+
slug: string;
|
|
101
|
+
weight: number;
|
|
102
|
+
plugin: string;
|
|
103
|
+
}, {
|
|
104
|
+
type: "audit" | "group";
|
|
105
|
+
slug: string;
|
|
106
|
+
weight: number;
|
|
107
|
+
plugin: string;
|
|
108
|
+
}>, "many">, {
|
|
109
|
+
type: "audit" | "group";
|
|
110
|
+
slug: string;
|
|
111
|
+
weight: number;
|
|
112
|
+
plugin: string;
|
|
113
|
+
}[], {
|
|
114
|
+
type: "audit" | "group";
|
|
115
|
+
slug: string;
|
|
116
|
+
weight: number;
|
|
117
|
+
plugin: string;
|
|
118
|
+
}[]>, {
|
|
119
|
+
type: "audit" | "group";
|
|
120
|
+
slug: string;
|
|
121
|
+
weight: number;
|
|
122
|
+
plugin: string;
|
|
123
|
+
}[], {
|
|
124
|
+
type: "audit" | "group";
|
|
125
|
+
slug: string;
|
|
126
|
+
weight: number;
|
|
127
|
+
plugin: string;
|
|
128
|
+
}[]>;
|
|
129
|
+
isBinary: z.ZodOptional<z.ZodBoolean>;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
title: string;
|
|
132
|
+
slug: string;
|
|
133
|
+
refs: {
|
|
134
|
+
type: "audit" | "group";
|
|
135
|
+
slug: string;
|
|
136
|
+
weight: number;
|
|
137
|
+
plugin: string;
|
|
138
|
+
}[];
|
|
139
|
+
description?: string | undefined;
|
|
140
|
+
docsUrl?: string | undefined;
|
|
141
|
+
isBinary?: boolean | undefined;
|
|
142
|
+
}, {
|
|
143
|
+
title: string;
|
|
144
|
+
slug: string;
|
|
145
|
+
refs: {
|
|
146
|
+
type: "audit" | "group";
|
|
147
|
+
slug: string;
|
|
148
|
+
weight: number;
|
|
149
|
+
plugin: string;
|
|
150
|
+
}[];
|
|
151
|
+
description?: string | undefined;
|
|
152
|
+
docsUrl?: string | undefined;
|
|
153
|
+
isBinary?: boolean | undefined;
|
|
154
|
+
}>, "many">, {
|
|
155
|
+
title: string;
|
|
156
|
+
slug: string;
|
|
157
|
+
refs: {
|
|
158
|
+
type: "audit" | "group";
|
|
159
|
+
slug: string;
|
|
160
|
+
weight: number;
|
|
161
|
+
plugin: string;
|
|
162
|
+
}[];
|
|
163
|
+
description?: string | undefined;
|
|
164
|
+
docsUrl?: string | undefined;
|
|
165
|
+
isBinary?: boolean | undefined;
|
|
166
|
+
}[], {
|
|
167
|
+
title: string;
|
|
168
|
+
slug: string;
|
|
169
|
+
refs: {
|
|
170
|
+
type: "audit" | "group";
|
|
171
|
+
slug: string;
|
|
172
|
+
weight: number;
|
|
173
|
+
plugin: string;
|
|
174
|
+
}[];
|
|
175
|
+
description?: string | undefined;
|
|
176
|
+
docsUrl?: string | undefined;
|
|
177
|
+
isBinary?: boolean | undefined;
|
|
178
|
+
}[]>;
|