@code-pushup/models 0.2.0 → 0.3.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
@@ -5,6 +5,11 @@ import { z as z2 } from "zod";
5
5
  import { z } from "zod";
6
6
  import { MATERIAL_ICONS } from "@code-pushup/portal-client";
7
7
 
8
+ // packages/models/src/lib/implementation/limits.ts
9
+ var MAX_SLUG_LENGTH = 128;
10
+ var MAX_TITLE_LENGTH = 256;
11
+ var MAX_DESCRIPTION_LENGTH = 65536;
12
+
8
13
  // packages/models/src/lib/implementation/utils.ts
9
14
  var slugRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
10
15
  var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
@@ -40,12 +45,12 @@ function executionMetaSchema(options = {
40
45
  function slugSchema(description = "Unique ID (human-readable, URL-safe)") {
41
46
  return z.string({ description }).regex(slugRegex, {
42
47
  message: "The slug has to follow the pattern [0-9a-z] followed by multiple optional groups of -[0-9a-z]. e.g. my-slug"
43
- }).max(128, {
44
- message: "slug can be max 128 characters long"
48
+ }).max(MAX_SLUG_LENGTH, {
49
+ message: `slug can be max ${MAX_SLUG_LENGTH} characters long`
45
50
  });
46
51
  }
47
52
  function descriptionSchema(description = "Description (markdown)") {
48
- return z.string({ description }).max(65536).optional();
53
+ return z.string({ description }).max(MAX_DESCRIPTION_LENGTH).optional();
49
54
  }
50
55
  function docsUrlSchema(description = "Documentation site") {
51
56
  return urlSchema(description).optional().or(z.string().max(0));
@@ -54,7 +59,7 @@ function urlSchema(description) {
54
59
  return z.string({ description }).url();
55
60
  }
56
61
  function titleSchema(description = "Descriptive name") {
57
- return z.string({ description }).max(256);
62
+ return z.string({ description }).max(MAX_TITLE_LENGTH);
58
63
  }
59
64
  function metaSchema(options) {
60
65
  const {
@@ -522,6 +527,9 @@ var reportSchema = packageVersionSchema({
522
527
  )
523
528
  );
524
529
  export {
530
+ MAX_DESCRIPTION_LENGTH,
531
+ MAX_SLUG_LENGTH,
532
+ MAX_TITLE_LENGTH,
525
533
  auditGroupSchema,
526
534
  auditOutputsSchema,
527
535
  auditReportSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/models",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
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,12 +1,13 @@
1
- export { CategoryConfig, CategoryRef, categoryRefSchema, categoryConfigSchema, } from './lib/category-config';
1
+ export { CategoryConfig, CategoryRef, categoryConfigSchema, categoryRefSchema, } from './lib/category-config';
2
2
  export { CoreConfig, coreConfigSchema, refineCoreConfig, unrefinedCoreConfigSchema, } from './lib/core-config';
3
+ export { MAX_DESCRIPTION_LENGTH, MAX_SLUG_LENGTH, MAX_TITLE_LENGTH, } from './lib/implementation/limits';
4
+ export { materialIconSchema } from './lib/implementation/schemas';
3
5
  export { Format, PersistConfig, formatSchema, persistConfigSchema, } from './lib/persist-config';
4
6
  export { PluginConfig, pluginConfigSchema } from './lib/plugin-config';
5
- export { auditSchema, Audit, pluginAuditsSchema, } from './lib/plugin-config-audits';
6
- export { AuditGroupRef, AuditGroup, auditGroupSchema, } from './lib/plugin-config-groups';
7
+ export { Audit, auditSchema, pluginAuditsSchema, } from './lib/plugin-config-audits';
8
+ export { AuditGroup, AuditGroupRef, auditGroupSchema, } from './lib/plugin-config-groups';
9
+ export { OnProgress, RunnerConfig, RunnerFunction, onProgressSchema, runnerConfigSchema, } from './lib/plugin-config-runner';
7
10
  export { AuditOutput, AuditOutputs, auditOutputsSchema, } from './lib/plugin-process-output';
8
11
  export { Issue, IssueSeverity } from './lib/plugin-process-output-audit-issue';
9
- export { AuditReport, auditReportSchema, PluginReport, Report, pluginReportSchema, reportSchema, } from './lib/report';
12
+ export { AuditReport, PluginReport, Report, auditReportSchema, pluginReportSchema, reportSchema, } from './lib/report';
10
13
  export { UploadConfig, uploadConfigSchema } from './lib/upload-config';
11
- export { materialIconSchema } from './lib/implementation/schemas';
12
- export { onProgressSchema, OnProgress, RunnerFunction, runnerConfigSchema, RunnerConfig, } from './lib/plugin-config-runner';
@@ -0,0 +1,3 @@
1
+ export declare const MAX_SLUG_LENGTH = 128;
2
+ export declare const MAX_TITLE_LENGTH = 256;
3
+ export declare const MAX_DESCRIPTION_LENGTH = 65536;