@code-pushup/models 0.26.1 → 0.28.0
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 +111 -11
- package/package.json +1 -1
- package/src/index.d.ts +2 -1
- package/src/lib/audit-output.d.ts +2 -0
- package/src/lib/implementation/constants.d.ts +3 -3
- package/src/lib/implementation/schemas.d.ts +2 -0
- package/src/lib/reports-diff.d.ts +1348 -0
package/index.js
CHANGED
|
@@ -84,6 +84,9 @@ var descriptionSchema = z.string({ description: "Description (markdown)" }).max(
|
|
|
84
84
|
var urlSchema = z.string().url();
|
|
85
85
|
var docsUrlSchema = urlSchema.optional().or(z.literal("")).describe("Documentation site");
|
|
86
86
|
var titleSchema = z.string({ description: "Descriptive name" }).max(MAX_TITLE_LENGTH);
|
|
87
|
+
var scoreSchema = z.number({
|
|
88
|
+
description: "Value between 0 and 1"
|
|
89
|
+
}).min(0).max(1);
|
|
87
90
|
function metaSchema(options) {
|
|
88
91
|
const {
|
|
89
92
|
descriptionDescription,
|
|
@@ -215,6 +218,8 @@ var issueSchema = z3.object(
|
|
|
215
218
|
);
|
|
216
219
|
|
|
217
220
|
// packages/models/src/lib/audit-output.ts
|
|
221
|
+
var auditValueSchema = nonnegativeIntSchema.describe("Raw numeric value");
|
|
222
|
+
var auditDisplayValueSchema = z4.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional();
|
|
218
223
|
var auditDetailsSchema = z4.object(
|
|
219
224
|
{
|
|
220
225
|
issues: z4.array(issueSchema, { description: "List of findings" })
|
|
@@ -224,11 +229,9 @@ var auditDetailsSchema = z4.object(
|
|
|
224
229
|
var auditOutputSchema = z4.object(
|
|
225
230
|
{
|
|
226
231
|
slug: slugSchema.describe("Reference to audit"),
|
|
227
|
-
displayValue:
|
|
228
|
-
value:
|
|
229
|
-
score:
|
|
230
|
-
description: "Value between 0 and 1"
|
|
231
|
-
}).min(0).max(1),
|
|
232
|
+
displayValue: auditDisplayValueSchema,
|
|
233
|
+
value: auditValueSchema,
|
|
234
|
+
score: scoreSchema,
|
|
232
235
|
details: auditDetailsSchema.optional()
|
|
233
236
|
},
|
|
234
237
|
{ description: "Audit information" }
|
|
@@ -493,9 +496,9 @@ var CONFIG_FILE_NAME = "code-pushup.config";
|
|
|
493
496
|
var SUPPORTED_CONFIG_FILE_FORMATS = ["ts", "mjs", "js"];
|
|
494
497
|
|
|
495
498
|
// packages/models/src/lib/implementation/constants.ts
|
|
496
|
-
var
|
|
497
|
-
var
|
|
498
|
-
var
|
|
499
|
+
var DEFAULT_PERSIST_OUTPUT_DIR = ".code-pushup";
|
|
500
|
+
var DEFAULT_PERSIST_FILENAME = "report";
|
|
501
|
+
var DEFAULT_PERSIST_FORMAT = ["json", "md"];
|
|
499
502
|
|
|
500
503
|
// packages/models/src/lib/report.ts
|
|
501
504
|
import { z as z13 } from "zod";
|
|
@@ -559,28 +562,124 @@ var reportSchema = packageVersionSchema({
|
|
|
559
562
|
)
|
|
560
563
|
})
|
|
561
564
|
);
|
|
565
|
+
|
|
566
|
+
// packages/models/src/lib/reports-diff.ts
|
|
567
|
+
import { z as z14 } from "zod";
|
|
568
|
+
function makeComparisonSchema(schema) {
|
|
569
|
+
const sharedDescription = schema.description || "Result";
|
|
570
|
+
return z14.object({
|
|
571
|
+
before: schema.describe(`${sharedDescription} (source commit)`),
|
|
572
|
+
after: schema.describe(`${sharedDescription} (target commit)`)
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
function makeArraysComparisonSchema(diffSchema, resultSchema, description) {
|
|
576
|
+
return z14.object(
|
|
577
|
+
{
|
|
578
|
+
changed: z14.array(diffSchema),
|
|
579
|
+
unchanged: z14.array(resultSchema),
|
|
580
|
+
added: z14.array(resultSchema),
|
|
581
|
+
removed: z14.array(resultSchema)
|
|
582
|
+
},
|
|
583
|
+
{ description }
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
var scorableMetaSchema = z14.object({ slug: slugSchema, title: titleSchema });
|
|
587
|
+
var scorableWithPluginMetaSchema = scorableMetaSchema.merge(
|
|
588
|
+
z14.object({
|
|
589
|
+
plugin: pluginMetaSchema.pick({ slug: true, title: true }).describe("Plugin which defines it")
|
|
590
|
+
})
|
|
591
|
+
);
|
|
592
|
+
var scorableDiffSchema = scorableMetaSchema.merge(
|
|
593
|
+
z14.object({
|
|
594
|
+
scores: makeComparisonSchema(scoreSchema).merge(
|
|
595
|
+
z14.object({
|
|
596
|
+
diff: z14.number().min(-1).max(1).describe("Score change (`scores.after - scores.before`)")
|
|
597
|
+
})
|
|
598
|
+
).describe("Score comparison")
|
|
599
|
+
})
|
|
600
|
+
);
|
|
601
|
+
var scorableWithPluginDiffSchema = scorableDiffSchema.merge(
|
|
602
|
+
scorableWithPluginMetaSchema
|
|
603
|
+
);
|
|
604
|
+
var categoryDiffSchema = scorableDiffSchema;
|
|
605
|
+
var groupDiffSchema = scorableWithPluginDiffSchema;
|
|
606
|
+
var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
607
|
+
z14.object({
|
|
608
|
+
values: makeComparisonSchema(auditValueSchema).merge(
|
|
609
|
+
z14.object({
|
|
610
|
+
diff: z14.number().int().describe("Value change (`values.after - values.before`)")
|
|
611
|
+
})
|
|
612
|
+
).describe("Audit `value` comparison"),
|
|
613
|
+
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
614
|
+
"Audit `displayValue` comparison"
|
|
615
|
+
)
|
|
616
|
+
})
|
|
617
|
+
);
|
|
618
|
+
var categoryResultSchema = scorableMetaSchema.merge(
|
|
619
|
+
z14.object({ score: scoreSchema })
|
|
620
|
+
);
|
|
621
|
+
var groupResultSchema = scorableWithPluginMetaSchema.merge(
|
|
622
|
+
z14.object({ score: scoreSchema })
|
|
623
|
+
);
|
|
624
|
+
var auditResultSchema = scorableWithPluginMetaSchema.merge(
|
|
625
|
+
auditOutputSchema.pick({ score: true, value: true, displayValue: true })
|
|
626
|
+
);
|
|
627
|
+
var reportsDiffSchema = z14.object({
|
|
628
|
+
commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
|
|
629
|
+
categories: makeArraysComparisonSchema(
|
|
630
|
+
categoryDiffSchema,
|
|
631
|
+
categoryResultSchema,
|
|
632
|
+
"Changes affecting categories"
|
|
633
|
+
),
|
|
634
|
+
groups: makeArraysComparisonSchema(
|
|
635
|
+
groupDiffSchema,
|
|
636
|
+
groupResultSchema,
|
|
637
|
+
"Changes affecting groups"
|
|
638
|
+
),
|
|
639
|
+
audits: makeArraysComparisonSchema(
|
|
640
|
+
auditDiffSchema,
|
|
641
|
+
auditResultSchema,
|
|
642
|
+
"Changes affecting audits"
|
|
643
|
+
)
|
|
644
|
+
}).merge(
|
|
645
|
+
packageVersionSchema({
|
|
646
|
+
versionDescription: "NPM version of the CLI (when `compare` was run)",
|
|
647
|
+
required: true
|
|
648
|
+
})
|
|
649
|
+
).merge(
|
|
650
|
+
executionMetaSchema({
|
|
651
|
+
descriptionDate: "Start date and time of the compare run",
|
|
652
|
+
descriptionDuration: "Duration of the compare run in ms"
|
|
653
|
+
})
|
|
654
|
+
);
|
|
562
655
|
export {
|
|
563
656
|
CONFIG_FILE_NAME,
|
|
657
|
+
DEFAULT_PERSIST_FILENAME,
|
|
658
|
+
DEFAULT_PERSIST_FORMAT,
|
|
659
|
+
DEFAULT_PERSIST_OUTPUT_DIR,
|
|
564
660
|
MAX_DESCRIPTION_LENGTH,
|
|
565
661
|
MAX_ISSUE_MESSAGE_LENGTH,
|
|
566
662
|
MAX_SLUG_LENGTH,
|
|
567
663
|
MAX_TITLE_LENGTH,
|
|
568
|
-
PERSIST_FILENAME,
|
|
569
|
-
PERSIST_FORMAT,
|
|
570
|
-
PERSIST_OUTPUT_DIR,
|
|
571
664
|
SUPPORTED_CONFIG_FILE_FORMATS,
|
|
572
665
|
auditDetailsSchema,
|
|
666
|
+
auditDiffSchema,
|
|
573
667
|
auditOutputSchema,
|
|
574
668
|
auditOutputsSchema,
|
|
575
669
|
auditReportSchema,
|
|
670
|
+
auditResultSchema,
|
|
576
671
|
auditSchema,
|
|
577
672
|
categoryConfigSchema,
|
|
673
|
+
categoryDiffSchema,
|
|
578
674
|
categoryRefSchema,
|
|
675
|
+
categoryResultSchema,
|
|
579
676
|
commitSchema,
|
|
580
677
|
coreConfigSchema,
|
|
581
678
|
exists,
|
|
582
679
|
formatSchema,
|
|
680
|
+
groupDiffSchema,
|
|
583
681
|
groupRefSchema,
|
|
682
|
+
groupResultSchema,
|
|
584
683
|
groupSchema,
|
|
585
684
|
issueSchema,
|
|
586
685
|
issueSeveritySchema,
|
|
@@ -591,6 +690,7 @@ export {
|
|
|
591
690
|
pluginMetaSchema,
|
|
592
691
|
pluginReportSchema,
|
|
593
692
|
reportSchema,
|
|
693
|
+
reportsDiffSchema,
|
|
594
694
|
runnerConfigSchema,
|
|
595
695
|
runnerFunctionSchema,
|
|
596
696
|
uploadConfigSchema
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { Commit, commitSchema } from './lib/commit';
|
|
|
5
5
|
export { CoreConfig, coreConfigSchema } from './lib/core-config';
|
|
6
6
|
export { Group, GroupRef, groupRefSchema, groupSchema } from './lib/group';
|
|
7
7
|
export { CONFIG_FILE_NAME, SUPPORTED_CONFIG_FILE_FORMATS, } from './lib/implementation/configuration';
|
|
8
|
-
export {
|
|
8
|
+
export { DEFAULT_PERSIST_FILENAME, DEFAULT_PERSIST_FORMAT, DEFAULT_PERSIST_OUTPUT_DIR, } from './lib/implementation/constants';
|
|
9
9
|
export { MAX_DESCRIPTION_LENGTH, MAX_ISSUE_MESSAGE_LENGTH, MAX_SLUG_LENGTH, MAX_TITLE_LENGTH, } from './lib/implementation/limits';
|
|
10
10
|
export { MaterialIcon, materialIconSchema } from './lib/implementation/schemas';
|
|
11
11
|
export { exists } from './lib/implementation/utils';
|
|
@@ -13,5 +13,6 @@ export { Issue, IssueSeverity, issueSchema, issueSeveritySchema, } from './lib/i
|
|
|
13
13
|
export { Format, PersistConfig, formatSchema, persistConfigSchema, } from './lib/persist-config';
|
|
14
14
|
export { PluginConfig, PluginMeta, pluginConfigSchema, pluginMetaSchema, } from './lib/plugin-config';
|
|
15
15
|
export { AuditReport, PluginReport, Report, auditReportSchema, pluginReportSchema, reportSchema, } from './lib/report';
|
|
16
|
+
export { AuditDiff, AuditResult, CategoryDiff, CategoryResult, GroupDiff, GroupResult, ReportsDiff, auditDiffSchema, auditResultSchema, categoryDiffSchema, categoryResultSchema, groupDiffSchema, groupResultSchema, reportsDiffSchema, } from './lib/reports-diff';
|
|
16
17
|
export { OnProgress, RunnerConfig, RunnerFunction, onProgressSchema, runnerConfigSchema, runnerFunctionSchema, } from './lib/runner-config';
|
|
17
18
|
export { UploadConfig, uploadConfigSchema } from './lib/upload-config';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const auditValueSchema: z.ZodNumber;
|
|
3
|
+
export declare const auditDisplayValueSchema: z.ZodOptional<z.ZodString>;
|
|
2
4
|
export declare const auditDetailsSchema: z.ZodObject<{
|
|
3
5
|
issues: z.ZodArray<z.ZodObject<{
|
|
4
6
|
message: z.ZodString;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Format } from '../persist-config';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
2
|
+
export declare const DEFAULT_PERSIST_OUTPUT_DIR = ".code-pushup";
|
|
3
|
+
export declare const DEFAULT_PERSIST_FILENAME = "report";
|
|
4
|
+
export declare const DEFAULT_PERSIST_FORMAT: Format[];
|
|
@@ -24,6 +24,8 @@ export declare const urlSchema: ZodString;
|
|
|
24
24
|
export declare const docsUrlSchema: z.ZodUnion<[ZodOptional<ZodString>, z.ZodLiteral<"">]>;
|
|
25
25
|
/** Schema for a title of a plugin, category and audit */
|
|
26
26
|
export declare const titleSchema: ZodString;
|
|
27
|
+
/** Schema for score of audit, category or group */
|
|
28
|
+
export declare const scoreSchema: z.ZodNumber;
|
|
27
29
|
/**
|
|
28
30
|
* Used for categories, plugins and audits
|
|
29
31
|
* @param options
|