@mintlify/validation
Version:
Validates mint.json files
116 lines (115 loc) • 4.92 kB
TypeScript
import { z } from 'zod';
import { Division } from '../reusable/divisions.js';
import { BaseAnchorSchema } from './anchors.js';
import { BaseDropdownSchema } from './dropdown.js';
import { GroupsConfig, DecoratedGroupsConfig } from './groups.js';
import { BaseLanguageSchema } from './languages.js';
import { BaseMenuItemSchema } from './menu.js';
import { PagesConfig, DecoratedPagesConfig } from './pages.js';
import { BaseProductSchema } from './products.js';
import { BaseTabSchema } from './tabs.js';
import { BaseVersionSchema } from './version.js';
type NavigationType = 'default' | 'decorated';
declare const SomeApiSchema: z.ZodObject<{
openapi: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, z.ZodObject<{
source: z.ZodEffects<z.ZodString, string, string>;
directory: z.ZodOptional<z.ZodString>;
}, "strict", z.ZodTypeAny, {
source: string;
directory?: string | undefined;
}, {
source: string;
directory?: string | undefined;
}>]>>;
asyncapi: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">, z.ZodObject<{
source: z.ZodEffects<z.ZodString, string, string>;
directory: z.ZodOptional<z.ZodString>;
}, "strict", z.ZodTypeAny, {
source: string;
directory?: string | undefined;
}, {
source: string;
directory?: string | undefined;
}>]>>;
}, "strip", z.ZodTypeAny, {
openapi?: string | string[] | {
source: string;
directory?: string | undefined;
} | undefined;
asyncapi?: string | string[] | {
source: string;
directory?: string | undefined;
} | undefined;
}, {
openapi?: string | string[] | {
source: string;
directory?: string | undefined;
} | undefined;
asyncapi?: string | string[] | {
source: string;
directory?: string | undefined;
} | undefined;
}>;
type OtherConfigs<T extends NavigationType> = T extends 'default' ? z.infer<typeof SomeApiSchema> & {
global?: GlobalNavigation;
} : {
global?: GlobalNavigation;
};
type ExcludedDivisions = {
languages: 'languages' | 'menu';
versions: 'versions' | 'menu';
dropdowns: 'dropdowns' | 'menu';
anchors: 'anchors' | 'menu';
products: 'products' | 'menu';
tabs: 'tabs' | 'menu';
menu: 'languages' | 'versions' | 'dropdowns' | 'anchors' | 'menu' | 'products';
};
type BaseNavigation<T extends NavigationType, K extends Division> = {
languages: K extends ExcludedDivisions['languages'] ? never : LanguageNavigation<T>[];
} | {
versions: K extends ExcludedDivisions['versions'] ? never : VersionNavigation<T>[];
} | {
dropdowns: K extends ExcludedDivisions['dropdowns'] ? never : DropdownNavigation<T>[];
} | {
anchors: K extends ExcludedDivisions['anchors'] ? never : AnchorNavigation<T>[];
} | {
products: K extends ExcludedDivisions['products'] ? never : ProductNavigation<T>[];
} | {
tabs: K extends ExcludedDivisions['tabs'] ? never : TabNavigation<T>[];
} | {
menu: K extends ExcludedDivisions['menu'] ? never : MenuItemNavigation<T>[];
} | {
groups: T extends 'default' ? GroupsConfig : DecoratedGroupsConfig;
} | {
pages: T extends 'default' ? PagesConfig : DecoratedPagesConfig;
} | {
href: string;
};
export type ProductNavigation<T extends NavigationType> = BaseProductSchema & (OtherConfigs<T> | (BaseNavigation<T, 'products'> & OtherConfigs<T>));
export type AnchorNavigation<T extends NavigationType> = BaseAnchorSchema & (OtherConfigs<T> | (BaseNavigation<T, 'anchors'> & OtherConfigs<T>));
export type LanguageNavigation<T extends NavigationType> = BaseLanguageSchema & (OtherConfigs<T> | (BaseNavigation<T, 'languages'> & OtherConfigs<T>));
export type VersionNavigation<T extends NavigationType> = BaseVersionSchema & (OtherConfigs<T> | (BaseNavigation<T, 'versions'> & OtherConfigs<T>));
export type DropdownNavigation<T extends NavigationType> = BaseDropdownSchema & (OtherConfigs<T> | (BaseNavigation<T, 'dropdowns'> & OtherConfigs<T>));
export type TabNavigation<T extends NavigationType> = BaseTabSchema & (OtherConfigs<T> | (BaseNavigation<T, 'tabs'> & OtherConfigs<T>));
export type MenuItemNavigation<T extends NavigationType> = BaseMenuItemSchema & (OtherConfigs<T> | (BaseNavigation<T, 'menu'> & OtherConfigs<T>));
export type GlobalNavigation = {
languages?: (BaseLanguageSchema & {
href: string;
})[];
versions?: (BaseVersionSchema & {
href: string;
})[];
tabs?: (BaseTabSchema & {
href: string;
})[];
dropdowns?: (BaseDropdownSchema & {
href: string;
})[];
anchors?: (BaseAnchorSchema & {
href: string;
})[];
products?: (BaseProductSchema & {
href: string;
})[];
};
export {};