@mintlify/validation 0.1.58 → 0.1.60

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.
Files changed (49) hide show
  1. package/dist/index.d.ts +5 -6
  2. package/dist/index.js +62 -2
  3. package/dist/mint-config/common.js +9 -0
  4. package/dist/mint-config/flattenUnionErrorMessages.js +19 -0
  5. package/dist/mint-config/hexadecimalPattern.js +1 -0
  6. package/dist/mint-config/schemas/analytics.d.ts +0 -104
  7. package/dist/mint-config/schemas/analytics.js +129 -0
  8. package/dist/mint-config/schemas/anchorColors.d.ts +0 -1
  9. package/dist/mint-config/schemas/anchorColors.js +28 -0
  10. package/dist/mint-config/schemas/anchors.d.ts +7 -56
  11. package/dist/mint-config/schemas/anchors.js +69 -0
  12. package/dist/mint-config/schemas/apiReference.d.ts +0 -2
  13. package/dist/mint-config/schemas/apiReference.js +65 -0
  14. package/dist/mint-config/schemas/basics.d.ts +0 -11
  15. package/dist/mint-config/schemas/basics.js +122 -0
  16. package/dist/mint-config/schemas/colors.d.ts +0 -1
  17. package/dist/mint-config/schemas/colors.js +42 -0
  18. package/dist/mint-config/schemas/config.d.ts +18 -19
  19. package/dist/mint-config/schemas/config.js +39 -0
  20. package/dist/mint-config/schemas/favicon.js +9 -0
  21. package/dist/mint-config/schemas/integrations.d.ts +0 -6
  22. package/dist/mint-config/schemas/integrations.js +11 -0
  23. package/dist/mint-config/schemas/navigation.d.ts +15 -2
  24. package/dist/mint-config/schemas/navigation.js +27 -0
  25. package/dist/mint-config/schemas/tabs.d.ts +0 -13
  26. package/dist/mint-config/schemas/tabs.js +28 -0
  27. package/dist/mint-config/schemas/versions.d.ts +0 -13
  28. package/dist/mint-config/schemas/versions.js +13 -0
  29. package/dist/mint-config/validateAnchorsWarnings.d.ts +3 -4
  30. package/dist/mint-config/validateAnchorsWarnings.js +35 -0
  31. package/dist/mint-config/validateVersionsInNavigation.d.ts +4 -5
  32. package/dist/mint-config/validateVersionsInNavigation.js +55 -0
  33. package/dist/openapi/convertOpenApi.d.ts +1 -1
  34. package/dist/openapi/convertOpenApi.js +166 -0
  35. package/dist/openapi/convertParameters.d.ts +1 -1
  36. package/dist/openapi/convertParameters.js +60 -0
  37. package/dist/openapi/convertSchema.d.ts +1 -1
  38. package/dist/openapi/convertSchema.js +475 -0
  39. package/dist/openapi/convertSecurity.d.ts +1 -1
  40. package/dist/openapi/convertSecurity.js +82 -0
  41. package/dist/openapi/convertServers.d.ts +1 -1
  42. package/dist/openapi/convertServers.js +43 -0
  43. package/dist/openapi/types/endpoint.js +13 -0
  44. package/dist/tsconfig.build.tsbuildinfo +1 -0
  45. package/package.json +18 -11
  46. package/dist/index.js.LICENSE.txt +0 -8
  47. package/dist/mint-config/types/enums.d.ts +0 -4
  48. package/dist/mint-config/types/index.d.ts +0 -12
  49. package/dist/mint-config/types/navigation.d.ts +0 -13
@@ -0,0 +1,122 @@
1
+ import { z } from 'zod';
2
+ export var nameSchema = z
3
+ .string({ required_error: 'Name is missing.' })
4
+ .min(1, 'Name cannot be empty.')
5
+ .trim();
6
+ export var logoSchema = z.union([
7
+ z.string().min(3, 'Logo needs to be a path to your logo file including the file extension.'),
8
+ z.object({
9
+ light: z.string(),
10
+ dark: z.string(),
11
+ href: z.string().optional(),
12
+ }),
13
+ ], {
14
+ invalid_type_error: 'Logo must be a string or an object with light and dark properties.',
15
+ });
16
+ export var modeToggleSchema = z.object({
17
+ default: z
18
+ .enum(['light', 'dark'], {
19
+ errorMap: function () {
20
+ return {
21
+ message: 'modeToggleSchema.default must be one of the following: light or dark',
22
+ };
23
+ },
24
+ })
25
+ .optional(),
26
+ isHidden: z
27
+ .boolean({
28
+ invalid_type_error: 'isHidden must be a boolean. Try writing true or false without the quotes.',
29
+ })
30
+ .optional(),
31
+ });
32
+ export var isWhiteLabeledSchema = z.boolean({
33
+ invalid_type_error: 'isWhiteLabeled must be a boolean. Try writing true or false without the quotes.',
34
+ });
35
+ export var metadataSchema = z.record(z.string({ invalid_type_error: 'metadata keys must be strings' }), z
36
+ .string({ invalid_type_error: 'metadata values must be strings' })
37
+ .min(1, 'metadata values must not be empty'));
38
+ export var footerSocialsSchema = z.union([
39
+ // TO DO: deprecate array types
40
+ z.array(z.object({
41
+ type: z.string(),
42
+ url: z.string().url('footerSocials url must be a valid url'),
43
+ })),
44
+ z.record(z.string().trim().min(1, 'footerSocials name (the key in the object) must not be empty'), z.string().url('footerSocials url (the value in the object) must be a valid url')),
45
+ ], {
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
+ });
48
+ export var feedbackSchema = z.object({
49
+ thumbsRating: z
50
+ .boolean({
51
+ invalid_type_error: 'thumbsRating must be a boolean. Try writing true or false without the quotes.',
52
+ })
53
+ .optional(),
54
+ suggestEdit: z
55
+ .boolean({
56
+ invalid_type_error: 'suggestEdit must be a boolean. Try writing true or false without the quotes.',
57
+ })
58
+ .optional(),
59
+ raiseIssue: z
60
+ .boolean({
61
+ invalid_type_error: 'raiseIssue must be a boolean. Try writing true or false without the quotes.',
62
+ })
63
+ .optional(),
64
+ });
65
+ export var searchSchema = z.object({
66
+ prompt: z
67
+ .string({
68
+ invalid_type_error: 'search.prompt must be a string. If this field is undefined, the default prompt is `Search...`',
69
+ })
70
+ .optional(),
71
+ });
72
+ var redirectSchema = z.object({
73
+ source: z.string(),
74
+ destination: z.string(),
75
+ });
76
+ export var redirectsSchema = z
77
+ .array(redirectSchema, {
78
+ invalid_type_error: 'redirects must be an array of objects with source and destination properties',
79
+ })
80
+ .refine(function (value) {
81
+ var keys = value.map(function (obj) { return obj.source; });
82
+ return new Set(keys).size === keys.length;
83
+ }, {
84
+ message: 'Sources in the array must be unique.',
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'),
101
+ })
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.'),
115
+ })
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
+ };
@@ -59,4 +59,3 @@ export declare const colorsSchema: z.ZodObject<{
59
59
  ultraLight?: any;
60
60
  ultraDark?: any;
61
61
  }>;
62
- export type ColorsType = z.infer<typeof colorsSchema>;
@@ -0,0 +1,42 @@
1
+ import { z } from 'zod';
2
+ import { hexadecimalPattern } from '../hexadecimalPattern.js';
3
+ import { anchorColorSchema } from './anchorColors.js';
4
+ export var colorsSchema = z
5
+ .object({
6
+ primary: z
7
+ .string({ invalid_type_error: 'Primary color must be a string.' })
8
+ .min(1, 'Color primary is missing.')
9
+ .regex(hexadecimalPattern, 'Primary color must be a hexadecimal color including the # at the start.'),
10
+ light: z
11
+ .string({ invalid_type_error: 'Light color must be a string.' })
12
+ .regex(hexadecimalPattern, 'Light color must be a hexadecimal color including the # at the start.')
13
+ .optional(),
14
+ dark: z
15
+ .string({ invalid_type_error: 'Dark color must be a string.' })
16
+ .regex(hexadecimalPattern, 'Dark color must be a hexadecimal color including the # at the start.')
17
+ .optional(),
18
+ background: z
19
+ .object({
20
+ light: z
21
+ .string({
22
+ invalid_type_error: 'Background light color must be a string.',
23
+ })
24
+ .regex(hexadecimalPattern, 'Background light color must be a hexadecimal color including the # at the start.')
25
+ .optional(),
26
+ dark: z
27
+ .string({
28
+ invalid_type_error: 'Background dark color must be a string.',
29
+ })
30
+ .regex(hexadecimalPattern, 'Background dark color must be a hexadecimal color including the # at the start.')
31
+ .optional(),
32
+ })
33
+ .optional(),
34
+ anchors: anchorColorSchema.optional(),
35
+ // Prevent strict() from throwing an error when the user defines a deprecated ultraLight / ultraDark color.
36
+ ultraLight: z.any().optional(),
37
+ ultraDark: z.any().optional(),
38
+ }, {
39
+ required_error: 'Colors are missing. You need to define at least the primary color. For example: { "colors": { "primary": "#ff0000" } }',
40
+ invalid_type_error: 'Colors must be an object.',
41
+ })
42
+ .strict('Some of the colors in mint.json are invalid, did you make a typo? We only accept primary, light, dark, background, and anchors.');
@@ -216,7 +216,7 @@ export declare const configSchema: z.ZodObject<{
216
216
  type: "github";
217
217
  url: string;
218
218
  }>]>, "many">>;
219
- navigation: z.ZodArray<z.ZodType<import("../types").MintNavigationGroup, z.ZodTypeDef, import("../types").MintNavigationGroup>, "many">;
219
+ navigation: z.ZodArray<z.ZodType<import("@mintlify/models").NavigationGroup, z.ZodTypeDef, import("@mintlify/models").NavigationGroup>, "many">;
220
220
  primaryTab: z.ZodOptional<z.ZodObject<{
221
221
  name: z.ZodString;
222
222
  }, "strict", z.ZodTypeAny, {
@@ -227,21 +227,21 @@ export declare const configSchema: z.ZodObject<{
227
227
  topAnchor: z.ZodOptional<z.ZodObject<{
228
228
  name: z.ZodString;
229
229
  icon: z.ZodOptional<z.ZodString>;
230
- iconType: z.ZodOptional<z.ZodEnum<["brands", "duotone", "light", "sharp-solid", "solid", "thin"]>>;
230
+ iconType: z.ZodOptional<z.ZodEnum<["brands", "duotone", "light", "regular", "sharp-solid", "solid", "thin"]>>;
231
231
  }, "strict", z.ZodTypeAny, {
232
232
  name: string;
233
233
  icon?: string | undefined;
234
- iconType?: "light" | "brands" | "duotone" | "sharp-solid" | "solid" | "thin" | undefined;
234
+ iconType?: "brands" | "duotone" | "light" | "regular" | "sharp-solid" | "solid" | "thin" | undefined;
235
235
  }, {
236
236
  name: string;
237
237
  icon?: string | undefined;
238
- iconType?: "light" | "brands" | "duotone" | "sharp-solid" | "solid" | "thin" | undefined;
238
+ iconType?: "brands" | "duotone" | "light" | "regular" | "sharp-solid" | "solid" | "thin" | undefined;
239
239
  }>>;
240
240
  anchors: z.ZodOptional<z.ZodArray<z.ZodObject<{
241
241
  name: z.ZodString;
242
242
  url: z.ZodString;
243
243
  icon: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
244
- iconType: z.ZodOptional<z.ZodEnum<["brands", "duotone", "light", "sharp-solid", "solid", "thin"]>>;
244
+ iconType: z.ZodOptional<z.ZodEnum<["brands", "duotone", "light", "regular", "sharp-solid", "solid", "thin"]>>;
245
245
  color: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
246
246
  from: z.ZodString;
247
247
  via: z.ZodOptional<z.ZodString>;
@@ -261,7 +261,7 @@ export declare const configSchema: z.ZodObject<{
261
261
  name: string;
262
262
  url: string;
263
263
  icon?: string | undefined;
264
- iconType?: "light" | "brands" | "duotone" | "sharp-solid" | "solid" | "thin" | undefined;
264
+ iconType?: "brands" | "duotone" | "light" | "regular" | "sharp-solid" | "solid" | "thin" | undefined;
265
265
  color?: string | {
266
266
  from: string;
267
267
  to: string;
@@ -273,7 +273,7 @@ export declare const configSchema: z.ZodObject<{
273
273
  name: string;
274
274
  url: string;
275
275
  icon?: string | undefined;
276
- iconType?: "light" | "brands" | "duotone" | "sharp-solid" | "solid" | "thin" | undefined;
276
+ iconType?: "brands" | "duotone" | "light" | "regular" | "sharp-solid" | "solid" | "thin" | undefined;
277
277
  color?: string | {
278
278
  from: string;
279
279
  to: string;
@@ -521,8 +521,8 @@ export declare const configSchema: z.ZodObject<{
521
521
  destination: string;
522
522
  }[]>>;
523
523
  }, "strip", z.ZodTypeAny, {
524
- $schema: string;
525
524
  name: string;
525
+ $schema: string;
526
526
  favicon: string;
527
527
  colors: {
528
528
  primary: string;
@@ -540,7 +540,7 @@ export declare const configSchema: z.ZodObject<{
540
540
  ultraLight?: any;
541
541
  ultraDark?: any;
542
542
  };
543
- navigation: import("../types").MintNavigationGroup[];
543
+ navigation: import("@mintlify/models").NavigationGroup[];
544
544
  mintlify?: string | undefined;
545
545
  logo?: string | {
546
546
  light: string;
@@ -596,13 +596,13 @@ export declare const configSchema: z.ZodObject<{
596
596
  topAnchor?: {
597
597
  name: string;
598
598
  icon?: string | undefined;
599
- iconType?: "light" | "brands" | "duotone" | "sharp-solid" | "solid" | "thin" | undefined;
599
+ iconType?: "brands" | "duotone" | "light" | "regular" | "sharp-solid" | "solid" | "thin" | undefined;
600
600
  } | undefined;
601
601
  anchors?: {
602
602
  name: string;
603
603
  url: string;
604
604
  icon?: string | undefined;
605
- iconType?: "light" | "brands" | "duotone" | "sharp-solid" | "solid" | "thin" | undefined;
605
+ iconType?: "brands" | "duotone" | "light" | "regular" | "sharp-solid" | "solid" | "thin" | undefined;
606
606
  color?: string | {
607
607
  from: string;
608
608
  to: string;
@@ -615,10 +615,10 @@ export declare const configSchema: z.ZodObject<{
615
615
  name: string;
616
616
  url: string;
617
617
  }[] | undefined;
618
- footerSocials?: Record<string, string> | {
618
+ footerSocials?: {
619
619
  type: string;
620
620
  url: string;
621
- }[] | undefined;
621
+ }[] | Record<string, string> | undefined;
622
622
  backgroundImage?: string | undefined;
623
623
  feedback?: {
624
624
  thumbsRating?: boolean | undefined;
@@ -696,7 +696,7 @@ export declare const configSchema: z.ZodObject<{
696
696
  ultraLight?: any;
697
697
  ultraDark?: any;
698
698
  };
699
- navigation: import("../types").MintNavigationGroup[];
699
+ navigation: import("@mintlify/models").NavigationGroup[];
700
700
  $schema?: string | undefined;
701
701
  mintlify?: string | undefined;
702
702
  logo?: string | {
@@ -753,13 +753,13 @@ export declare const configSchema: z.ZodObject<{
753
753
  topAnchor?: {
754
754
  name: string;
755
755
  icon?: string | undefined;
756
- iconType?: "light" | "brands" | "duotone" | "sharp-solid" | "solid" | "thin" | undefined;
756
+ iconType?: "brands" | "duotone" | "light" | "regular" | "sharp-solid" | "solid" | "thin" | undefined;
757
757
  } | undefined;
758
758
  anchors?: {
759
759
  name: string;
760
760
  url: string;
761
761
  icon?: string | undefined;
762
- iconType?: "light" | "brands" | "duotone" | "sharp-solid" | "solid" | "thin" | undefined;
762
+ iconType?: "brands" | "duotone" | "light" | "regular" | "sharp-solid" | "solid" | "thin" | undefined;
763
763
  color?: string | {
764
764
  from: string;
765
765
  to: string;
@@ -772,10 +772,10 @@ export declare const configSchema: z.ZodObject<{
772
772
  name: string;
773
773
  url: string;
774
774
  }[] | undefined;
775
- footerSocials?: Record<string, string> | {
775
+ footerSocials?: {
776
776
  type: string;
777
777
  url: string;
778
- }[] | undefined;
778
+ }[] | Record<string, string> | undefined;
779
779
  backgroundImage?: string | undefined;
780
780
  feedback?: {
781
781
  thumbsRating?: boolean | undefined;
@@ -835,4 +835,3 @@ export declare const configSchema: z.ZodObject<{
835
835
  destination: string;
836
836
  }[] | undefined;
837
837
  }>;
838
- export type ConfigType = z.infer<typeof configSchema>;
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ import { analyticsSchema } from './analytics.js';
3
+ import { anchorSchema, topAnchorSchema } from './anchors.js';
4
+ import { apiSchema, openApiSchema } from './apiReference.js';
5
+ import { nameSchema, logoSchema, modeToggleSchema, isWhiteLabeledSchema, footerSocialsSchema, feedbackSchema, metadataSchema, createCtaButtonSchema, searchSchema, redirectsSchema, } from './basics.js';
6
+ import { colorsSchema } from './colors.js';
7
+ import { faviconSchema } from './favicon.js';
8
+ import { integrationsSchema } from './integrations.js';
9
+ import { navigationSchema } from './navigation.js';
10
+ import { tabsSchema, primaryTabSchema } from './tabs.js';
11
+ import { versionsSchema } from './versions.js';
12
+ export var configSchema = z.object({
13
+ $schema: z.string().url().optional().default('https://mintlify.com/schema.json'),
14
+ mintlify: z.string().optional(),
15
+ name: nameSchema,
16
+ logo: logoSchema.optional(),
17
+ favicon: faviconSchema,
18
+ openapi: openApiSchema.optional(),
19
+ api: apiSchema.optional(),
20
+ modeToggle: modeToggleSchema.optional(),
21
+ versions: versionsSchema.optional(),
22
+ metadata: metadataSchema.optional(),
23
+ colors: colorsSchema,
24
+ topbarCtaButton: createCtaButtonSchema('topbarCtaButton').optional(),
25
+ topbarLinks: createCtaButtonSchema('topbarLinks').array().optional(),
26
+ navigation: navigationSchema,
27
+ primaryTab: primaryTabSchema.optional(),
28
+ topAnchor: topAnchorSchema.optional(),
29
+ anchors: anchorSchema.array().optional(),
30
+ tabs: tabsSchema.optional(),
31
+ footerSocials: footerSocialsSchema.optional(),
32
+ backgroundImage: z.string().optional(),
33
+ feedback: feedbackSchema.optional(),
34
+ analytics: analyticsSchema.optional(),
35
+ integrations: integrationsSchema.optional(),
36
+ isWhiteLabeled: isWhiteLabeledSchema.optional(),
37
+ search: searchSchema.optional(),
38
+ redirects: redirectsSchema.optional(),
39
+ });
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export var faviconSchema = z
3
+ .string({
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
+ invalid_type_error: 'Favicon must be a string path pointing to the favicon file in your Mintlify folder.',
6
+ })
7
+ .refine(function (val) { return val.split('.').pop() !== 'ico'; }, {
8
+ message: 'Favicon cannot be an .ico file.',
9
+ });
@@ -1,6 +1,4 @@
1
1
  import { z } from 'zod';
2
- declare const intercomSchema: z.ZodString;
3
- declare const frontchatSchema: z.ZodString;
4
2
  export declare const integrationsSchema: z.ZodObject<{
5
3
  intercom: z.ZodOptional<z.ZodString>;
6
4
  frontchat: z.ZodOptional<z.ZodString>;
@@ -11,7 +9,3 @@ export declare const integrationsSchema: z.ZodObject<{
11
9
  intercom?: string | undefined;
12
10
  frontchat?: string | undefined;
13
11
  }>;
14
- export type IntercomType = z.infer<typeof intercomSchema>;
15
- export type FrontchatType = z.infer<typeof frontchatSchema>;
16
- export type IntegrationsType = z.infer<typeof integrationsSchema>;
17
- export {};
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ var intercomSchema = z
3
+ .string({ invalid_type_error: 'integrations.intercom must be a string' })
4
+ .min(6, 'integrations.intercom must be a valid Intercom app ID');
5
+ var frontchatSchema = z
6
+ .string({ invalid_type_error: 'integrations.frontchat must be a string' })
7
+ .min(6, 'integrations.frontchat must be a valid Front chat snippet id');
8
+ export var integrationsSchema = z.object({
9
+ intercom: intercomSchema.optional(),
10
+ frontchat: frontchatSchema.optional(),
11
+ }, { invalid_type_error: 'integrations must be an object' });
@@ -1,3 +1,16 @@
1
+ import { NavigationGroup } from '@mintlify/models';
1
2
  import { z } from 'zod';
2
- import { MintNavigationGroup } from '../types/navigation';
3
- export declare const navigationConfigSchema: z.ZodArray<z.ZodType<MintNavigationGroup, z.ZodTypeDef, MintNavigationGroup>, "many">;
3
+ export declare const baseNavigationGroupSchema: z.ZodObject<{
4
+ group: z.ZodString;
5
+ icon: z.ZodOptional<z.ZodString>;
6
+ version: z.ZodOptional<z.ZodString>;
7
+ }, "strict", z.ZodTypeAny, {
8
+ group: string;
9
+ icon?: string | undefined;
10
+ version?: string | undefined;
11
+ }, {
12
+ group: string;
13
+ icon?: string | undefined;
14
+ version?: string | undefined;
15
+ }>;
16
+ export declare const navigationSchema: z.ZodArray<z.ZodType<NavigationGroup, z.ZodTypeDef, NavigationGroup>, "many">;
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ // export to allow type testing against @mintlify/models
3
+ export var baseNavigationGroupSchema = z
4
+ .object({
5
+ // We allow top-level groups to be an empty string if the user wants to hide the title.
6
+ // Future work should refactor this so nested groups are non-empty strings.
7
+ group: z.string({
8
+ required_error: 'Missing navigation group name.',
9
+ invalid_type_error: 'Group must be a string. We use the group name to create the navigation sidebar.',
10
+ }),
11
+ icon: z.string({ invalid_type_error: 'Icon must be a string.' }).optional(),
12
+ version: z.string({ invalid_type_error: 'Version must be a string.' }).optional(),
13
+ }, { invalid_type_error: 'Navigation entry must be an object.' })
14
+ .strict('Navigation entry can only contain group, pages, icon, and version.');
15
+ var navigationGroupSchema = baseNavigationGroupSchema.extend({
16
+ pages: z.lazy(function () {
17
+ return z
18
+ .array(z.union([navigationGroupSchema, z.string().min(1, 'Page cannot be an empty string.')]))
19
+ .min(1, "Pages array can't be empty.");
20
+ }),
21
+ });
22
+ export var navigationSchema = z
23
+ .array(navigationGroupSchema, {
24
+ required_error: 'Navigation is missing.',
25
+ invalid_type_error: 'Navigation must be an array.',
26
+ })
27
+ .min(1, 'Navigation cannot be an empty array. Please add at least one group.');
@@ -1,15 +1,4 @@
1
1
  import { z } from 'zod';
2
- declare const tabSchema: z.ZodObject<{
3
- name: z.ZodString;
4
- url: z.ZodString;
5
- }, "strip", z.ZodTypeAny, {
6
- name: string;
7
- url: string;
8
- }, {
9
- name: string;
10
- url: string;
11
- }>;
12
- export type TabType = z.infer<typeof tabSchema>;
13
2
  export declare const tabsSchema: z.ZodArray<z.ZodObject<{
14
3
  name: z.ZodString;
15
4
  url: z.ZodString;
@@ -27,5 +16,3 @@ export declare const primaryTabSchema: z.ZodObject<{
27
16
  }, {
28
17
  name: string;
29
18
  }>;
30
- export type PrimaryTabType = z.infer<typeof primaryTabSchema>;
31
- export {};
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ var tabSchema = z.object({
3
+ name: z
4
+ .string({
5
+ required_error: 'Every tab must have a name.',
6
+ invalid_type_error: 'Tab name must be a string.',
7
+ })
8
+ .trim()
9
+ .min(1, 'Tab name is empty.'),
10
+ url: z
11
+ .string({
12
+ required_error: 'Every tab must have a url',
13
+ invalid_type_error: 'Tab url must be a string.',
14
+ })
15
+ .trim()
16
+ .min(1, 'Tab URL is missing.'),
17
+ });
18
+ export var tabsSchema = tabSchema.array();
19
+ export var primaryTabSchema = z
20
+ .object({
21
+ name: z.string({
22
+ required_error: 'primaryTab.name is missing, set it or delete the entire primaryTab property.',
23
+ invalid_type_error: 'primaryTab.name must be a string',
24
+ }),
25
+ }, {
26
+ invalid_type_error: 'primaryTab must be an object with a name property.',
27
+ })
28
+ .strict('primaryTab can only have name properties.');
@@ -1,14 +1,4 @@
1
1
  import { z } from 'zod';
2
- declare const versionSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
3
- name: z.ZodString;
4
- url: z.ZodString;
5
- }, "strict", z.ZodTypeAny, {
6
- name: string;
7
- url: string;
8
- }, {
9
- name: string;
10
- url: string;
11
- }>]>;
12
2
  export declare const versionsSchema: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
13
3
  name: z.ZodString;
14
4
  url: z.ZodString;
@@ -19,6 +9,3 @@ export declare const versionsSchema: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodOb
19
9
  name: string;
20
10
  url: string;
21
11
  }>]>, "many">;
22
- export type VersionType = z.infer<typeof versionSchema>;
23
- export type VersionsType = z.infer<typeof versionsSchema>;
24
- export {};
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ var versionSchema = z.union([
3
+ z.string({ invalid_type_error: 'Versions must be an array of strings.' }),
4
+ z
5
+ .object({
6
+ name: z.string().min(1, 'Name cannot be an empty string.'),
7
+ url: z.string().min(1, 'URL cannot be an empty string.'),
8
+ })
9
+ .strict('Object must contain name and url properties'),
10
+ ]);
11
+ export var versionsSchema = z
12
+ .array(versionSchema)
13
+ .min(1, 'Versions array cannot be empty. Either delete the property or add strings to the array.');
@@ -1,4 +1,3 @@
1
- import { MintValidationResults } from './common';
2
- import { AnchorsType } from './schemas/anchors';
3
- import { MintNavigation } from './types/navigation';
4
- export declare function validateAnchorsWarnings(anchors: AnchorsType | undefined, navigation: MintNavigation | undefined): MintValidationResults;
1
+ import { Anchor, Navigation } from '@mintlify/models';
2
+ import { MintValidationResults } from './common.js';
3
+ export declare function validateAnchorsWarnings(anchors: Anchor[] | undefined, navigation: Navigation | undefined): MintValidationResults;
@@ -0,0 +1,35 @@
1
+ import { MintValidationResults } from './common.js';
2
+ import { navigationSchema } from './schemas/navigation.js';
3
+ export function validateAnchorsWarnings(anchors, navigation) {
4
+ var results = new MintValidationResults();
5
+ if (anchors &&
6
+ Array.isArray(anchors) &&
7
+ navigation &&
8
+ navigationSchema.safeParse(navigation).success) {
9
+ anchors.forEach(function (anchor) {
10
+ if (!anchor.url.startsWith('mailto:') &&
11
+ !anchor.url.startsWith('http') &&
12
+ !anchor.url.startsWith('https') &&
13
+ !navigation.some(function (nav) { return pageStartsWith(nav, anchor.url); })) {
14
+ results.warnings.push('No pages in the navigation match anchor ' +
15
+ anchor.url +
16
+ ' you should have at least one page that starts with ' +
17
+ anchor.url);
18
+ }
19
+ });
20
+ }
21
+ return results;
22
+ }
23
+ function pageStartsWith(navEntry, prefix) {
24
+ if (typeof navEntry === 'string') {
25
+ return navEntry.startsWith(prefix);
26
+ }
27
+ else if (navEntry.pages == undefined) {
28
+ return false;
29
+ }
30
+ else {
31
+ return navEntry.pages.some(function (entry) {
32
+ return pageStartsWith(entry, prefix);
33
+ });
34
+ }
35
+ }
@@ -1,5 +1,4 @@
1
- import { MintValidationResults } from './common';
2
- import { VersionsType } from './schemas/versions';
3
- import { MintNavigationGroupChild, MintNavigationGroup } from './types/navigation';
4
- export declare function flattenNavigationVersions(nav: MintNavigationGroupChild[], versions?: string[]): string[];
5
- export declare function validateVersionsInNavigation(navigation: MintNavigationGroup[] | undefined, versions?: VersionsType | undefined): MintValidationResults;
1
+ import { VersionType, NavigationEntry, NavigationGroup } from '@mintlify/models';
2
+ import { MintValidationResults } from './common.js';
3
+ export declare function flattenNavigationVersions(nav: NavigationEntry[], versions?: string[]): string[];
4
+ export declare function validateVersionsInNavigation(navigation: NavigationGroup[] | undefined, versions?: VersionType[] | undefined): MintValidationResults;
@@ -0,0 +1,55 @@
1
+ import { MintValidationResults } from './common.js';
2
+ import { navigationSchema } from './schemas/navigation.js';
3
+ export function flattenNavigationVersions(nav, versions) {
4
+ if (versions === void 0) { versions = []; }
5
+ nav.forEach(function (val) {
6
+ if (val == null || typeof val === 'string') {
7
+ return versions;
8
+ }
9
+ if (val.version) {
10
+ versions.push(val.version);
11
+ }
12
+ if (!Array.isArray(val.pages)) {
13
+ return versions;
14
+ }
15
+ return flattenNavigationVersions(val.pages, versions);
16
+ });
17
+ return versions;
18
+ }
19
+ export function validateVersionsInNavigation(navigation, versions) {
20
+ if (versions === void 0) { versions = []; }
21
+ var results = new MintValidationResults();
22
+ if (navigation == null || !navigationSchema.safeParse(navigation).success) {
23
+ return results;
24
+ }
25
+ var versionsFromNavigation = flattenNavigationVersions(navigation);
26
+ versionsFromNavigation.forEach(function (v) {
27
+ if (versions && !versions.includes(v)) {
28
+ results.errors.push("Version ".concat(v, " is not included in the versions array, but is used in the navigation. Please add ").concat(v, " to the versions array."));
29
+ }
30
+ });
31
+ if (versionsFromNavigation.length === 0 && versions.length > 0) {
32
+ results.warnings.push('You have versions defined in the config, but no versions are used in the navigation.');
33
+ }
34
+ navigation.forEach(function (nav) {
35
+ var _a;
36
+ (_a = results.warnings).push.apply(_a, warnVersionNesting(nav, null));
37
+ });
38
+ return results;
39
+ }
40
+ function warnVersionNesting(navigation, currentVersion) {
41
+ if (typeof navigation === 'string') {
42
+ return [];
43
+ }
44
+ var warnings = [];
45
+ if (navigation.version && currentVersion != null && navigation.version !== currentVersion) {
46
+ warnings.push("Please do not set versions on groups nested inside a group that already has a version. The group \"".concat(navigation.group, "\" has version \"").concat(navigation.version, "\" set and it is nested in a group that has the version \"").concat(currentVersion, "\" set."));
47
+ }
48
+ if (navigation.pages) {
49
+ return warnings.concat(navigation.pages
50
+ .map(function (entry) { return warnVersionNesting(entry, currentVersion || navigation.version); })
51
+ .flat()
52
+ .filter(Boolean));
53
+ }
54
+ return [];
55
+ }
@@ -1,5 +1,5 @@
1
1
  import { OpenAPIV3_1 } from 'openapi-types';
2
- import type { BodySchema, DataSchemaArray, Endpoint, HttpMethod, ResponseSchema } from './types/endpoint';
2
+ import type { BodySchema, DataSchemaArray, Endpoint, HttpMethod, ResponseSchema } from './types/endpoint.js';
3
3
  export declare const generateMessage: (path: string[], messages?: string[]) => string;
4
4
  export declare class InvalidSchemaError extends Error {
5
5
  constructor(path: string[], ...messages: string[]);