@mintlify/validation 0.1.66 → 0.1.68

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/dist/index.js CHANGED
@@ -1,12 +1,3 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
1
  import { zodToJsonSchema } from 'zod-to-json-schema';
11
2
  import { MintValidationResults } from './mint-config/common.js';
12
3
  import { flattenUnionErrorMessages } from './mint-config/flattenUnionErrorMessages.js';
@@ -15,29 +6,32 @@ import { validateAnchorsWarnings } from './mint-config/validateAnchorsWarnings.j
15
6
  import { validateVersionsInNavigation } from './mint-config/validateVersionsInNavigation.js';
16
7
  export function validateMintConfig(config) {
17
8
  var _a;
18
- var results = new MintValidationResults();
9
+ const results = new MintValidationResults();
19
10
  if (config == null || config == undefined || Object.entries(config).length === 0) {
20
11
  results.errors.push('Mint Config object cannot be empty.');
21
12
  results.status = 'error';
22
13
  return results;
23
14
  }
24
15
  // Specific warnings and errors
25
- var validateAnchorsWarningResult = validateAnchorsWarnings(config.anchors, config.navigation);
26
- var validateVersionsInNavigationResult = validateVersionsInNavigation(config.navigation, (_a = config.versions) !== null && _a !== void 0 ? _a : []);
27
- results.errors = __spreadArray(__spreadArray([], results.errors, true), validateVersionsInNavigationResult.errors, true);
28
- results.warnings = __spreadArray(__spreadArray(__spreadArray([], results.warnings, true), validateVersionsInNavigationResult.warnings, true), validateAnchorsWarningResult.warnings, true);
16
+ const validateAnchorsWarningResult = validateAnchorsWarnings(config.anchors, config.navigation);
17
+ const validateVersionsInNavigationResult = validateVersionsInNavigation(config.navigation, (_a = config.versions) !== null && _a !== void 0 ? _a : []);
18
+ results.errors = [...results.errors, ...validateVersionsInNavigationResult.errors];
19
+ results.warnings = [
20
+ ...results.warnings,
21
+ ...validateVersionsInNavigationResult.warnings,
22
+ ...validateAnchorsWarningResult.warnings,
23
+ ];
29
24
  // Global check
30
- var validateConfigResult = configSchema.safeParse(config);
25
+ const validateConfigResult = configSchema.safeParse(config);
31
26
  if (validateConfigResult.success == false) {
32
- var errors = validateConfigResult.error.issues;
33
- errors.forEach(function (e) {
27
+ const errors = validateConfigResult.error.issues;
28
+ errors.forEach((e) => {
34
29
  var _a;
35
- var _b;
36
- if (e.code === 'invalid_union' && ((_b = e.unionErrors) === null || _b === void 0 ? void 0 : _b.length) > 0) {
37
- (_a = results.errors).push.apply(_a, flattenUnionErrorMessages(e.unionErrors));
30
+ if (e.code === 'invalid_union' && ((_a = e.unionErrors) === null || _a === void 0 ? void 0 : _a.length) > 0) {
31
+ results.errors.push(...flattenUnionErrorMessages(e.unionErrors));
38
32
  }
39
33
  else {
40
- var message = e.message;
34
+ let message = e.message;
41
35
  // Fallback if we forget to set a required_error
42
36
  if (message === 'Required') {
43
37
  message = 'Missing required field: ' + e.path.join('.');
@@ -52,9 +46,9 @@ export function validateMintConfig(config) {
52
46
  export * from './openapi/types/endpoint.js';
53
47
  export { convertOpenAPIV3_1ToEndpoint } from './openapi/convertOpenApi.js';
54
48
  export { convertSchema } from './openapi/convertSchema.js';
55
- export var mintConfigSchema = (function () {
49
+ export const mintConfigSchema = (() => {
56
50
  var _a, _b, _c, _d, _e, _f;
57
- var schema = zodToJsonSchema(configSchema, 'Schema');
51
+ const schema = zodToJsonSchema(configSchema, 'Schema');
58
52
  (_b = (_a = schema.definitions) === null || _a === void 0 ? void 0 : _a.Schema) === null || _b === void 0 ? true : delete _b.properties.__injected;
59
53
  (_d = (_c = schema.definitions) === null || _c === void 0 ? void 0 : _c.Schema) === null || _d === void 0 ? true : delete _d.properties.colors.properties.ultraDark;
60
54
  (_f = (_e = schema.definitions) === null || _e === void 0 ? void 0 : _e.Schema) === null || _f === void 0 ? true : delete _f.properties.colors.properties.ultraLight;
@@ -1,9 +1,7 @@
1
- var MintValidationResults = /** @class */ (function () {
2
- function MintValidationResults() {
1
+ export class MintValidationResults {
2
+ constructor() {
3
3
  this.status = 'success';
4
4
  this.errors = [];
5
5
  this.warnings = [];
6
6
  }
7
- return MintValidationResults;
8
- }());
9
- export { MintValidationResults };
7
+ }
@@ -1,19 +1,10 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
1
  // TO DO: Write unit tests for this function.
11
2
  // TO DO: Prettify the output instead of just returning JSON objects.
12
3
  export function flattenUnionErrorMessages(unionErrors) {
13
- return unionErrors.reduce(function (acc, unionError) {
4
+ return unionErrors.reduce((acc, unionError) => {
14
5
  if (Array.isArray(unionError.unionErrors) && unionError.unionErrors.length > 0) {
15
- return __spreadArray(__spreadArray([], acc, true), flattenUnionErrorMessages(unionError.unionErrors), true);
6
+ return [...acc, ...flattenUnionErrorMessages(unionError.unionErrors)];
16
7
  }
17
- return __spreadArray(__spreadArray([], acc, true), [unionError.message], false);
8
+ return [...acc, unionError.message];
18
9
  }, []);
19
10
  }
@@ -1 +1 @@
1
- export var hexadecimalPattern = /^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/;
1
+ export const hexadecimalPattern = /^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- var amplitudeConfigInterfaceSchema = z.object({
2
+ const amplitudeConfigInterfaceSchema = z.object({
3
3
  apiKey: z.string({
4
4
  required_error: 'Amplitude apiKey is missing.',
5
5
  invalid_type_error: 'Amplitude apiKey must be a string.',
@@ -7,7 +7,7 @@ var amplitudeConfigInterfaceSchema = z.object({
7
7
  }, {
8
8
  invalid_type_error: 'Amplitude analytics config must be an object with an apiKey property.',
9
9
  });
10
- var clearbitConfigInterfaceSchema = z.object({
10
+ const clearbitConfigInterfaceSchema = z.object({
11
11
  publicApiKey: z.string({
12
12
  required_error: 'Clearbit publicApiKey is missing.',
13
13
  invalid_type_error: 'Clearbit publicApiKey must be a string.',
@@ -15,7 +15,7 @@ var clearbitConfigInterfaceSchema = z.object({
15
15
  }, {
16
16
  invalid_type_error: 'Clearbit config must be an object with a publicApiKey property.',
17
17
  });
18
- var fathomConfigInterfaceSchema = z.object({
18
+ const fathomConfigInterfaceSchema = z.object({
19
19
  siteId: z.string({
20
20
  required_error: 'Fathom siteId is missing.',
21
21
  invalid_type_error: 'Fathom siteId must be a string.',
@@ -23,7 +23,7 @@ var fathomConfigInterfaceSchema = z.object({
23
23
  }, {
24
24
  invalid_type_error: 'Fathom analytics config must be an object with a siteId property.',
25
25
  });
26
- var googleAnalyticsConfigInterfaceSchema = z.object({
26
+ const googleAnalyticsConfigInterfaceSchema = z.object({
27
27
  measurementId: z
28
28
  .string({
29
29
  required_error: 'Google Analytics measurementId is missing.',
@@ -33,7 +33,7 @@ var googleAnalyticsConfigInterfaceSchema = z.object({
33
33
  }, {
34
34
  invalid_type_error: 'Google Analytics config must be an object with a measurementId property.',
35
35
  });
36
- var googleTagManagerConfigInterfaceSchema = z.object({
36
+ const googleTagManagerConfigInterfaceSchema = z.object({
37
37
  tagId: z
38
38
  .string({
39
39
  required_error: 'Google Tag Manager tagId is missing.',
@@ -43,7 +43,7 @@ var googleTagManagerConfigInterfaceSchema = z.object({
43
43
  }, {
44
44
  invalid_type_error: 'Google Tag Manager config must be an object with a tagId property.',
45
45
  });
46
- var hotjarConfigInterfaceSchema = z.object({
46
+ const hotjarConfigInterfaceSchema = z.object({
47
47
  hjid: z.string({
48
48
  required_error: 'Hotjar hjid is missing.',
49
49
  invalid_type_error: 'Hotjar hjid must be a string.',
@@ -55,17 +55,17 @@ var hotjarConfigInterfaceSchema = z.object({
55
55
  }, {
56
56
  invalid_type_error: 'Hotjar config must be an object with a hjid and hjsv property.',
57
57
  });
58
- var koalaConfigInterfaceSchema = z.object({
58
+ const koalaConfigInterfaceSchema = z.object({
59
59
  publicApiKey: z
60
60
  .string({
61
61
  required_error: 'Public Api Key is required for the Koala snippet to run.',
62
62
  invalid_type_error: 'Koala Public Api Key must be a string.',
63
63
  })
64
- .refine(function (publicApiKey) { return publicApiKey.length >= 2; }, 'Koala Public Api Key must have at least two characters'),
64
+ .refine((publicApiKey) => publicApiKey.length >= 2, 'Koala Public Api Key must have at least two characters'),
65
65
  }, {
66
66
  invalid_type_error: 'Koala config must be an object with a publicApiKey property.',
67
67
  });
68
- var logrocketConfigInterfaceSchema = z.object({
68
+ const logrocketConfigInterfaceSchema = z.object({
69
69
  appId: z.string({
70
70
  required_error: 'Logrocket appId is missing.',
71
71
  invalid_type_error: 'Logrocket appId must be a string.',
@@ -73,7 +73,7 @@ var logrocketConfigInterfaceSchema = z.object({
73
73
  }, {
74
74
  invalid_type_error: 'Logrocket config must be an object with an appId property.',
75
75
  });
76
- var mixpanelConfigInterfaceSchema = z.object({
76
+ const mixpanelConfigInterfaceSchema = z.object({
77
77
  projectToken: z.string({
78
78
  required_error: 'Mixpanel projectToken is missing.',
79
79
  invalid_type_error: 'Mixpanel projectToken must be a string.',
@@ -81,13 +81,13 @@ var mixpanelConfigInterfaceSchema = z.object({
81
81
  }, {
82
82
  invalid_type_error: 'Mixpanel config must be an object with a projectToken property.',
83
83
  });
84
- var pirschConfigInterfaceSchema = z.object({
84
+ const pirschConfigInterfaceSchema = z.object({
85
85
  id: z.string({
86
86
  required_error: 'Pirsch id is missing.',
87
87
  invalid_type_error: 'Pirsch id must be a string.',
88
88
  }),
89
89
  }, { invalid_type_error: 'Pirsch config must be an object with an id property.' });
90
- var postHogConfigInterfaceSchema = z.object({
90
+ const postHogConfigInterfaceSchema = z.object({
91
91
  apiKey: z
92
92
  .string({
93
93
  required_error: 'Posthog apiKey is missing.',
@@ -101,17 +101,17 @@ var postHogConfigInterfaceSchema = z.object({
101
101
  }, {
102
102
  invalid_type_error: 'Posthog config must be an object with an apiKey property.',
103
103
  });
104
- var plausibleConfigInterfaceSchema = z.object({
104
+ const plausibleConfigInterfaceSchema = z.object({
105
105
  domain: z
106
106
  .string({
107
107
  required_error: 'Plausible domain is missing.',
108
108
  invalid_type_error: 'Plausible domain must be a string.',
109
109
  })
110
- .refine(function (domain) { return !domain.startsWith('http://') && !domain.startsWith('https://'); }, 'Plausible domain must not start with http:// or https://'),
110
+ .refine((domain) => !domain.startsWith('http://') && !domain.startsWith('https://'), 'Plausible domain must not start with http:// or https://'),
111
111
  }, {
112
112
  invalid_type_error: 'Plausible config must be an object with a domain property. The domain must not start with http:// or https://.',
113
113
  });
114
- export var analyticsSchema = z
114
+ export const analyticsSchema = z
115
115
  .object({
116
116
  amplitude: amplitudeConfigInterfaceSchema.optional(),
117
117
  clearbit: clearbitConfigInterfaceSchema.optional(),
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { hexadecimalPattern } from '../hexadecimalPattern.js';
3
- export var gradientSchema = z.object({
3
+ export const gradientSchema = z.object({
4
4
  from: z
5
5
  .string({
6
6
  invalid_type_error: 'Anchor color.from must be a string.',
@@ -18,7 +18,7 @@ export var gradientSchema = z.object({
18
18
  })
19
19
  .regex(hexadecimalPattern, 'Anchor color.to must be a hexadecimal color.'),
20
20
  });
21
- export var anchorColorSchema = z.union([
21
+ export const anchorColorSchema = z.union([
22
22
  z
23
23
  .string({ invalid_type_error: 'Anchor color must be a string.' })
24
24
  .regex(hexadecimalPattern, 'Anchor color must be a hexadecimal color.'),
@@ -1,7 +1,7 @@
1
1
  import { iconTypes } from '@mintlify/models';
2
2
  import { z } from 'zod';
3
3
  import { anchorColorSchema } from './anchorColors.js';
4
- export var anchorSchema = z.object({
4
+ export const anchorSchema = z.object({
5
5
  name: z
6
6
  .string({
7
7
  required_error: 'Every anchor must have a name.',
@@ -20,11 +20,11 @@ export var anchorSchema = z.object({
20
20
  .string({
21
21
  invalid_type_error: 'Anchor icon must be the name of a Font Awesome icon. Visit this link to see all the available icons: https://fontawesome.com/icons',
22
22
  })
23
- .refine(function (iconStr) { return !iconStr.startsWith('fa-'); }, 'icon does not need to start with "fa-". Please delete "fa-" and keep the rest of the icon name.')
23
+ .refine((iconStr) => !iconStr.startsWith('fa-'), 'icon does not need to start with "fa-". Please delete "fa-" and keep the rest of the icon name.')
24
24
  .optional(),
25
25
  iconType: z
26
26
  .enum(iconTypes, {
27
- errorMap: function () {
27
+ errorMap: () => {
28
28
  return {
29
29
  message: 'anchor iconType must be one of the following strings: brands, duotone, light, sharp-solid, solid, thin',
30
30
  };
@@ -43,7 +43,7 @@ export var anchorSchema = z.object({
43
43
  })
44
44
  .optional(),
45
45
  });
46
- export var topAnchorSchema = z
46
+ export const topAnchorSchema = z
47
47
  .object({
48
48
  name: z.string({
49
49
  required_error: 'topAnchor.name is missing, set it or delete the entire topAnchor property.',
@@ -56,7 +56,7 @@ export var topAnchorSchema = z
56
56
  .optional(),
57
57
  iconType: z
58
58
  .enum(iconTypes, {
59
- errorMap: function () {
59
+ errorMap: () => {
60
60
  return {
61
61
  message: 'topAnchor.iconType must be one of the following strings: brands, duotone, light, sharp-solid, solid, thin',
62
62
  };
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- export var openApiSchema = z.union([
2
+ export const openApiSchema = z.union([
3
3
  z.string({
4
4
  invalid_type_error: 'openapi must be a string or an array of strings of absolute or relative URLs pointing to your OpenAPI file.',
5
5
  }),
@@ -7,7 +7,7 @@ export var openApiSchema = z.union([
7
7
  invalid_type_error: 'openapi must be a string or an array of strings of absolute or relative URLs pointing to your OpenAPI file.',
8
8
  })),
9
9
  ]);
10
- export var apiSchema = z
10
+ export const apiSchema = z
11
11
  .object({
12
12
  baseUrl: z
13
13
  .union([
@@ -19,7 +19,7 @@ export var apiSchema = z
19
19
  .object({
20
20
  method: z
21
21
  .enum(['bearer', 'basic', 'key', 'cobo'], {
22
- errorMap: function () {
22
+ errorMap: () => {
23
23
  return {
24
24
  message: 'api.auth.method has to be one of: bearer, basic, or key',
25
25
  };
@@ -35,7 +35,7 @@ export var apiSchema = z
35
35
  .object({
36
36
  mode: z
37
37
  .enum(['show', 'simple', 'hide'], {
38
- errorMap: function () {
38
+ errorMap: () => {
39
39
  return {
40
40
  message: 'api.playground.mode must be one of the following strings: show, simple, or hide',
41
41
  };
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
- export var nameSchema = z
2
+ export const nameSchema = z
3
3
  .string({ required_error: 'Name is missing.' })
4
4
  .min(1, 'Name cannot be empty.')
5
5
  .trim();
6
- export var logoSchema = z.union([
6
+ export const logoSchema = z.union([
7
7
  z.string().min(3, 'Logo needs to be a path to your logo file including the file extension.'),
8
8
  z.object({
9
9
  light: z.string(),
@@ -13,10 +13,10 @@ export var logoSchema = z.union([
13
13
  ], {
14
14
  invalid_type_error: 'Logo must be a string or an object with light and dark properties.',
15
15
  });
16
- export var modeToggleSchema = z.object({
16
+ export const modeToggleSchema = z.object({
17
17
  default: z
18
18
  .enum(['light', 'dark'], {
19
- errorMap: function () {
19
+ errorMap: () => {
20
20
  return {
21
21
  message: 'modeToggleSchema.default must be one of the following: light or dark',
22
22
  };
@@ -29,13 +29,13 @@ export var modeToggleSchema = z.object({
29
29
  })
30
30
  .optional(),
31
31
  });
32
- export var isWhiteLabeledSchema = z.boolean({
32
+ export const isWhiteLabeledSchema = z.boolean({
33
33
  invalid_type_error: 'isWhiteLabeled must be a boolean. Try writing true or false without the quotes.',
34
34
  });
35
- export var metadataSchema = z.record(z.string({ invalid_type_error: 'metadata keys must be strings' }), z
35
+ export const metadataSchema = z.record(z.string({ invalid_type_error: 'metadata keys must be strings' }), z
36
36
  .string({ invalid_type_error: 'metadata values must be strings' })
37
37
  .min(1, 'metadata values must not be empty'));
38
- export var footerSocialsSchema = z.union([
38
+ export const footerSocialsSchema = z.union([
39
39
  // TO DO: deprecate array types
40
40
  z.array(z.object({
41
41
  type: z.string(),
@@ -45,7 +45,7 @@ export var footerSocialsSchema = z.union([
45
45
  ], {
46
46
  invalid_type_error: 'footerSocials must be an object where the key is the name of the social media and the value is the url to your profile. For example: { "twitter": "https://twitter.com/mintlify" }',
47
47
  });
48
- export var feedbackSchema = z.object({
48
+ export const feedbackSchema = z.object({
49
49
  thumbsRating: z
50
50
  .boolean({
51
51
  invalid_type_error: 'thumbsRating must be a boolean. Try writing true or false without the quotes.',
@@ -62,61 +62,59 @@ export var feedbackSchema = z.object({
62
62
  })
63
63
  .optional(),
64
64
  });
65
- export var searchSchema = z.object({
65
+ export const searchSchema = z.object({
66
66
  prompt: z
67
67
  .string({
68
68
  invalid_type_error: 'search.prompt must be a string. If this field is undefined, the default prompt is `Search...`',
69
69
  })
70
70
  .optional(),
71
71
  });
72
- var redirectSchema = z.object({
72
+ const redirectSchema = z.object({
73
73
  source: z.string(),
74
74
  destination: z.string(),
75
75
  });
76
- export var redirectsSchema = z
76
+ export const redirectsSchema = z
77
77
  .array(redirectSchema, {
78
78
  invalid_type_error: 'redirects must be an array of objects with source and destination properties',
79
79
  })
80
- .refine(function (value) {
81
- var keys = value.map(function (obj) { return obj.source; });
80
+ .refine((value) => {
81
+ const keys = value.map((obj) => obj.source);
82
82
  return new Set(keys).size === keys.length;
83
83
  }, {
84
84
  message: 'Sources in the array must be unique.',
85
85
  });
86
- export var createCtaButtonSchema = function (ctaButtonName) {
87
- return z.union([
88
- z
89
- .object({
90
- type: z.literal('link').optional(),
91
- name: z.string({
92
- required_error: 'Name must be defined when using a CTA button',
93
- invalid_type_error: 'Name must be a string',
94
- }),
95
- url: z
96
- .string({
97
- required_error: ctaButtonName + '.url is missing',
98
- invalid_type_error: ctaButtonName + '.url must be a string',
99
- })
100
- .min(1, ctaButtonName + '.url cannot be empty'),
86
+ export const createCtaButtonSchema = (ctaButtonName) => z.union([
87
+ z
88
+ .object({
89
+ type: z.literal('link').optional(),
90
+ name: z.string({
91
+ required_error: 'Name must be defined when using a CTA button',
92
+ invalid_type_error: 'Name must be a string',
93
+ }),
94
+ url: z
95
+ .string({
96
+ required_error: ctaButtonName + '.url is missing',
97
+ invalid_type_error: ctaButtonName + '.url must be a string',
101
98
  })
102
- .strict(ctaButtonName +
103
- ' can only contain name, url, and type properties. Set a different type if you need to set other fields.'),
104
- z
105
- .object({
106
- type: z.literal('github'),
107
- url: z
108
- .string({
109
- required_error: ctaButtonName +
110
- '.url is missing. Please set the url to a link to your GitHub repository.',
111
- invalid_type_error: ctaButtonName +
112
- '.url must be a string. Specifically, set the url to a link to your GitHub repository.',
113
- })
114
- .url(ctaButtonName + '.url must be a valid url pointing to your GitHub repository.'),
99
+ .min(1, ctaButtonName + '.url cannot be empty'),
100
+ })
101
+ .strict(ctaButtonName +
102
+ ' can only contain name, url, and type properties. Set a different type if you need to set other fields.'),
103
+ z
104
+ .object({
105
+ type: z.literal('github'),
106
+ url: z
107
+ .string({
108
+ required_error: ctaButtonName +
109
+ '.url is missing. Please set the url to a link to your GitHub repository.',
110
+ invalid_type_error: ctaButtonName +
111
+ '.url must be a string. Specifically, set the url to a link to your GitHub repository.',
115
112
  })
116
- .strict(ctaButtonName +
117
- ' can only contain url and type properties when type="github". Please delete any other properties you have set.'),
118
- ], {
119
- invalid_type_error: ctaButtonName +
120
- ' must be an object. The object can have type="link" (the default) if you define a url and a name. You can also have type="github" if you define a url pointing to your GitHub repo and set the type in the object.',
121
- });
122
- };
113
+ .url(ctaButtonName + '.url must be a valid url pointing to your GitHub repository.'),
114
+ })
115
+ .strict(ctaButtonName +
116
+ ' can only contain url and type properties when type="github". Please delete any other properties you have set.'),
117
+ ], {
118
+ invalid_type_error: ctaButtonName +
119
+ ' must be an object. The object can have type="link" (the default) if you define a url and a name. You can also have type="github" if you define a url pointing to your GitHub repo and set the type in the object.',
120
+ });
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { hexadecimalPattern } from '../hexadecimalPattern.js';
3
3
  import { anchorColorSchema } from './anchorColors.js';
4
- export var colorsSchema = z
4
+ export const colorsSchema = z
5
5
  .object({
6
6
  primary: z
7
7
  .string({ invalid_type_error: 'Primary color must be a string.' })
@@ -9,7 +9,7 @@ import { integrationsSchema } from './integrations.js';
9
9
  import { navigationSchema } from './navigation.js';
10
10
  import { tabsSchema, primaryTabSchema } from './tabs.js';
11
11
  import { versionsSchema } from './versions.js';
12
- export var configSchema = z.object({
12
+ export const configSchema = z.object({
13
13
  $schema: z.string().url().optional().default('https://mintlify.com/schema.json'),
14
14
  mintlify: z.string().optional(),
15
15
  name: nameSchema,
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
- export var faviconSchema = z
2
+ export const faviconSchema = z
3
3
  .string({
4
4
  required_error: 'Favicon is missing. Please set favicon to the path of your favicon file. We recommend using a .svg or .png file. Mintlify automatically resizes your favicon to the sizes needed.',
5
5
  invalid_type_error: 'Favicon must be a string path pointing to the favicon file in your Mintlify folder.',
6
6
  })
7
- .refine(function (val) { return val.split('.').pop() !== 'ico'; }, {
7
+ .refine((val) => val.split('.').pop() !== 'ico', {
8
8
  message: 'Favicon cannot be an .ico file.',
9
9
  });
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
- var intercomSchema = z
2
+ const intercomSchema = z
3
3
  .string({ invalid_type_error: 'integrations.intercom must be a string' })
4
4
  .min(6, 'integrations.intercom must be a valid Intercom app ID');
5
- var frontchatSchema = z
5
+ const frontchatSchema = z
6
6
  .string({ invalid_type_error: 'integrations.frontchat must be a string' })
7
7
  .min(6, 'integrations.frontchat must be a valid Front chat snippet id');
8
- export var integrationsSchema = z.object({
8
+ export const integrationsSchema = z.object({
9
9
  intercom: intercomSchema.optional(),
10
10
  frontchat: frontchatSchema.optional(),
11
11
  }, { invalid_type_error: 'integrations must be an object' });
@@ -1,7 +1,7 @@
1
1
  import { iconTypes } from '@mintlify/models';
2
2
  import { z } from 'zod';
3
3
  // export to allow type testing against @mintlify/models
4
- export var baseNavigationGroupSchema = z
4
+ export const baseNavigationGroupSchema = z
5
5
  .object({
6
6
  // We allow top-level groups to be an empty string if the user wants to hide the title.
7
7
  // Future work should refactor this so nested groups are non-empty strings.
@@ -12,7 +12,7 @@ export var baseNavigationGroupSchema = z
12
12
  icon: z.string({ invalid_type_error: 'Icon must be a string.' }).optional(),
13
13
  iconType: z
14
14
  .enum(iconTypes, {
15
- errorMap: function () {
15
+ errorMap: () => {
16
16
  return {
17
17
  message: 'group iconType must be one of the following strings: brands, duotone, light, sharp-solid, solid, thin',
18
18
  };
@@ -22,14 +22,12 @@ export var baseNavigationGroupSchema = z
22
22
  version: z.string({ invalid_type_error: 'Version must be a string.' }).optional(),
23
23
  }, { invalid_type_error: 'Navigation entry must be an object.' })
24
24
  .strict('Navigation entry can only contain group, pages, icon, and version.');
25
- var navigationGroupSchema = baseNavigationGroupSchema.extend({
26
- pages: z.lazy(function () {
27
- return z
28
- .array(z.union([navigationGroupSchema, z.string().min(1, 'Page cannot be an empty string.')]))
29
- .min(1, "Pages array can't be empty.");
30
- }),
25
+ const navigationGroupSchema = baseNavigationGroupSchema.extend({
26
+ pages: z.lazy(() => z
27
+ .array(z.union([navigationGroupSchema, z.string().min(1, 'Page cannot be an empty string.')]))
28
+ .min(1, "Pages array can't be empty.")),
31
29
  });
32
- export var navigationSchema = z
30
+ export const navigationSchema = z
33
31
  .array(navigationGroupSchema, {
34
32
  required_error: 'Navigation is missing.',
35
33
  invalid_type_error: 'Navigation must be an array.',
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- var tabSchema = z.object({
2
+ const tabSchema = z.object({
3
3
  name: z
4
4
  .string({
5
5
  required_error: 'Every tab must have a name.',
@@ -15,8 +15,8 @@ var tabSchema = z.object({
15
15
  .trim()
16
16
  .min(1, 'Tab URL is missing.'),
17
17
  });
18
- export var tabsSchema = tabSchema.array();
19
- export var primaryTabSchema = z
18
+ export const tabsSchema = tabSchema.array();
19
+ export const primaryTabSchema = z
20
20
  .object({
21
21
  name: z.string({
22
22
  required_error: 'primaryTab.name is missing, set it or delete the entire primaryTab property.',
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- var versionSchema = z.union([
2
+ const versionSchema = z.union([
3
3
  z.string({ invalid_type_error: 'Versions must be an array of strings.' }),
4
4
  z
5
5
  .object({
@@ -8,6 +8,6 @@ var versionSchema = z.union([
8
8
  })
9
9
  .strict('Object must contain name and url properties'),
10
10
  ]);
11
- export var versionsSchema = z
11
+ export const versionsSchema = z
12
12
  .array(versionSchema)
13
13
  .min(1, 'Versions array cannot be empty. Either delete the property or add strings to the array.');
@@ -1,16 +1,16 @@
1
1
  import { MintValidationResults } from './common.js';
2
2
  import { navigationSchema } from './schemas/navigation.js';
3
3
  export function validateAnchorsWarnings(anchors, navigation) {
4
- var results = new MintValidationResults();
4
+ const results = new MintValidationResults();
5
5
  if (anchors &&
6
6
  Array.isArray(anchors) &&
7
7
  navigation &&
8
8
  navigationSchema.safeParse(navigation).success) {
9
- anchors.forEach(function (anchor) {
9
+ anchors.forEach((anchor) => {
10
10
  if (!anchor.url.startsWith('mailto:') &&
11
11
  !anchor.url.startsWith('http') &&
12
12
  !anchor.url.startsWith('https') &&
13
- !navigation.some(function (nav) { return pageStartsWith(nav, anchor.url); })) {
13
+ !navigation.some((nav) => pageStartsWith(nav, anchor.url))) {
14
14
  results.warnings.push('No pages in the navigation match anchor ' +
15
15
  anchor.url +
16
16
  ' you should have at least one page that starts with ' +
@@ -28,7 +28,7 @@ function pageStartsWith(navEntry, prefix) {
28
28
  return false;
29
29
  }
30
30
  else {
31
- return navEntry.pages.some(function (entry) {
31
+ return navEntry.pages.some((entry) => {
32
32
  return pageStartsWith(entry, prefix);
33
33
  });
34
34
  }