@mintlify/link-rot 3.0.1458 → 3.0.1459

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.
@@ -7,53 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { parseGraphqlSelector } from '@mintlify/common';
11
10
  import { generateGraphqlDivisionsFromDocsConfig, loadGraphqlSdlSource } from '@mintlify/prebuild';
12
11
  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
12
  export const getGraphqlPagePaths = (baseDir) => __awaiter(void 0, void 0, void 0, function* () {
38
13
  const docsConfig = yield readDocsConfig(baseDir);
39
14
  if (!docsConfig)
40
15
  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
- }
16
+ const { generatedRoutes } = yield generateGraphqlDivisionsFromDocsConfig(docsConfig, (source) => loadGraphqlSdlSource(source, baseDir), {
17
+ onSourceError: (source, err) => console.warn(`Warning: Failed to load GraphQL schema ${source}: ${err}`),
18
+ });
19
+ return generatedRoutes;
59
20
  });