@mintlify/previewing 4.0.327 → 4.0.329
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/local-preview/listener/generate.d.ts +25 -61
- package/dist/local-preview/listener/index.js +6 -2
- package/dist/local-preview/listener/update.d.ts +1 -0
- package/dist/local-preview/listener/update.js +24 -6
- package/dist/local-preview/listener/utils.d.ts +1 -0
- package/dist/local-preview/listener/utils.js +5 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
import type { DecoratedNavigationPage } from '@mintlify/models';
|
|
2
2
|
export declare const generateNav: (pagesAcc: Record<string, DecoratedNavigationPage>) => Promise<{
|
|
3
3
|
generatedNav: import("@mintlify/models").DecoratedNavigation;
|
|
4
|
-
generatedDocsNav: {
|
|
4
|
+
generatedDocsNav: ({
|
|
5
|
+
languages: import("@mintlify/validation/dist/mint-config/schemas/v2/properties/navigation/divisionNav.js").LanguageNavigation<"decorated">[];
|
|
6
|
+
} | {
|
|
7
|
+
versions: import("@mintlify/validation/dist/mint-config/schemas/v2/properties/navigation/divisionNav.js").VersionNavigation<"decorated">[];
|
|
8
|
+
} | {
|
|
9
|
+
tabs: import("@mintlify/validation/dist/mint-config/schemas/v2/properties/navigation/divisionNav.js").TabNavigation<"decorated">[];
|
|
10
|
+
} | {
|
|
11
|
+
dropdowns: import("@mintlify/validation/dist/mint-config/schemas/v2/properties/navigation/divisionNav.js").DropdownNavigation<"decorated">[];
|
|
12
|
+
} | {
|
|
13
|
+
anchors: import("@mintlify/validation/dist/mint-config/schemas/v2/properties/navigation/divisionNav.js").AnchorNavigation<"decorated">[];
|
|
14
|
+
} | {
|
|
15
|
+
groups: {
|
|
16
|
+
group: string;
|
|
17
|
+
pages: any[];
|
|
18
|
+
icon?: string | {
|
|
19
|
+
name: string;
|
|
20
|
+
style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
|
|
21
|
+
} | undefined;
|
|
22
|
+
hidden?: boolean | undefined;
|
|
23
|
+
root?: string | undefined;
|
|
24
|
+
}[];
|
|
25
|
+
} | {
|
|
26
|
+
pages: any[];
|
|
27
|
+
}) & {
|
|
5
28
|
global?: {
|
|
6
29
|
languages?: ({
|
|
7
30
|
language: "en" | "cn" | "es" | "fr" | "jp" | "pt" | "pt-BR" | "de";
|
|
@@ -50,64 +73,5 @@ export declare const generateNav: (pagesAcc: Record<string, DecoratedNavigationP
|
|
|
50
73
|
href: string;
|
|
51
74
|
})[] | undefined;
|
|
52
75
|
} | undefined;
|
|
53
|
-
}
|
|
54
|
-
languages: any[];
|
|
55
|
-
} | {
|
|
56
|
-
versions: any[];
|
|
57
|
-
} | {
|
|
58
|
-
tabs: any[];
|
|
59
|
-
} | {
|
|
60
|
-
dropdowns: any[];
|
|
61
|
-
} | {
|
|
62
|
-
anchors: any[];
|
|
63
|
-
} | {
|
|
64
|
-
groups: ({
|
|
65
|
-
group: string;
|
|
66
|
-
icon?: string | {
|
|
67
|
-
name: string;
|
|
68
|
-
style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
|
|
69
|
-
} | undefined;
|
|
70
|
-
hidden?: boolean | undefined;
|
|
71
|
-
root?: string | {
|
|
72
|
-
href: string;
|
|
73
|
-
title: string;
|
|
74
|
-
sidebarTitle?: string | undefined;
|
|
75
|
-
description?: string | undefined;
|
|
76
|
-
api?: string | undefined;
|
|
77
|
-
openapi?: string | undefined;
|
|
78
|
-
contentType?: string | undefined;
|
|
79
|
-
authMethod?: string | undefined;
|
|
80
|
-
auth?: string | undefined;
|
|
81
|
-
version?: string | undefined;
|
|
82
|
-
mode?: string | undefined;
|
|
83
|
-
hideFooterPagination?: boolean | undefined;
|
|
84
|
-
authors?: unknown;
|
|
85
|
-
lastUpdatedDate?: string | undefined;
|
|
86
|
-
createdDate?: string | undefined;
|
|
87
|
-
"openapi-schema"?: string | undefined;
|
|
88
|
-
icon?: string | {
|
|
89
|
-
name: string;
|
|
90
|
-
style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
|
|
91
|
-
} | undefined;
|
|
92
|
-
tag?: string | undefined;
|
|
93
|
-
url?: string | undefined;
|
|
94
|
-
hideApiMarker?: boolean | undefined;
|
|
95
|
-
noindex?: boolean | undefined;
|
|
96
|
-
isPublic?: boolean | undefined;
|
|
97
|
-
public?: boolean | undefined;
|
|
98
|
-
} | undefined;
|
|
99
|
-
} & ({
|
|
100
|
-
openapi: (string | string[] | {
|
|
101
|
-
source: string;
|
|
102
|
-
directory?: string | undefined;
|
|
103
|
-
}) & (string | string[] | {
|
|
104
|
-
source: string;
|
|
105
|
-
directory?: string | undefined;
|
|
106
|
-
} | undefined);
|
|
107
|
-
} | {
|
|
108
|
-
pages: any[];
|
|
109
|
-
}))[];
|
|
110
|
-
} | {
|
|
111
|
-
pages: any[];
|
|
112
|
-
});
|
|
76
|
+
};
|
|
113
77
|
}>;
|
|
@@ -20,7 +20,7 @@ import { CMD_EXEC_PATH, NEXT_PROPS_PATH, NEXT_PUBLIC_PATH, CLIENT_PATH } from '.
|
|
|
20
20
|
import { generatePagesWithImports } from './generatePagesWithImports.js';
|
|
21
21
|
import { getDocsState } from './getDocsState.js';
|
|
22
22
|
import { resolveAllImports } from './resolveAllImports.js';
|
|
23
|
-
import { updateGeneratedNav, updateOpenApiFiles } from './update.js';
|
|
23
|
+
import { updateGeneratedNav, updateOpenApiFiles, upsertOpenApiFile } from './update.js';
|
|
24
24
|
import { isFileSizeValid } from './utils.js';
|
|
25
25
|
const { readFile } = _promises;
|
|
26
26
|
const listener = (callback) => {
|
|
@@ -236,7 +236,11 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
|
|
|
236
236
|
doc = undefined;
|
|
237
237
|
}
|
|
238
238
|
if (doc) {
|
|
239
|
-
|
|
239
|
+
yield upsertOpenApiFile({
|
|
240
|
+
filename: pathUtil.parse(filename).name,
|
|
241
|
+
originalFileLocation: '/' + filename,
|
|
242
|
+
spec: doc,
|
|
243
|
+
});
|
|
240
244
|
yield updateOpenApiFiles();
|
|
241
245
|
regenerateNav = true;
|
|
242
246
|
category = 'openApi';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { OpenApiFile } from '@mintlify/models';
|
|
2
2
|
export declare const updateGeneratedNav: () => Promise<void>;
|
|
3
3
|
export declare const updateOpenApiFiles: (providedOpenApiFiles?: OpenApiFile[]) => Promise<void>;
|
|
4
|
+
export declare const upsertOpenApiFile: (openApiFile: OpenApiFile) => Promise<void>;
|
|
@@ -7,31 +7,49 @@ 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 { categorizeFilePaths } from '@mintlify/prebuild';
|
|
11
10
|
import fse from 'fs-extra';
|
|
12
11
|
import { join } from 'path';
|
|
13
|
-
import {
|
|
12
|
+
import { NEXT_PROPS_PATH } from '../../constants.js';
|
|
14
13
|
import { generateNav } from './generate.js';
|
|
15
14
|
import { getDocsState } from './getDocsState.js';
|
|
15
|
+
import { readJsonFile } from './utils.js';
|
|
16
16
|
export const updateGeneratedNav = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const { pagesAcc } = yield getDocsState();
|
|
18
18
|
const { generatedNav, generatedDocsNav } = yield generateNav(pagesAcc);
|
|
19
|
-
const targetPath = join(
|
|
19
|
+
const targetPath = join(NEXT_PROPS_PATH, 'generatedNav.json');
|
|
20
20
|
yield fse.outputFile(targetPath, JSON.stringify(generatedNav, null, 2), {
|
|
21
21
|
flag: 'w',
|
|
22
22
|
});
|
|
23
|
-
const targetDocsPath = join(
|
|
23
|
+
const targetDocsPath = join(NEXT_PROPS_PATH, 'generatedDocsNav.json');
|
|
24
24
|
yield fse.outputFile(targetDocsPath, JSON.stringify(generatedDocsNav, null, 2), {
|
|
25
25
|
flag: 'w',
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
28
|
export const updateOpenApiFiles = (providedOpenApiFiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
29
|
if (providedOpenApiFiles == undefined) {
|
|
30
|
-
const { openApiFiles } = yield
|
|
30
|
+
const { openApiFiles } = yield getDocsState();
|
|
31
31
|
providedOpenApiFiles = openApiFiles;
|
|
32
32
|
}
|
|
33
|
-
const targetPath = join(
|
|
33
|
+
const targetPath = join(NEXT_PROPS_PATH, 'openApiFiles.json');
|
|
34
34
|
yield fse.outputFile(targetPath, JSON.stringify(providedOpenApiFiles, null, 2), {
|
|
35
35
|
flag: 'w',
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
|
+
export const upsertOpenApiFile = (openApiFile) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
const sourcePath = join(NEXT_PROPS_PATH, 'openApiFiles.json');
|
|
40
|
+
let existingOpenApiFiles = [];
|
|
41
|
+
try {
|
|
42
|
+
existingOpenApiFiles = (yield readJsonFile(sourcePath));
|
|
43
|
+
}
|
|
44
|
+
catch (_a) { }
|
|
45
|
+
const existingIndex = existingOpenApiFiles.findIndex((file) => file.originalFileLocation === openApiFile.originalFileLocation);
|
|
46
|
+
if (existingIndex >= 0) {
|
|
47
|
+
existingOpenApiFiles[existingIndex] = openApiFile;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
existingOpenApiFiles.push(openApiFile);
|
|
51
|
+
}
|
|
52
|
+
yield fse.outputFile(sourcePath, JSON.stringify(existingOpenApiFiles, null, 2), {
|
|
53
|
+
flag: 'w',
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const getFileExtension: (filename: string) => string;
|
|
2
2
|
export declare const isFileSizeValid: (path: string, maxFileSizeInMb: number) => Promise<boolean>;
|
|
3
3
|
export declare function isError(obj: unknown): boolean;
|
|
4
|
+
export declare const readJsonFile: (path: string) => Promise<any>;
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { promises as _promises } from 'fs';
|
|
11
|
+
import fse from 'fs-extra';
|
|
11
12
|
const { stat } = _promises;
|
|
12
13
|
export const getFileExtension = (filename) => {
|
|
13
14
|
return filename.substring(filename.lastIndexOf('.') + 1, filename.length) || filename;
|
|
@@ -20,3 +21,7 @@ export const isFileSizeValid = (path, maxFileSizeInMb) => __awaiter(void 0, void
|
|
|
20
21
|
export function isError(obj) {
|
|
21
22
|
return Object.prototype.toString.call(obj) === '[object Error]';
|
|
22
23
|
}
|
|
24
|
+
export const readJsonFile = (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
const file = yield fse.readFile(path, 'utf-8');
|
|
26
|
+
return JSON.parse(file);
|
|
27
|
+
});
|