@code-pushup/models 0.5.0 → 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 CHANGED
@@ -182,6 +182,23 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
182
182
  metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
183
183
  );
184
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
+ }
185
202
 
186
203
  // packages/models/src/lib/core-config.ts
187
204
  import { z as z11 } from "zod";
@@ -190,10 +207,10 @@ import { z as z11 } from "zod";
190
207
  import { z as z3 } from "zod";
191
208
  var formatSchema = z3.enum(["json", "md"]);
192
209
  var persistConfigSchema = z3.object({
193
- outputDir: filePathSchema("Artifacts folder"),
194
- filename: fileNameSchema("Artifacts file name (without extension)").default(
195
- "report"
196
- ),
210
+ outputDir: filePathSchema("Artifacts folder").optional(),
211
+ filename: fileNameSchema(
212
+ "Artifacts file name (without extension)"
213
+ ).optional(),
197
214
  format: z3.array(formatSchema).default(["json"]).optional()
198
215
  // @TODO remove default or optional value and otherwise it will not set defaults.
199
216
  });
@@ -429,17 +446,10 @@ var unrefinedCoreConfigSchema = z11.object({
429
446
  description: "List of plugins to be used (official, community-provided, or custom)"
430
447
  }),
431
448
  /** portal configuration for persisting results */
432
- persist: persistConfigSchema,
449
+ persist: persistConfigSchema.optional(),
433
450
  /** portal configuration for uploading results */
434
451
  upload: uploadConfigSchema.optional(),
435
- categories: z11.array(categoryConfigSchema, {
436
- description: "Categorization of individual audits"
437
- }).min(1).refine(
438
- (categories) => !getDuplicateSlugCategories(categories),
439
- (categories) => ({
440
- message: duplicateSlugCategoriesErrorMsg(categories)
441
- })
442
- )
452
+ categories: categoriesSchema
443
453
  });
444
454
  var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
445
455
  function refineCoreConfig(schema) {
@@ -490,15 +500,11 @@ function getMissingRefsForCategories(coreCfg) {
490
500
  }
491
501
  return missingRefs.length ? missingRefs : false;
492
502
  }
493
- function duplicateSlugCategoriesErrorMsg(categories) {
494
- const duplicateStringSlugs = getDuplicateSlugCategories(categories);
495
- return `In the categories, the following slugs are duplicated: ${errorItems(
496
- duplicateStringSlugs
497
- )}`;
498
- }
499
- function getDuplicateSlugCategories(categories) {
500
- return hasDuplicateStrings(categories.map(({ slug }) => slug));
501
- }
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";
502
508
 
503
509
  // packages/models/src/lib/report.ts
504
510
  import { z as z12 } from "zod";
@@ -534,6 +540,9 @@ export {
534
540
  MAX_DESCRIPTION_LENGTH,
535
541
  MAX_SLUG_LENGTH,
536
542
  MAX_TITLE_LENGTH,
543
+ PERSIST_FILENAME,
544
+ PERSIST_FORMAT,
545
+ PERSIST_OUTPUT_DIR,
537
546
  auditGroupSchema,
538
547
  auditOutputsSchema,
539
548
  auditReportSchema,
@@ -541,6 +550,8 @@ export {
541
550
  categoryConfigSchema,
542
551
  categoryRefSchema,
543
552
  coreConfigSchema,
553
+ fileNameSchema,
554
+ filePathSchema,
544
555
  formatSchema,
545
556
  materialIconSchema,
546
557
  onProgressSchema,
@@ -552,5 +563,6 @@ export {
552
563
  reportSchema,
553
564
  runnerConfigSchema,
554
565
  unrefinedCoreConfigSchema,
555
- uploadConfigSchema
566
+ uploadConfigSchema,
567
+ urlSchema
556
568
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/models",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "dependencies": {
5
5
  "zod": "^3.22.1",
6
6
  "@code-pushup/portal-client": "^0.1.2"
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 { materialIconSchema } from './lib/implementation/schemas';
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';
@@ -85,3 +85,94 @@ export declare const categoryConfigSchema: z.ZodObject<{
85
85
  }>;
86
86
  export type CategoryConfig = z.infer<typeof categoryConfigSchema>;
87
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
+ }[]>;