@mintlify/prebuild 1.0.783 → 1.0.785

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,4 +7,5 @@ export declare const categorizeFilePaths: (contentDirectoryPath: string, mintIgn
7
7
  asyncApiFiles: AsyncAPIFile[];
8
8
  snippets: string[];
9
9
  snippetsV2: string[];
10
+ fileImportsMap: Map<string, Set<string>>;
10
11
  }>;
@@ -1,34 +1,48 @@
1
- import { openApiCheck } from '@mintlify/common';
2
- import { validateAsyncApi } from '@mintlify/common';
1
+ import { openApiCheck, validateAsyncApi, buildImportMap, getFileCategory, isSnippetExtension, getAST, } from '@mintlify/common';
3
2
  import { readFile } from 'fs/promises';
4
3
  import yaml from 'js-yaml';
5
4
  import * as path from 'path';
6
5
  import { getFileList } from '../fs/index.js';
7
6
  import { getFileExtension } from '../utils.js';
8
7
  export const categorizeFilePaths = async (contentDirectoryPath, mintIgnore = [], disableOpenApi) => {
9
- const allFilesInCmdExecutionPath = getFileList(contentDirectoryPath, contentDirectoryPath, mintIgnore);
8
+ const allFiles = getFileList(contentDirectoryPath, contentDirectoryPath, mintIgnore);
9
+ const mdxFiles = [];
10
+ const nonMdxFiles = [];
11
+ for await (const filename of allFiles) {
12
+ const extension = getFileExtension(filename);
13
+ if (isSnippetExtension(extension)) {
14
+ const filePath = path.join(contentDirectoryPath, filename);
15
+ const content = await readFile(filePath, 'utf8');
16
+ const tree = getAST(content, filePath);
17
+ mdxFiles.push({ path: filename, tree });
18
+ }
19
+ else {
20
+ nonMdxFiles.push({ filename, extension });
21
+ }
22
+ }
23
+ const { importedFiles, fileImportsMap } = buildImportMap(mdxFiles);
10
24
  const contentFilenames = [];
25
+ const snippets = [];
26
+ const snippetsV2 = [];
27
+ for (const file of mdxFiles) {
28
+ const category = getFileCategory(file.path, { importedFiles });
29
+ switch (category) {
30
+ case 'snippet':
31
+ snippets.push(file.path);
32
+ break;
33
+ case 'snippet-v2':
34
+ snippetsV2.push(file.path);
35
+ break;
36
+ case 'page':
37
+ contentFilenames.push(file.path);
38
+ break;
39
+ }
40
+ }
11
41
  const staticFilenames = [];
12
42
  const openApiFiles = [];
13
43
  const asyncApiFiles = [];
14
- const snippets = [];
15
- const snippetsV2 = [];
16
- for await (const filename of allFilesInCmdExecutionPath) {
17
- const extension = getFileExtension(filename);
44
+ for (const { filename, extension } of nonMdxFiles) {
18
45
  switch (extension) {
19
- case 'mdx':
20
- case 'md':
21
- case 'jsx':
22
- if (filename.startsWith('/_snippets/')) {
23
- snippets.push(filename);
24
- break;
25
- }
26
- if (filename.startsWith('/snippets/')) {
27
- snippetsV2.push(filename);
28
- break;
29
- }
30
- contentFilenames.push(filename);
31
- break;
32
46
  case 'json':
33
47
  case 'yaml':
34
48
  case 'yml':
@@ -71,5 +85,13 @@ export const categorizeFilePaths = async (contentDirectoryPath, mintIgnore = [],
71
85
  staticFilenames.push(filename);
72
86
  }
73
87
  }
74
- return { contentFilenames, staticFilenames, openApiFiles, asyncApiFiles, snippets, snippetsV2 };
88
+ return {
89
+ contentFilenames,
90
+ staticFilenames,
91
+ openApiFiles,
92
+ asyncApiFiles,
93
+ snippets,
94
+ snippetsV2,
95
+ fileImportsMap,
96
+ };
75
97
  };
@@ -1,8 +1,11 @@
1
+ export interface PrebuildResult {
2
+ fileImportsMap: Map<string, Set<string>>;
3
+ }
1
4
  export declare const prebuild: (contentDirectoryPath: string, { localSchema, groups, disableOpenApi, }?: {
2
5
  localSchema?: boolean;
3
6
  groups?: string[];
4
7
  disableOpenApi?: boolean;
5
- }) => Promise<void>;
8
+ }) => Promise<PrebuildResult | undefined>;
6
9
  export * from './categorizeFilePaths.js';
7
10
  export * from '../createPage/index.js';
8
11
  export * from '../createPage/preparseMdx/index.js';
@@ -12,7 +12,7 @@ export const prebuild = async (contentDirectoryPath, { localSchema, groups, disa
12
12
  throw Error('must be run in a directory where a docs.json file exists.');
13
13
  }
14
14
  const mintIgnore = await getMintIgnore(contentDirectoryPath);
15
- const { contentFilenames, staticFilenames, openApiFiles, asyncApiFiles, snippets, snippetsV2 } = await categorizeFilePaths(contentDirectoryPath, mintIgnore, disableOpenApi);
15
+ const { contentFilenames, staticFilenames, openApiFiles, asyncApiFiles, snippets, snippetsV2, fileImportsMap, } = await categorizeFilePaths(contentDirectoryPath, mintIgnore, disableOpenApi);
16
16
  await update({
17
17
  contentDirectoryPath,
18
18
  staticFilenames,
@@ -27,6 +27,7 @@ export const prebuild = async (contentDirectoryPath, { localSchema, groups, disa
27
27
  mintIgnore,
28
28
  disableOpenApi,
29
29
  });
30
+ return { fileImportsMap };
30
31
  };
31
32
  export * from './categorizeFilePaths.js';
32
33
  export * from '../createPage/index.js';
@@ -112,6 +112,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
112
112
  } | undefined;
113
113
  decoration?: "gradient" | "grid" | "windows" | undefined;
114
114
  } | undefined;
115
+ public?: boolean | undefined;
115
116
  logo?: string | {
116
117
  light: string;
117
118
  dark: string;
@@ -435,6 +436,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
435
436
  } | undefined;
436
437
  decoration?: "gradient" | "grid" | "windows" | undefined;
437
438
  } | undefined;
439
+ public?: boolean | undefined;
438
440
  logo?: string | {
439
441
  light: string;
440
442
  dark: string;
@@ -758,6 +760,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
758
760
  } | undefined;
759
761
  decoration?: "gradient" | "grid" | "windows" | undefined;
760
762
  } | undefined;
763
+ public?: boolean | undefined;
761
764
  logo?: string | {
762
765
  light: string;
763
766
  dark: string;
@@ -1081,6 +1084,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1081
1084
  } | undefined;
1082
1085
  decoration?: "gradient" | "grid" | "windows" | undefined;
1083
1086
  } | undefined;
1087
+ public?: boolean | undefined;
1084
1088
  logo?: string | {
1085
1089
  light: string;
1086
1090
  dark: string;
@@ -1404,6 +1408,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1404
1408
  } | undefined;
1405
1409
  decoration?: "gradient" | "grid" | "windows" | undefined;
1406
1410
  } | undefined;
1411
+ public?: boolean | undefined;
1407
1412
  logo?: string | {
1408
1413
  light: string;
1409
1414
  dark: string;
@@ -1727,6 +1732,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1727
1732
  } | undefined;
1728
1733
  decoration?: "gradient" | "grid" | "windows" | undefined;
1729
1734
  } | undefined;
1735
+ public?: boolean | undefined;
1730
1736
  logo?: string | {
1731
1737
  light: string;
1732
1738
  dark: string;
@@ -2050,6 +2056,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
2050
2056
  } | undefined;
2051
2057
  decoration?: "gradient" | "grid" | "windows" | undefined;
2052
2058
  } | undefined;
2059
+ public?: boolean | undefined;
2053
2060
  logo?: string | {
2054
2061
  light: string;
2055
2062
  dark: string;
@@ -107,6 +107,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
107
107
  } | undefined;
108
108
  decoration?: "gradient" | "grid" | "windows" | undefined;
109
109
  } | undefined;
110
+ public?: boolean | undefined;
110
111
  logo?: string | {
111
112
  light: string;
112
113
  dark: string;
@@ -430,6 +431,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
430
431
  } | undefined;
431
432
  decoration?: "gradient" | "grid" | "windows" | undefined;
432
433
  } | undefined;
434
+ public?: boolean | undefined;
433
435
  logo?: string | {
434
436
  light: string;
435
437
  dark: string;
@@ -753,6 +755,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
753
755
  } | undefined;
754
756
  decoration?: "gradient" | "grid" | "windows" | undefined;
755
757
  } | undefined;
758
+ public?: boolean | undefined;
756
759
  logo?: string | {
757
760
  light: string;
758
761
  dark: string;
@@ -1076,6 +1079,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
1076
1079
  } | undefined;
1077
1080
  decoration?: "gradient" | "grid" | "windows" | undefined;
1078
1081
  } | undefined;
1082
+ public?: boolean | undefined;
1079
1083
  logo?: string | {
1080
1084
  light: string;
1081
1085
  dark: string;
@@ -1399,6 +1403,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
1399
1403
  } | undefined;
1400
1404
  decoration?: "gradient" | "grid" | "windows" | undefined;
1401
1405
  } | undefined;
1406
+ public?: boolean | undefined;
1402
1407
  logo?: string | {
1403
1408
  light: string;
1404
1409
  dark: string;
@@ -1722,6 +1727,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
1722
1727
  } | undefined;
1723
1728
  decoration?: "gradient" | "grid" | "windows" | undefined;
1724
1729
  } | undefined;
1730
+ public?: boolean | undefined;
1725
1731
  logo?: string | {
1726
1732
  light: string;
1727
1733
  dark: string;
@@ -2045,6 +2051,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
2045
2051
  } | undefined;
2046
2052
  decoration?: "gradient" | "grid" | "windows" | undefined;
2047
2053
  } | undefined;
2054
+ public?: boolean | undefined;
2048
2055
  logo?: string | {
2049
2056
  light: string;
2050
2057
  dark: string;