@mintlify/prebuild 1.0.1209 → 1.0.1211

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,6 +7,7 @@ export declare const generateOpenApiFromDocsConfig: (navigation: NavigationConfi
7
7
  targetDir?: string;
8
8
  localSchema?: boolean;
9
9
  invalidSpecFiles?: InvalidSpecFile[];
10
+ mountPaths?: string[];
10
11
  writeFile?: (filename: string, content: string) => void | Promise<void>;
11
12
  }) => Promise<{
12
13
  newNav: NavigationConfig;
@@ -5,8 +5,20 @@ import { divisions, } from '@mintlify/validation';
5
5
  import * as path from 'path';
6
6
  import { findInvalidSpecFile } from '../../invalidSpecFiles.js';
7
7
  const DEFAULT_OUTPUT_DIR = 'api-reference';
8
+ const normalizeMountPath = (mountPath) => mountPath.replace(/^\/+|\/+$/g, '');
9
+ const getMountPathForPath = (candidatePath, mountPaths) => {
10
+ if (!candidatePath)
11
+ return '';
12
+ const normalizedPath = candidatePath.replace(/^\/+/, '');
13
+ const candidates = mountPaths
14
+ .map(normalizeMountPath)
15
+ .filter(Boolean)
16
+ .sort((a, b) => b.length - a.length);
17
+ return (candidates.find((mountPath) => normalizedPath === mountPath || normalizedPath.startsWith(`${mountPath}/`)) ?? '');
18
+ };
19
+ const resolveMountPath = (specPath, outputDir, mountPaths) => getMountPathForPath(specPath, mountPaths) || getMountPathForPath(outputDir, mountPaths);
8
20
  export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pagesAcc, opts) => {
9
- const { overwrite, writeFiles, targetDir, localSchema, invalidSpecFiles, writeFile } = opts;
21
+ const { overwrite, writeFiles, targetDir, localSchema, invalidSpecFiles, mountPaths = [], writeFile, } = opts;
10
22
  const newOpenApiFiles = [];
11
23
  const openApiFilePromises = new Map();
12
24
  async function processOpenApiInNav(nav) {
@@ -53,6 +65,7 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
53
65
  writeFiles,
54
66
  outDir: outputDir,
55
67
  outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
68
+ mountPath: resolveMountPath(openApiFile.originalFileLocation, outputDir, mountPaths),
56
69
  overwrite,
57
70
  localSchema,
58
71
  writeFile,
@@ -173,6 +186,7 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
173
186
  writeFiles,
174
187
  outDir: currentDirectory ?? DEFAULT_OUTPUT_DIR,
175
188
  outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
189
+ mountPath: resolveMountPath(openApiFile.originalFileLocation, currentDirectory, mountPaths),
176
190
  overwrite,
177
191
  localSchema,
178
192
  writeFile,
@@ -193,6 +207,7 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
193
207
  writeFiles,
194
208
  outDir: currentDirectory ?? DEFAULT_OUTPUT_DIR,
195
209
  outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
210
+ mountPath: resolveMountPath(openApiFile.originalFileLocation, currentDirectory, mountPaths),
196
211
  overwrite,
197
212
  localSchema,
198
213
  writeFile,