@mintlify/prebuild 1.0.404 → 1.0.406

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.
@@ -1,8 +1,10 @@
1
+ import { AsyncAPIFile } from '@mintlify/common/asyncapi';
1
2
  import { OpenApiFile } from '@mintlify/models';
2
3
  export declare const categorizeFilePaths: (contentDirectoryPath: string) => Promise<{
3
4
  contentFilenames: string[];
4
5
  staticFilenames: string[];
5
6
  openApiFiles: OpenApiFile[];
7
+ asyncApiFiles: AsyncAPIFile[];
6
8
  snippets: string[];
7
9
  snippetsV2: string[];
8
10
  }>;
@@ -1,4 +1,5 @@
1
1
  import { openApiCheck } from '@mintlify/common';
2
+ import { asyncApiCheck } from '@mintlify/common/asyncapi';
2
3
  import { readFile } from 'fs/promises';
3
4
  import yaml from 'js-yaml';
4
5
  import * as path from 'path';
@@ -9,6 +10,7 @@ export const categorizeFilePaths = async (contentDirectoryPath) => {
9
10
  const contentFilenames = [];
10
11
  const staticFilenames = [];
11
12
  const openApiFiles = [];
13
+ const asyncApiFiles = [];
12
14
  const snippets = [];
13
15
  const snippetsV2 = [];
14
16
  for await (const filename of allFilesInCmdExecutionPath) {
@@ -33,20 +35,31 @@ export const categorizeFilePaths = async (contentDirectoryPath) => {
33
35
  // we need to read from the fs so we can store the original spec
34
36
  const str = await readFile(path.join(contentDirectoryPath, filename), 'utf8');
35
37
  const obj = yaml.load(str);
36
- if (!(await openApiCheck(obj)))
38
+ const isOpenApi = await openApiCheck(obj);
39
+ const isAsyncApi = await asyncApiCheck(obj);
40
+ if (!isOpenApi && !isAsyncApi)
37
41
  break;
38
42
  const fileName = path.parse(filename).name;
39
- openApiFiles.push({
40
- filename: fileName,
41
- spec: obj,
42
- originalFileLocation: filename,
43
- });
43
+ if (isOpenApi) {
44
+ openApiFiles.push({
45
+ filename: fileName,
46
+ spec: obj,
47
+ originalFileLocation: filename,
48
+ });
49
+ }
50
+ if (isAsyncApi) {
51
+ asyncApiFiles.push({
52
+ filename: fileName,
53
+ spec: obj,
54
+ originalFileLocation: filename,
55
+ });
56
+ }
44
57
  }
45
- catch { } // not an openapi spec
58
+ catch { }
46
59
  break;
47
60
  default:
48
61
  staticFilenames.push(filename);
49
62
  }
50
63
  }
51
- return { contentFilenames, staticFilenames, openApiFiles, snippets, snippetsV2 };
64
+ return { contentFilenames, staticFilenames, openApiFiles, asyncApiFiles, snippets, snippetsV2 };
52
65
  };
@@ -11,8 +11,17 @@ export const prebuild = async (contentDirectoryPath) => {
11
11
  if (mintConfigPath == null && docsConfigPath == null) {
12
12
  throw Error('Must be run in a directory where a mint.json or docs.json file exists.');
13
13
  }
14
- const { contentFilenames, staticFilenames, openApiFiles, snippets, snippetsV2 } = await categorizeFilePaths(contentDirectoryPath);
15
- await update(contentDirectoryPath, staticFilenames, openApiFiles, contentFilenames, snippets, snippetsV2, docsConfigPath);
14
+ const { contentFilenames, staticFilenames, openApiFiles, asyncApiFiles, snippets, snippetsV2 } = await categorizeFilePaths(contentDirectoryPath);
15
+ await update({
16
+ contentDirectoryPath,
17
+ staticFilenames,
18
+ openApiFiles,
19
+ asyncApiFiles,
20
+ contentFilenames,
21
+ snippets,
22
+ snippetV2Filenames: snippetsV2,
23
+ docsConfigPath,
24
+ });
16
25
  };
17
26
  export * from './categorizeFilePaths.js';
18
27
  export * from '../createPage/index.js';
@@ -55,6 +55,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
55
55
  icon?: string | {
56
56
  name: string;
57
57
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
58
+ library?: "fontawesome" | "lucide" | undefined;
58
59
  } | undefined;
59
60
  hidden?: boolean | undefined;
60
61
  root?: string | undefined;
@@ -70,6 +71,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
70
71
  icon?: string | {
71
72
  name: string;
72
73
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
74
+ library?: "fontawesome" | "lucide" | undefined;
73
75
  } | undefined;
74
76
  hidden?: boolean | undefined;
75
77
  root?: string | undefined;
@@ -79,6 +81,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
79
81
  icon?: string | {
80
82
  name: string;
81
83
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
84
+ library?: "fontawesome" | "lucide" | undefined;
82
85
  } | undefined;
83
86
  hidden?: boolean | undefined;
84
87
  root?: string | undefined;
@@ -115,6 +118,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
115
118
  icon?: string | {
116
119
  name: string;
117
120
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
121
+ library?: "fontawesome" | "lucide" | undefined;
118
122
  } | undefined;
119
123
  hidden?: boolean | undefined;
120
124
  root?: string | undefined;
@@ -130,6 +134,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
130
134
  icon?: string | {
131
135
  name: string;
132
136
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
137
+ library?: "fontawesome" | "lucide" | undefined;
133
138
  } | undefined;
134
139
  hidden?: boolean | undefined;
135
140
  root?: string | undefined;
@@ -139,6 +144,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
139
144
  icon?: string | {
140
145
  name: string;
141
146
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
147
+ library?: "fontawesome" | "lucide" | undefined;
142
148
  } | undefined;
143
149
  hidden?: boolean | undefined;
144
150
  root?: string | undefined;
@@ -248,7 +254,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
248
254
  } | undefined;
249
255
  } | undefined;
250
256
  icons?: {
251
- library: "fontawesome";
257
+ library: "fontawesome" | "lucide";
252
258
  } | undefined;
253
259
  styling?: {
254
260
  eyebrows?: "section" | "breadcrumbs" | undefined;
@@ -363,6 +369,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
363
369
  icon?: string | {
364
370
  name: string;
365
371
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
372
+ library?: "fontawesome" | "lucide" | undefined;
366
373
  } | undefined;
367
374
  hidden?: boolean | undefined;
368
375
  root?: string | undefined;
@@ -378,6 +385,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
378
385
  icon?: string | {
379
386
  name: string;
380
387
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
388
+ library?: "fontawesome" | "lucide" | undefined;
381
389
  } | undefined;
382
390
  hidden?: boolean | undefined;
383
391
  root?: string | undefined;
@@ -387,6 +395,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
387
395
  icon?: string | {
388
396
  name: string;
389
397
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
398
+ library?: "fontawesome" | "lucide" | undefined;
390
399
  } | undefined;
391
400
  hidden?: boolean | undefined;
392
401
  root?: string | undefined;
@@ -423,6 +432,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
423
432
  icon?: string | {
424
433
  name: string;
425
434
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
435
+ library?: "fontawesome" | "lucide" | undefined;
426
436
  } | undefined;
427
437
  hidden?: boolean | undefined;
428
438
  root?: string | undefined;
@@ -438,6 +448,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
438
448
  icon?: string | {
439
449
  name: string;
440
450
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
451
+ library?: "fontawesome" | "lucide" | undefined;
441
452
  } | undefined;
442
453
  hidden?: boolean | undefined;
443
454
  root?: string | undefined;
@@ -447,6 +458,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
447
458
  icon?: string | {
448
459
  name: string;
449
460
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
461
+ library?: "fontawesome" | "lucide" | undefined;
450
462
  } | undefined;
451
463
  hidden?: boolean | undefined;
452
464
  root?: string | undefined;
@@ -556,7 +568,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
556
568
  } | undefined;
557
569
  } | undefined;
558
570
  icons?: {
559
- library: "fontawesome";
571
+ library: "fontawesome" | "lucide";
560
572
  } | undefined;
561
573
  styling?: {
562
574
  eyebrows?: "section" | "breadcrumbs" | undefined;
@@ -671,6 +683,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
671
683
  icon?: string | {
672
684
  name: string;
673
685
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
686
+ library?: "fontawesome" | "lucide" | undefined;
674
687
  } | undefined;
675
688
  hidden?: boolean | undefined;
676
689
  root?: string | undefined;
@@ -686,6 +699,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
686
699
  icon?: string | {
687
700
  name: string;
688
701
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
702
+ library?: "fontawesome" | "lucide" | undefined;
689
703
  } | undefined;
690
704
  hidden?: boolean | undefined;
691
705
  root?: string | undefined;
@@ -695,6 +709,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
695
709
  icon?: string | {
696
710
  name: string;
697
711
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
712
+ library?: "fontawesome" | "lucide" | undefined;
698
713
  } | undefined;
699
714
  hidden?: boolean | undefined;
700
715
  root?: string | undefined;
@@ -731,6 +746,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
731
746
  icon?: string | {
732
747
  name: string;
733
748
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
749
+ library?: "fontawesome" | "lucide" | undefined;
734
750
  } | undefined;
735
751
  hidden?: boolean | undefined;
736
752
  root?: string | undefined;
@@ -746,6 +762,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
746
762
  icon?: string | {
747
763
  name: string;
748
764
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
765
+ library?: "fontawesome" | "lucide" | undefined;
749
766
  } | undefined;
750
767
  hidden?: boolean | undefined;
751
768
  root?: string | undefined;
@@ -755,6 +772,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
755
772
  icon?: string | {
756
773
  name: string;
757
774
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
775
+ library?: "fontawesome" | "lucide" | undefined;
758
776
  } | undefined;
759
777
  hidden?: boolean | undefined;
760
778
  root?: string | undefined;
@@ -864,7 +882,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
864
882
  } | undefined;
865
883
  } | undefined;
866
884
  icons?: {
867
- library: "fontawesome";
885
+ library: "fontawesome" | "lucide";
868
886
  } | undefined;
869
887
  styling?: {
870
888
  eyebrows?: "section" | "breadcrumbs" | undefined;
@@ -979,6 +997,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
979
997
  icon?: string | {
980
998
  name: string;
981
999
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1000
+ library?: "fontawesome" | "lucide" | undefined;
982
1001
  } | undefined;
983
1002
  hidden?: boolean | undefined;
984
1003
  root?: string | undefined;
@@ -994,6 +1013,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
994
1013
  icon?: string | {
995
1014
  name: string;
996
1015
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1016
+ library?: "fontawesome" | "lucide" | undefined;
997
1017
  } | undefined;
998
1018
  hidden?: boolean | undefined;
999
1019
  root?: string | undefined;
@@ -1003,6 +1023,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1003
1023
  icon?: string | {
1004
1024
  name: string;
1005
1025
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1026
+ library?: "fontawesome" | "lucide" | undefined;
1006
1027
  } | undefined;
1007
1028
  hidden?: boolean | undefined;
1008
1029
  root?: string | undefined;
@@ -1039,6 +1060,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1039
1060
  icon?: string | {
1040
1061
  name: string;
1041
1062
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1063
+ library?: "fontawesome" | "lucide" | undefined;
1042
1064
  } | undefined;
1043
1065
  hidden?: boolean | undefined;
1044
1066
  root?: string | undefined;
@@ -1054,6 +1076,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1054
1076
  icon?: string | {
1055
1077
  name: string;
1056
1078
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1079
+ library?: "fontawesome" | "lucide" | undefined;
1057
1080
  } | undefined;
1058
1081
  hidden?: boolean | undefined;
1059
1082
  root?: string | undefined;
@@ -1063,6 +1086,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1063
1086
  icon?: string | {
1064
1087
  name: string;
1065
1088
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1089
+ library?: "fontawesome" | "lucide" | undefined;
1066
1090
  } | undefined;
1067
1091
  hidden?: boolean | undefined;
1068
1092
  root?: string | undefined;
@@ -1172,7 +1196,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1172
1196
  } | undefined;
1173
1197
  } | undefined;
1174
1198
  icons?: {
1175
- library: "fontawesome";
1199
+ library: "fontawesome" | "lucide";
1176
1200
  } | undefined;
1177
1201
  styling?: {
1178
1202
  eyebrows?: "section" | "breadcrumbs" | undefined;
@@ -1287,6 +1311,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1287
1311
  icon?: string | {
1288
1312
  name: string;
1289
1313
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1314
+ library?: "fontawesome" | "lucide" | undefined;
1290
1315
  } | undefined;
1291
1316
  hidden?: boolean | undefined;
1292
1317
  root?: string | undefined;
@@ -1302,6 +1327,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1302
1327
  icon?: string | {
1303
1328
  name: string;
1304
1329
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1330
+ library?: "fontawesome" | "lucide" | undefined;
1305
1331
  } | undefined;
1306
1332
  hidden?: boolean | undefined;
1307
1333
  root?: string | undefined;
@@ -1311,6 +1337,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1311
1337
  icon?: string | {
1312
1338
  name: string;
1313
1339
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1340
+ library?: "fontawesome" | "lucide" | undefined;
1314
1341
  } | undefined;
1315
1342
  hidden?: boolean | undefined;
1316
1343
  root?: string | undefined;
@@ -1347,6 +1374,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1347
1374
  icon?: string | {
1348
1375
  name: string;
1349
1376
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1377
+ library?: "fontawesome" | "lucide" | undefined;
1350
1378
  } | undefined;
1351
1379
  hidden?: boolean | undefined;
1352
1380
  root?: string | undefined;
@@ -1362,6 +1390,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1362
1390
  icon?: string | {
1363
1391
  name: string;
1364
1392
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1393
+ library?: "fontawesome" | "lucide" | undefined;
1365
1394
  } | undefined;
1366
1395
  hidden?: boolean | undefined;
1367
1396
  root?: string | undefined;
@@ -1371,6 +1400,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1371
1400
  icon?: string | {
1372
1401
  name: string;
1373
1402
  style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
1403
+ library?: "fontawesome" | "lucide" | undefined;
1374
1404
  } | undefined;
1375
1405
  hidden?: boolean | undefined;
1376
1406
  root?: string | undefined;
@@ -1480,7 +1510,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1480
1510
  } | undefined;
1481
1511
  } | undefined;
1482
1512
  icons?: {
1483
- library: "fontawesome";
1513
+ library: "fontawesome" | "lucide";
1484
1514
  } | undefined;
1485
1515
  styling?: {
1486
1516
  eyebrows?: "section" | "breadcrumbs" | undefined;
@@ -1,15 +1,7 @@
1
1
  import type { OpenApiFile, DecoratedNavigationPage } from '@mintlify/models';
2
- import { DocsConfig, NavigationConfig } from '@mintlify/validation';
2
+ import { DocsConfig } from '@mintlify/validation';
3
3
  export declare const generateOpenApiDivisions: (docsConfig: DocsConfig, openApiFiles: OpenApiFile[], targetDir?: string) => Promise<{
4
4
  newDocsConfig: DocsConfig;
5
5
  pagesAcc: Record<string, DecoratedNavigationPage>;
6
6
  openApiFiles: OpenApiFile[];
7
7
  }>;
8
- export declare const generateOpenApiFromDocsConfig: (navigation: NavigationConfig, openApiFiles: OpenApiFile[], pagesAcc: Record<string, DecoratedNavigationPage>, opts: {
9
- overwrite?: boolean;
10
- writeFiles: boolean;
11
- targetDir?: string;
12
- }) => Promise<{
13
- newNav: NavigationConfig;
14
- newOpenApiFiles: OpenApiFile[];
15
- }>;
@@ -1,9 +1,5 @@
1
- import { getOpenApiDocumentFromUrl, optionallyAddLeadingSlash } from '@mintlify/common';
2
- import { generateOpenApiPagesForDocsConfig } from '@mintlify/scraping';
3
- import { divisions, } from '@mintlify/validation';
4
- import * as path from 'path';
5
1
  import { getOpenApiFilesFromConfig } from '../read/getOpenApiFilesFromConfig.js';
6
- const DEFAULT_OUTPUT_DIR = 'api-reference';
2
+ import { generateOpenApiFromDocsConfig } from './generateOpenApiFromDocsConfig.js';
7
3
  export const generateOpenApiDivisions = async (docsConfig, openApiFiles, targetDir) => {
8
4
  const openapiFilesFromDocsConfig = await getOpenApiFilesFromConfig('docs', docsConfig);
9
5
  openApiFiles.push(...openapiFilesFromDocsConfig);
@@ -19,125 +15,3 @@ export const generateOpenApiDivisions = async (docsConfig, openApiFiles, targetD
19
15
  openApiFiles: [...openApiFiles, ...newOpenApiFiles],
20
16
  };
21
17
  };
22
- export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pagesAcc, opts) => {
23
- const { overwrite, writeFiles, targetDir } = opts;
24
- const newOpenApiFiles = [];
25
- async function processOpenApiInNav(nav) {
26
- let outputDir = DEFAULT_OUTPUT_DIR;
27
- let openapi;
28
- if ('openapi' in nav) {
29
- if (typeof nav.openapi === 'string') {
30
- openapi = nav.openapi;
31
- }
32
- else if (Array.isArray(nav.openapi) && nav.openapi.length > 0) {
33
- // TODO: handle multiple openapi files
34
- openapi = nav.openapi[0];
35
- }
36
- else if (typeof nav.openapi === 'object' && 'source' in nav.openapi) {
37
- openapi = nav.openapi.source;
38
- outputDir = nav.openapi.directory ?? DEFAULT_OUTPUT_DIR;
39
- }
40
- }
41
- if (openapi) {
42
- let openApiFile = undefined;
43
- if (openapi.startsWith('https')) {
44
- openApiFile = await createOpenApiFile(openapi, getDivisionNav(nav)?.division ?? 'unknown');
45
- openApiFile.filename = `${openApiFile.filename}-${newOpenApiFiles.length}`;
46
- newOpenApiFiles.push(openApiFile);
47
- }
48
- else {
49
- openApiFile = openApiFiles.find((file) => file.originalFileLocation != undefined &&
50
- file.originalFileLocation === optionallyAddLeadingSlash(openapi));
51
- }
52
- if (!openApiFile) {
53
- throw new Error(`Openapi file ${openapi} defined in ${getDivisionNav(nav)
54
- ?.division} in your docs.json does not exist`);
55
- }
56
- const { pagesAcc: pagesAccFromGeneratedOpenApiPages, nav: navFromGeneratedOpenApiPages } = await generateOpenApiPagesForDocsConfig(openApiFile.spec, {
57
- openApiFilePath: openApiFile.originalFileLocation,
58
- writeFiles,
59
- outDir: outputDir,
60
- outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
61
- overwrite,
62
- });
63
- Object.entries(pagesAccFromGeneratedOpenApiPages).forEach(([key, value]) => {
64
- pagesAcc[key] = value;
65
- });
66
- const divisionNav = getDivisionNav(nav);
67
- if (divisionNav?.division) {
68
- return {
69
- [divisionNav.division]: divisionNav.name,
70
- ...divisionNav.nav,
71
- ...(divisionNav.division === 'group'
72
- ? {
73
- pages: 'pages' in nav
74
- ? [...nav.pages, ...navFromGeneratedOpenApiPages]
75
- : navFromGeneratedOpenApiPages,
76
- }
77
- : {
78
- groups: 'groups' in nav
79
- ? [...nav.groups, ...navFromGeneratedOpenApiPages]
80
- : navFromGeneratedOpenApiPages,
81
- }),
82
- };
83
- }
84
- }
85
- return null;
86
- }
87
- async function processNav(nav) {
88
- const processedNav = await processOpenApiInNav(nav);
89
- if (processedNav) {
90
- return processedNav;
91
- }
92
- let newNav = { ...nav };
93
- for (const division of ['groups', ...divisions]) {
94
- if (division in newNav) {
95
- const items = newNav[division];
96
- newNav = {
97
- ...newNav,
98
- [division]: await Promise.all(items.map((item) => processNav(item))),
99
- };
100
- }
101
- }
102
- return newNav;
103
- }
104
- const processedNavigation = await processNav(navigation);
105
- navigation = processedNavigation;
106
- return {
107
- newNav: processedNavigation,
108
- newOpenApiFiles,
109
- };
110
- };
111
- function getDivisionNav(nav) {
112
- if ('openapi' in nav) {
113
- const { openapi: _, ...updatedNav } = nav;
114
- const divisionMap = {
115
- group: 'group',
116
- anchor: 'anchor',
117
- tab: 'tab',
118
- version: 'version',
119
- language: 'language',
120
- dropdown: 'dropdown',
121
- };
122
- const divisionType = Object.keys(divisionMap).find((key) => key in updatedNav);
123
- return {
124
- division: divisionMap[divisionType],
125
- name: updatedNav[divisionType],
126
- nav: updatedNav,
127
- };
128
- }
129
- return undefined;
130
- }
131
- async function createOpenApiFile(openApiUrl, division) {
132
- try {
133
- const document = await getOpenApiDocumentFromUrl(openApiUrl);
134
- return {
135
- filename: `openapi-from-${division}`,
136
- spec: document,
137
- };
138
- }
139
- catch (err) {
140
- console.error(err);
141
- throw err;
142
- }
143
- }
@@ -0,0 +1,10 @@
1
+ import type { OpenApiFile, DecoratedNavigationPage } from '@mintlify/models';
2
+ import { NavigationConfig } from '@mintlify/validation';
3
+ export declare const generateOpenApiFromDocsConfig: (navigation: NavigationConfig, openApiFiles: OpenApiFile[], pagesAcc: Record<string, DecoratedNavigationPage>, opts: {
4
+ overwrite?: boolean;
5
+ writeFiles: boolean;
6
+ targetDir?: string;
7
+ }) => Promise<{
8
+ newNav: NavigationConfig;
9
+ newOpenApiFiles: OpenApiFile[];
10
+ }>;
@@ -0,0 +1,127 @@
1
+ import { getOpenApiDocumentFromUrl, optionallyAddLeadingSlash } from '@mintlify/common';
2
+ import { generateOpenApiPagesForDocsConfig } from '@mintlify/scraping';
3
+ import { divisions } from '@mintlify/validation';
4
+ import * as path from 'path';
5
+ const DEFAULT_OUTPUT_DIR = 'api-reference';
6
+ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pagesAcc, opts) => {
7
+ const { overwrite, writeFiles, targetDir } = opts;
8
+ const newOpenApiFiles = [];
9
+ async function processOpenApiInNav(nav) {
10
+ let outputDir = DEFAULT_OUTPUT_DIR;
11
+ let openapi;
12
+ if ('openapi' in nav) {
13
+ if (typeof nav.openapi === 'string') {
14
+ openapi = nav.openapi;
15
+ }
16
+ else if (Array.isArray(nav.openapi) && nav.openapi.length > 0) {
17
+ // TODO: handle multiple openapi files
18
+ openapi = nav.openapi[0];
19
+ }
20
+ else if (typeof nav.openapi === 'object' && 'source' in nav.openapi) {
21
+ openapi = nav.openapi.source;
22
+ outputDir = nav.openapi.directory ?? DEFAULT_OUTPUT_DIR;
23
+ }
24
+ }
25
+ if (openapi) {
26
+ let openApiFile = undefined;
27
+ if (openapi.startsWith('https')) {
28
+ openApiFile = await createOpenApiFile(openapi, getDivisionNav(nav)?.division ?? 'unknown');
29
+ openApiFile.filename = `${openApiFile.filename}-${newOpenApiFiles.length}`;
30
+ newOpenApiFiles.push(openApiFile);
31
+ }
32
+ else {
33
+ openApiFile = openApiFiles.find((file) => file.originalFileLocation != undefined &&
34
+ file.originalFileLocation === optionallyAddLeadingSlash(openapi));
35
+ }
36
+ if (!openApiFile) {
37
+ throw new Error(`Openapi file ${openapi} defined in ${getDivisionNav(nav)
38
+ ?.division} in your docs.json does not exist`);
39
+ }
40
+ const { pagesAcc: pagesAccFromGeneratedOpenApiPages, nav: navFromGeneratedOpenApiPages } = await generateOpenApiPagesForDocsConfig(openApiFile.spec, {
41
+ openApiFilePath: openApiFile.originalFileLocation,
42
+ writeFiles,
43
+ outDir: outputDir,
44
+ outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
45
+ overwrite,
46
+ });
47
+ Object.entries(pagesAccFromGeneratedOpenApiPages).forEach(([key, value]) => {
48
+ pagesAcc[key] = value;
49
+ });
50
+ const divisionNav = getDivisionNav(nav);
51
+ if (divisionNav?.division) {
52
+ return {
53
+ [divisionNav.division]: divisionNav.name,
54
+ ...divisionNav.nav,
55
+ ...(divisionNav.division === 'group'
56
+ ? {
57
+ pages: 'pages' in nav
58
+ ? [...nav.pages, ...navFromGeneratedOpenApiPages]
59
+ : navFromGeneratedOpenApiPages,
60
+ }
61
+ : {
62
+ groups: 'groups' in nav
63
+ ? [...nav.groups, ...navFromGeneratedOpenApiPages]
64
+ : navFromGeneratedOpenApiPages,
65
+ }),
66
+ };
67
+ }
68
+ }
69
+ return null;
70
+ }
71
+ async function processNav(nav) {
72
+ const processedNav = await processOpenApiInNav(nav);
73
+ if (processedNav) {
74
+ return processedNav;
75
+ }
76
+ let newNav = { ...nav };
77
+ for (const division of ['groups', ...divisions]) {
78
+ if (division in newNav) {
79
+ const items = newNav[division];
80
+ newNav = {
81
+ ...newNav,
82
+ [division]: await Promise.all(items.map((item) => processNav(item))),
83
+ };
84
+ }
85
+ }
86
+ return newNav;
87
+ }
88
+ const processedNavigation = await processNav(navigation);
89
+ navigation = processedNavigation;
90
+ return {
91
+ newNav: processedNavigation,
92
+ newOpenApiFiles,
93
+ };
94
+ };
95
+ function getDivisionNav(nav) {
96
+ if ('openapi' in nav) {
97
+ const { openapi: _, ...updatedNav } = nav;
98
+ const divisionMap = {
99
+ group: 'group',
100
+ anchor: 'anchor',
101
+ tab: 'tab',
102
+ version: 'version',
103
+ language: 'language',
104
+ dropdown: 'dropdown',
105
+ };
106
+ const divisionType = Object.keys(divisionMap).find((key) => key in updatedNav);
107
+ return {
108
+ division: divisionMap[divisionType],
109
+ name: updatedNav[divisionType],
110
+ nav: updatedNav,
111
+ };
112
+ }
113
+ return undefined;
114
+ }
115
+ async function createOpenApiFile(openApiUrl, division) {
116
+ try {
117
+ const document = await getOpenApiDocumentFromUrl(openApiUrl);
118
+ return {
119
+ filename: `openapi-from-${division}`,
120
+ spec: document,
121
+ };
122
+ }
123
+ catch (err) {
124
+ console.error(err);
125
+ throw err;
126
+ }
127
+ }