@code-pushup/models 0.25.7 → 0.26.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 CHANGED
@@ -312,23 +312,42 @@ function getDuplicateSlugCategories(categories) {
312
312
  return hasDuplicateStrings(categories.map(({ slug }) => slug));
313
313
  }
314
314
 
315
+ // packages/models/src/lib/commit.ts
316
+ import { z as z6 } from "zod";
317
+ var commitSchema = z6.object(
318
+ {
319
+ hash: z6.string({ description: "Commit SHA (full)" }).regex(
320
+ /^[\da-f]{40}$/,
321
+ "Commit SHA should be a 40-character hexadecimal string"
322
+ ),
323
+ message: z6.string({ description: "Commit message" }),
324
+ date: z6.coerce.date({
325
+ description: "Date and time when commit was authored"
326
+ }),
327
+ author: z6.string({
328
+ description: "Commit author name"
329
+ }).trim()
330
+ },
331
+ { description: "Git commit" }
332
+ );
333
+
315
334
  // packages/models/src/lib/core-config.ts
316
- import { z as z11 } from "zod";
335
+ import { z as z12 } from "zod";
317
336
 
318
337
  // packages/models/src/lib/persist-config.ts
319
- import { z as z6 } from "zod";
320
- var formatSchema = z6.enum(["json", "md"]);
321
- var persistConfigSchema = z6.object({
338
+ import { z as z7 } from "zod";
339
+ var formatSchema = z7.enum(["json", "md"]);
340
+ var persistConfigSchema = z7.object({
322
341
  outputDir: filePathSchema.describe("Artifacts folder").optional(),
323
342
  filename: fileNameSchema.describe("Artifacts file name (without extension)").optional(),
324
- format: z6.array(formatSchema).optional()
343
+ format: z7.array(formatSchema).optional()
325
344
  });
326
345
 
327
346
  // packages/models/src/lib/plugin-config.ts
328
- import { z as z9 } from "zod";
347
+ import { z as z10 } from "zod";
329
348
 
330
349
  // packages/models/src/lib/group.ts
331
- import { z as z7 } from "zod";
350
+ import { z as z8 } from "zod";
332
351
  var groupRefSchema = weightedRefSchema(
333
352
  "Weighted reference to a group",
334
353
  "Reference slug to a group within this plugin (e.g. 'max-lines')"
@@ -345,7 +364,7 @@ var groupSchema = scorableSchema(
345
364
  getDuplicateRefsInGroups,
346
365
  duplicateRefsInGroupsErrorMsg
347
366
  ).merge(groupMetaSchema);
348
- var groupsSchema = z7.array(groupSchema, {
367
+ var groupsSchema = z8.array(groupSchema, {
349
368
  description: "List of groups"
350
369
  }).optional().refine(
351
370
  (groups) => !getDuplicateSlugsInGroups(groups),
@@ -373,14 +392,14 @@ function getDuplicateSlugsInGroups(groups) {
373
392
  }
374
393
 
375
394
  // packages/models/src/lib/runner-config.ts
376
- import { z as z8 } from "zod";
377
- var outputTransformSchema = z8.function().args(z8.unknown()).returns(z8.union([auditOutputsSchema, z8.promise(auditOutputsSchema)]));
378
- var runnerConfigSchema = z8.object(
395
+ import { z as z9 } from "zod";
396
+ var outputTransformSchema = z9.function().args(z9.unknown()).returns(z9.union([auditOutputsSchema, z9.promise(auditOutputsSchema)]));
397
+ var runnerConfigSchema = z9.object(
379
398
  {
380
- command: z8.string({
399
+ command: z9.string({
381
400
  description: "Shell command to execute"
382
401
  }),
383
- args: z8.array(z8.string({ description: "Command arguments" })).optional(),
402
+ args: z9.array(z9.string({ description: "Command arguments" })).optional(),
384
403
  outputFile: filePathSchema.describe("Output path"),
385
404
  outputTransform: outputTransformSchema.optional()
386
405
  },
@@ -388,8 +407,8 @@ var runnerConfigSchema = z8.object(
388
407
  description: "How to execute runner"
389
408
  }
390
409
  );
391
- var onProgressSchema = z8.function().args(z8.unknown()).returns(z8.void());
392
- var runnerFunctionSchema = z8.function().args(onProgressSchema.optional()).returns(z8.union([auditOutputsSchema, z8.promise(auditOutputsSchema)]));
410
+ var onProgressSchema = z9.function().args(z9.unknown()).returns(z9.void());
411
+ var runnerFunctionSchema = z9.function().args(onProgressSchema.optional()).returns(z9.union([auditOutputsSchema, z9.promise(auditOutputsSchema)]));
393
412
 
394
413
  // packages/models/src/lib/plugin-config.ts
395
414
  var pluginMetaSchema = packageVersionSchema().merge(
@@ -400,13 +419,13 @@ var pluginMetaSchema = packageVersionSchema().merge(
400
419
  description: "Plugin metadata"
401
420
  })
402
421
  ).merge(
403
- z9.object({
422
+ z10.object({
404
423
  slug: slugSchema.describe("Unique plugin slug within core config"),
405
424
  icon: materialIconSchema
406
425
  })
407
426
  );
408
- var pluginDataSchema = z9.object({
409
- runner: z9.union([runnerConfigSchema, runnerFunctionSchema]),
427
+ var pluginDataSchema = z10.object({
428
+ runner: z10.union([runnerConfigSchema, runnerFunctionSchema]),
410
429
  audits: pluginAuditsSchema,
411
430
  groups: groupsSchema
412
431
  });
@@ -432,22 +451,22 @@ function getMissingRefsFromGroups(pluginCfg) {
432
451
  }
433
452
 
434
453
  // packages/models/src/lib/upload-config.ts
435
- import { z as z10 } from "zod";
436
- var uploadConfigSchema = z10.object({
454
+ import { z as z11 } from "zod";
455
+ var uploadConfigSchema = z11.object({
437
456
  server: urlSchema.describe("URL of deployed portal API"),
438
- apiKey: z10.string({
457
+ apiKey: z11.string({
439
458
  description: "API key with write access to portal (use `process.env` for security)"
440
459
  }),
441
460
  organization: slugSchema.describe(
442
461
  "Organization slug from Code PushUp portal"
443
462
  ),
444
463
  project: slugSchema.describe("Project slug from Code PushUp portal"),
445
- timeout: z10.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
464
+ timeout: z11.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
446
465
  });
447
466
 
448
467
  // packages/models/src/lib/core-config.ts
449
- var unrefinedCoreConfigSchema = z11.object({
450
- plugins: z11.array(pluginConfigSchema, {
468
+ var unrefinedCoreConfigSchema = z12.object({
469
+ plugins: z12.array(pluginConfigSchema, {
451
470
  description: "List of plugins to be used (official, community-provided, or custom)"
452
471
  }).min(1),
453
472
  /** portal configuration for persisting results */
@@ -479,7 +498,7 @@ var PERSIST_FORMAT = ["json"];
479
498
  var PERSIST_FILENAME = "report";
480
499
 
481
500
  // packages/models/src/lib/report.ts
482
- import { z as z12 } from "zod";
501
+ import { z as z13 } from "zod";
483
502
  var auditReportSchema = auditSchema.merge(auditOutputSchema);
484
503
  var pluginReportSchema = pluginMetaSchema.merge(
485
504
  executionMetaSchema({
@@ -487,9 +506,9 @@ var pluginReportSchema = pluginMetaSchema.merge(
487
506
  descriptionDuration: "Duration of the plugin run in ms"
488
507
  })
489
508
  ).merge(
490
- z12.object({
491
- audits: z12.array(auditReportSchema).min(1),
492
- groups: z12.array(groupSchema).optional()
509
+ z13.object({
510
+ audits: z13.array(auditReportSchema).min(1),
511
+ groups: z13.array(groupSchema).optional()
493
512
  })
494
513
  ).refine(
495
514
  (pluginReport) => !getMissingRefsFromGroups2(pluginReport.audits, pluginReport.groups ?? []),
@@ -523,10 +542,11 @@ var reportSchema = packageVersionSchema({
523
542
  descriptionDuration: "Duration of the collect run in ms"
524
543
  })
525
544
  ).merge(
526
- z12.object(
545
+ z13.object(
527
546
  {
528
- categories: z12.array(categoryConfigSchema),
529
- plugins: z12.array(pluginReportSchema).min(1)
547
+ categories: z13.array(categoryConfigSchema),
548
+ plugins: z13.array(pluginReportSchema).min(1),
549
+ commit: commitSchema.describe("Git commit for which report was collected").nullable()
530
550
  },
531
551
  { description: "Collect output data" }
532
552
  )
@@ -556,6 +576,7 @@ export {
556
576
  auditSchema,
557
577
  categoryConfigSchema,
558
578
  categoryRefSchema,
579
+ commitSchema,
559
580
  coreConfigSchema,
560
581
  exists,
561
582
  formatSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/models",
3
- "version": "0.25.7",
3
+ "version": "0.26.0",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "zod": "^3.22.1",
package/src/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { Audit, auditSchema } from './lib/audit';
2
2
  export { AuditDetails, AuditOutput, AuditOutputs, auditDetailsSchema, auditOutputSchema, auditOutputsSchema, } from './lib/audit-output';
3
3
  export { CategoryConfig, CategoryRef, categoryConfigSchema, categoryRefSchema, } from './lib/category-config';
4
+ export { Commit, commitSchema } from './lib/commit';
4
5
  export { CoreConfig, coreConfigSchema } from './lib/core-config';
5
6
  export { Group, GroupRef, groupRefSchema, groupSchema } from './lib/group';
6
7
  export { CONFIG_FILE_NAME, SUPPORTED_CONFIG_FILE_FORMATS, } from './lib/implementation/configuration';
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ export declare const commitSchema: z.ZodObject<{
3
+ hash: z.ZodString;
4
+ message: z.ZodString;
5
+ date: z.ZodDate;
6
+ author: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ message: string;
9
+ date: Date;
10
+ hash: string;
11
+ author: string;
12
+ }, {
13
+ message: string;
14
+ date: Date;
15
+ hash: string;
16
+ author: string;
17
+ }>;
18
+ export type Commit = z.infer<typeof commitSchema>;
@@ -983,6 +983,22 @@ export declare const reportSchema: z.ZodEffects<z.ZodObject<{
983
983
  docsUrl?: string | undefined;
984
984
  }[] | undefined;
985
985
  }>, "many">;
986
+ commit: z.ZodNullable<z.ZodObject<{
987
+ hash: z.ZodString;
988
+ message: z.ZodString;
989
+ date: z.ZodDate;
990
+ author: z.ZodString;
991
+ }, "strip", z.ZodTypeAny, {
992
+ message: string;
993
+ date: Date;
994
+ hash: string;
995
+ author: string;
996
+ }, {
997
+ message: string;
998
+ date: Date;
999
+ hash: string;
1000
+ author: string;
1001
+ }>>;
986
1002
  }, "strip", z.ZodTypeAny, {
987
1003
  date: string;
988
1004
  packageName: string;
@@ -1046,6 +1062,12 @@ export declare const reportSchema: z.ZodEffects<z.ZodObject<{
1046
1062
  docsUrl?: string | undefined;
1047
1063
  }[] | undefined;
1048
1064
  }[];
1065
+ commit: {
1066
+ message: string;
1067
+ date: Date;
1068
+ hash: string;
1069
+ author: string;
1070
+ } | null;
1049
1071
  }, {
1050
1072
  date: string;
1051
1073
  packageName: string;
@@ -1109,6 +1131,12 @@ export declare const reportSchema: z.ZodEffects<z.ZodObject<{
1109
1131
  docsUrl?: string | undefined;
1110
1132
  }[] | undefined;
1111
1133
  }[];
1134
+ commit: {
1135
+ message: string;
1136
+ date: Date;
1137
+ hash: string;
1138
+ author: string;
1139
+ } | null;
1112
1140
  }>, {
1113
1141
  date: string;
1114
1142
  packageName: string;
@@ -1172,6 +1200,12 @@ export declare const reportSchema: z.ZodEffects<z.ZodObject<{
1172
1200
  docsUrl?: string | undefined;
1173
1201
  }[] | undefined;
1174
1202
  }[];
1203
+ commit: {
1204
+ message: string;
1205
+ date: Date;
1206
+ hash: string;
1207
+ author: string;
1208
+ } | null;
1175
1209
  }, {
1176
1210
  date: string;
1177
1211
  packageName: string;
@@ -1235,5 +1269,11 @@ export declare const reportSchema: z.ZodEffects<z.ZodObject<{
1235
1269
  docsUrl?: string | undefined;
1236
1270
  }[] | undefined;
1237
1271
  }[];
1272
+ commit: {
1273
+ message: string;
1274
+ date: Date;
1275
+ hash: string;
1276
+ author: string;
1277
+ } | null;
1238
1278
  }>;
1239
1279
  export type Report = z.infer<typeof reportSchema>;