@mintlify/validation 0.1.254 → 0.1.256
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/mint-config/schemas/v2/index.d.ts +3922 -7432
- package/dist/mint-config/schemas/v2/properties/index.d.ts +1 -0
- package/dist/mint-config/schemas/v2/properties/index.js +1 -0
- package/dist/mint-config/schemas/v2/properties/navigation/anchors.d.ts +12 -455
- package/dist/mint-config/schemas/v2/properties/navigation/anchors.js +28 -11
- package/dist/mint-config/schemas/v2/properties/navigation/divisionNav.d.ts +56 -0
- package/dist/mint-config/schemas/v2/properties/navigation/divisionNav.js +5 -0
- package/dist/mint-config/schemas/v2/properties/navigation/dropdown.d.ts +13 -330
- package/dist/mint-config/schemas/v2/properties/navigation/dropdown.js +28 -11
- package/dist/mint-config/schemas/v2/properties/navigation/groups.d.ts +22 -646
- package/dist/mint-config/schemas/v2/properties/navigation/groups.js +15 -13
- package/dist/mint-config/schemas/v2/properties/navigation/index.d.ts +258 -1495
- package/dist/mint-config/schemas/v2/properties/navigation/index.js +23 -13
- package/dist/mint-config/schemas/v2/properties/navigation/languages.d.ts +11 -202
- package/dist/mint-config/schemas/v2/properties/navigation/languages.js +33 -11
- package/dist/mint-config/schemas/v2/properties/navigation/pages.d.ts +2 -3
- package/dist/mint-config/schemas/v2/properties/navigation/pages.js +2 -2
- package/dist/mint-config/schemas/v2/properties/navigation/tabs.d.ts +11 -328
- package/dist/mint-config/schemas/v2/properties/navigation/tabs.js +28 -11
- package/dist/mint-config/schemas/v2/properties/navigation/version.d.ts +12 -203
- package/dist/mint-config/schemas/v2/properties/navigation/version.js +28 -11
- package/dist/mint-config/schemas/v2/themes/linden.d.ts +253 -955
- package/dist/mint-config/schemas/v2/themes/maple.d.ts +253 -955
- package/dist/mint-config/schemas/v2/themes/mint.d.ts +253 -955
- package/dist/mint-config/schemas/v2/themes/palm.d.ts +253 -955
- package/dist/mint-config/schemas/v2/themes/reusable/index.d.ts +143 -737
- package/dist/mint-config/schemas/v2/themes/willow.d.ts +253 -955
- package/dist/mint-config/upgrades/convertMintDecoratedNavToDocsDecoratedNav.d.ts +14 -0
- package/dist/mint-config/upgrades/convertMintDecoratedNavToDocsDecoratedNav.js +98 -0
- package/dist/mint-config/upgrades/updateNavigationToDocsConfig.js +14 -8
- package/dist/mint-config/validateConfig.d.ts +420 -960
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/mint-config/schemas/v2/properties/navigation/divisionSchemas.d.ts +0 -7
- package/dist/mint-config/schemas/v2/properties/navigation/divisionSchemas.js +0 -26
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MintConfigType, DecoratedNavigation } from '@mintlify/models';
|
|
2
|
+
import { DocsConfig } from '../schemas/v2/index.js';
|
|
3
|
+
import { DecoratedNavigationConfig } from '../schemas/v2/properties/navigation/index.js';
|
|
4
|
+
type Input = {
|
|
5
|
+
type: 'mint';
|
|
6
|
+
mintConfig: MintConfigType;
|
|
7
|
+
decoratedNavigation: DecoratedNavigation;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'docs';
|
|
10
|
+
docsConfig: DocsConfig;
|
|
11
|
+
decoratedNavigation: DecoratedNavigation;
|
|
12
|
+
};
|
|
13
|
+
export declare const convertMintDecoratedNavToDocsDecoratedNav: (param: Input) => DecoratedNavigationConfig;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { divisions } from '../schemas/v2/properties/index.js';
|
|
13
|
+
import { upgradeToDocsConfig } from './upgradeToDocsConfig.js';
|
|
14
|
+
export const convertMintDecoratedNavToDocsDecoratedNav = (param) => {
|
|
15
|
+
const { type, decoratedNavigation } = param;
|
|
16
|
+
let docsConfig;
|
|
17
|
+
if (type === 'mint') {
|
|
18
|
+
const { mintConfig } = param;
|
|
19
|
+
docsConfig = upgradeToDocsConfig(mintConfig);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
docsConfig = param.docsConfig;
|
|
23
|
+
}
|
|
24
|
+
const pagesAcc = {};
|
|
25
|
+
for (const decoratedNavigationEntry of decoratedNavigation) {
|
|
26
|
+
mapDecoratedNavigationToPages(decoratedNavigationEntry, pagesAcc);
|
|
27
|
+
}
|
|
28
|
+
const decoratedDocsConfig = generateDecoratedDocsNavigationFromPages(pagesAcc, docsConfig.navigation);
|
|
29
|
+
return decoratedDocsConfig;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* These functions are copied from other packages to avoid circular dependencies
|
|
33
|
+
*/
|
|
34
|
+
const generateDecoratedDocsNavigationFromPages = (filenamePageMetadataMap, docsConfigNav) => {
|
|
35
|
+
const { global } = docsConfigNav, nav = __rest(docsConfigNav, ["global"]);
|
|
36
|
+
const generateDecoratedPages = (page) => {
|
|
37
|
+
const href = optionallyAddLeadingSlash(page);
|
|
38
|
+
const pageMetadata = filenamePageMetadataMap[href];
|
|
39
|
+
if (pageMetadata) {
|
|
40
|
+
return pageMetadata;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
console.log(`⚠️ "${page}" is defined in the docs.json navigation but the file does not exist.`);
|
|
44
|
+
return {
|
|
45
|
+
title: slugToTitle(page),
|
|
46
|
+
href,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const traverseNav = (nav) => {
|
|
51
|
+
let processed = Object.assign({}, nav);
|
|
52
|
+
if ('openapi' in processed) {
|
|
53
|
+
const { openapi: _ } = processed, rest = __rest(processed, ["openapi"]);
|
|
54
|
+
processed = Object.assign({}, rest);
|
|
55
|
+
}
|
|
56
|
+
if ('pages' in processed) {
|
|
57
|
+
processed.pages = processed.pages.map((page) => typeof page === 'string' ? generateDecoratedPages(page) : traverseNav(page));
|
|
58
|
+
}
|
|
59
|
+
['groups', ...divisions].forEach((division) => {
|
|
60
|
+
const divisionNav = processed[division];
|
|
61
|
+
if (Array.isArray(divisionNav)) {
|
|
62
|
+
processed = Object.assign(Object.assign({}, processed), { [division]: divisionNav.map((item) => traverseNav(item)) });
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return processed;
|
|
66
|
+
};
|
|
67
|
+
return Object.assign({ global }, traverseNav(nav));
|
|
68
|
+
};
|
|
69
|
+
const mapDecoratedNavigationToPages = (entry, pagesAcc) => {
|
|
70
|
+
if (isGroup(entry)) {
|
|
71
|
+
for (const page of entry.pages) {
|
|
72
|
+
mapDecoratedNavigationToPages(page, pagesAcc);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
pagesAcc[entry.href] = entry;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const isGroup = (decoratedNavigation) => {
|
|
80
|
+
return decoratedNavigation.hasOwnProperty('group') && decoratedNavigation.hasOwnProperty('pages');
|
|
81
|
+
};
|
|
82
|
+
function optionallyAddLeadingSlash(filePath) {
|
|
83
|
+
if (filePath.startsWith('/')) {
|
|
84
|
+
return filePath;
|
|
85
|
+
}
|
|
86
|
+
return '/' + filePath;
|
|
87
|
+
}
|
|
88
|
+
const slugToTitle = (slug) => {
|
|
89
|
+
const indexOfQuestionMark = slug.indexOf('?');
|
|
90
|
+
if (indexOfQuestionMark > -1) {
|
|
91
|
+
slug = slug.substring(0, indexOfQuestionMark);
|
|
92
|
+
}
|
|
93
|
+
const slugArr = slug.split('/');
|
|
94
|
+
let defaultTitle = slugArr[slugArr.length - 1].split('-').join(' '); //replace all dashes
|
|
95
|
+
defaultTitle = defaultTitle.split('_').join(' '); //replace all underscores
|
|
96
|
+
defaultTitle = defaultTitle.charAt(0).toUpperCase() + defaultTitle.slice(1); //capitalize first letter
|
|
97
|
+
return defaultTitle;
|
|
98
|
+
};
|
|
@@ -9,7 +9,6 @@ const DEFAULT_ANCHOR = {
|
|
|
9
9
|
};
|
|
10
10
|
const filterGroupsByVersion = (groups, versionName) => groups.filter((group) => group.version === versionName || group.version === undefined || !versionName);
|
|
11
11
|
const formatIcon = (icon, iconType) => iconType ? { name: icon, style: iconType } : icon;
|
|
12
|
-
const isAnchor = (division) => 'icon' in division || 'color' in division;
|
|
13
12
|
const isRemoteUrl = (url) => {
|
|
14
13
|
if (!url)
|
|
15
14
|
return false;
|
|
@@ -88,12 +87,17 @@ const processDivisions = (type, divisions = [], navigationGroups = [], shouldIns
|
|
|
88
87
|
return undefined;
|
|
89
88
|
}
|
|
90
89
|
const baseDivision = Object.assign(Object.assign(Object.assign(Object.assign({}, (type === 'tabs' ? { tab: division.name } : { anchor: division.name })), { href: division.url }), (division.isDefaultHidden ? { hidden: division.isDefaultHidden } : {})), (division.openapi ? { openapi: division.openapi } : {}));
|
|
91
|
-
if (
|
|
92
|
-
if (division.icon) {
|
|
90
|
+
if (type === 'anchors') {
|
|
91
|
+
if ('icon' in division && division.icon) {
|
|
93
92
|
baseDivision.icon = formatIcon(division.icon, division.iconType);
|
|
94
93
|
}
|
|
95
|
-
if (division.color) {
|
|
96
|
-
|
|
94
|
+
if ('color' in division && division.color) {
|
|
95
|
+
// TODO: we need a better way to handle this
|
|
96
|
+
const color = typeof division.color === 'string' ? division.color : division.color.from;
|
|
97
|
+
baseDivision.color = {
|
|
98
|
+
light: color,
|
|
99
|
+
dark: color,
|
|
100
|
+
};
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
const ignoredDivisions = divisions.filter((d) => d.url.startsWith(division.url) && d.url !== division.url);
|
|
@@ -222,9 +226,11 @@ export const updateNavigationToDocsConfig = (config) => {
|
|
|
222
226
|
const versionName = typeof versions[index] === 'string'
|
|
223
227
|
? version.version
|
|
224
228
|
: ((_a = versions[index]) === null || _a === void 0 ? void 0 : _a.name) || version.language;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
229
|
+
if ('groups' in version) {
|
|
230
|
+
const updatedNavigationPerVersion = getUpdatedNavigation(version.groups, tabs, anchors, versionName, config);
|
|
231
|
+
if (updatedNavigationPerVersion) {
|
|
232
|
+
versionsResult[index] = Object.assign(Object.assign({}, _.omit(version, 'groups')), updatedNavigationPerVersion);
|
|
233
|
+
}
|
|
228
234
|
}
|
|
229
235
|
});
|
|
230
236
|
const navigationConfig = (isLocale ? { languages: versionsResult } : { versions: versionsResult });
|