@mintlify/link-rot 3.0.1455 → 3.0.1457
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/static-checking/getBrokenInternalLinks.js +8 -0
- package/dist/static-checking/getGraphqlPagePaths.d.ts +1 -0
- package/dist/static-checking/getGraphqlPagePaths.js +59 -0
- package/dist/static-checking/getOpenApiPagePaths.js +2 -9
- package/dist/static-checking/readConfig.d.ts +2 -0
- package/dist/static-checking/readConfig.js +7 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -8
|
@@ -15,6 +15,7 @@ import remarkSmartypants from 'remark-smartypants';
|
|
|
15
15
|
import { visit } from 'unist-util-visit';
|
|
16
16
|
import { Graph, Wrapper } from '../graph.js';
|
|
17
17
|
import { getLinkPaths, getPagePaths } from '../prebuild.js';
|
|
18
|
+
import { getGraphqlPagePaths } from './getGraphqlPagePaths.js';
|
|
18
19
|
import { getNavigationHrefs } from './getNavigationHrefs.js';
|
|
19
20
|
import { getOpenApiPagePaths } from './getOpenApiPagePaths.js';
|
|
20
21
|
import { getRedirects } from './getRedirects.js';
|
|
@@ -132,6 +133,13 @@ export const buildGraph = (repoPath, options) => __awaiter(void 0, void 0, void
|
|
|
132
133
|
catch (err) {
|
|
133
134
|
console.warn(`Warning: Failed to extract OpenAPI page paths: ${err}`);
|
|
134
135
|
}
|
|
136
|
+
try {
|
|
137
|
+
const graphqlPagePaths = yield getGraphqlPagePaths(baseDir);
|
|
138
|
+
graph.addVirtualNodes(graphqlPagePaths);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
console.warn(`Warning: Failed to extract GraphQL page paths: ${err}`);
|
|
142
|
+
}
|
|
135
143
|
const navResult = yield getNavigationHrefs(baseDir);
|
|
136
144
|
if (navResult) {
|
|
137
145
|
const configNode = graph.addNode(navResult.configFile);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getGraphqlPagePaths: (baseDir: string) => Promise<string[]>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { parseGraphqlSelector } from '@mintlify/common';
|
|
11
|
+
import { generateGraphqlDivisionsFromDocsConfig, loadGraphqlSdlSource } from '@mintlify/prebuild';
|
|
12
|
+
import { readDocsConfig } from './readConfig.js';
|
|
13
|
+
const graphqlSource = (config) => {
|
|
14
|
+
if (typeof config === 'string')
|
|
15
|
+
return config;
|
|
16
|
+
if (typeof config === 'object' && config !== null && 'source' in config) {
|
|
17
|
+
return typeof config.source === 'string' ? config.source : undefined;
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
};
|
|
21
|
+
const withoutGraphqlSources = (value, sources, dropSelectors = false) => {
|
|
22
|
+
var _a;
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
return value
|
|
25
|
+
.filter((item) => !dropSelectors || typeof item !== 'string' || !parseGraphqlSelector(item))
|
|
26
|
+
.map((item) => withoutGraphqlSources(item, sources, dropSelectors));
|
|
27
|
+
}
|
|
28
|
+
if (typeof value !== 'object' || value === null)
|
|
29
|
+
return value;
|
|
30
|
+
const config = 'graphql' in value ? value.graphql : undefined;
|
|
31
|
+
const failed = config !== undefined && sources.has((_a = graphqlSource(config)) !== null && _a !== void 0 ? _a : '');
|
|
32
|
+
const childDropSelectors = config === undefined ? dropSelectors : failed;
|
|
33
|
+
return Object.fromEntries(Object.entries(value)
|
|
34
|
+
.filter(([key]) => key !== 'graphql' || !failed)
|
|
35
|
+
.map(([key, entry]) => [key, withoutGraphqlSources(entry, sources, childDropSelectors)]));
|
|
36
|
+
};
|
|
37
|
+
export const getGraphqlPagePaths = (baseDir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const docsConfig = yield readDocsConfig(baseDir);
|
|
39
|
+
if (!docsConfig)
|
|
40
|
+
return [];
|
|
41
|
+
const failedSources = new Set();
|
|
42
|
+
let navigation = docsConfig.navigation;
|
|
43
|
+
for (;;) {
|
|
44
|
+
const failedCount = failedSources.size;
|
|
45
|
+
try {
|
|
46
|
+
const { generatedRoutes } = yield generateGraphqlDivisionsFromDocsConfig(Object.assign(Object.assign({}, docsConfig), { navigation }), (source) => loadGraphqlSdlSource(source, baseDir).catch((err) => {
|
|
47
|
+
failedSources.add(source);
|
|
48
|
+
console.warn(`Warning: Failed to load GraphQL schema ${source}: ${err}`);
|
|
49
|
+
throw err;
|
|
50
|
+
}));
|
|
51
|
+
return generatedRoutes;
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
if (failedSources.size === failedCount)
|
|
55
|
+
throw err;
|
|
56
|
+
navigation = withoutGraphqlSources(docsConfig.navigation, failedSources);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { buildOverlayRegistryForDirectory, generateOpenApiFromDocsConfig, getOpenApiFiles, getOpenApiFilesFromConfig, } from '@mintlify/prebuild';
|
|
11
11
|
import { generateOpenApiPagesForDocsConfig } from '@mintlify/scraping';
|
|
12
|
-
import { collectOpenApiOverlayConfig
|
|
13
|
-
import {
|
|
12
|
+
import { collectOpenApiOverlayConfig } from '@mintlify/validation';
|
|
13
|
+
import { readDocsConfig } from './readConfig.js';
|
|
14
14
|
const DEFAULT_OUTPUT_DIR = 'api-reference';
|
|
15
15
|
/**
|
|
16
16
|
* Extract virtual page paths that would be generated from OpenAPI specs.
|
|
@@ -76,13 +76,6 @@ export const getOpenApiPagePaths = (baseDir, options) => __awaiter(void 0, void
|
|
|
76
76
|
}
|
|
77
77
|
return [...new Set(pagePaths)];
|
|
78
78
|
});
|
|
79
|
-
const readDocsConfig = (baseDir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
-
const resolved = yield readResolvedConfigJson(baseDir);
|
|
81
|
-
if (!resolved || resolved.configFile !== 'docs.json')
|
|
82
|
-
return null;
|
|
83
|
-
const result = validateDocsConfig(resolved.json);
|
|
84
|
-
return result.success ? result.data : null;
|
|
85
|
-
});
|
|
86
79
|
const safeGetOpenApiFilesFromConfig = (docsConfig, overlayRegistry, fetchRemoteDocument) => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
80
|
try {
|
|
88
81
|
return yield getOpenApiFilesFromConfig('docs', docsConfig, undefined, overlayRegistry, fetchRemoteDocument);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DocsConfig } from '@mintlify/validation';
|
|
1
2
|
type ConfigFilename = 'docs.json' | 'mint.json';
|
|
2
3
|
export type ResolvedConfig = {
|
|
3
4
|
configFile: ConfigFilename;
|
|
@@ -8938,4 +8939,5 @@ export declare const readResolvedConfigJsonAndValidate: (baseDir: string) => Pro
|
|
|
8938
8939
|
};
|
|
8939
8940
|
error?: never;
|
|
8940
8941
|
} | null>;
|
|
8942
|
+
export declare const readDocsConfig: (baseDir: string) => Promise<DocsConfig | null>;
|
|
8941
8943
|
export {};
|
|
@@ -45,3 +45,10 @@ export const readResolvedConfigJsonAndValidate = (baseDir) => __awaiter(void 0,
|
|
|
45
45
|
const validate = resolvedConfigJson.configFile === 'docs.json' ? validateDocsConfig : validateMintConfig;
|
|
46
46
|
return validate(resolvedConfigJson.json);
|
|
47
47
|
});
|
|
48
|
+
export const readDocsConfig = (baseDir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
const resolved = yield readResolvedConfigJson(baseDir);
|
|
50
|
+
if (!resolved || resolved.configFile !== 'docs.json')
|
|
51
|
+
return null;
|
|
52
|
+
const result = validateDocsConfig(resolved.json);
|
|
53
|
+
return result.success ? result.data : null;
|
|
54
|
+
});
|