@mintlify/prebuild 1.0.799 → 1.0.801
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/prebuild/index.d.ts +2 -1
- package/dist/prebuild/index.js +2 -1
- package/dist/prebuild/update/ConfigUpdater.d.ts +2 -2
- package/dist/prebuild/update/ConfigUpdater.js +6 -3
- package/dist/prebuild/update/docsConfig/generateOpenApiFromDocsConfig.js +23 -13
- package/dist/prebuild/update/docsConfig/index.d.ts +2 -1
- package/dist/prebuild/update/docsConfig/index.js +2 -2
- package/dist/prebuild/update/index.d.ts +2 -1
- package/dist/prebuild/update/index.js +3 -2
- package/dist/prebuild/update/mintConfig/index.d.ts +1 -1
- package/dist/prebuild/update/mintConfig/index.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/prebuild/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export interface PrebuildResult {
|
|
2
2
|
fileImportsMap: Map<string, Set<string>>;
|
|
3
3
|
}
|
|
4
|
-
export declare const prebuild: (contentDirectoryPath: string, { localSchema, groups, disableOpenApi, }?: {
|
|
4
|
+
export declare const prebuild: (contentDirectoryPath: string, { localSchema, groups, disableOpenApi, strict, }?: {
|
|
5
5
|
localSchema?: boolean;
|
|
6
6
|
groups?: string[];
|
|
7
7
|
disableOpenApi?: boolean;
|
|
8
|
+
strict?: boolean;
|
|
8
9
|
}) => Promise<PrebuildResult | undefined>;
|
|
9
10
|
export * from './categorizeFilePaths.js';
|
|
10
11
|
export * from '../createPage/index.js';
|
package/dist/prebuild/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getConfigPath, getMintIgnore } from '../utils.js';
|
|
2
2
|
import { categorizeFilePaths } from './categorizeFilePaths.js';
|
|
3
3
|
import { update } from './update/index.js';
|
|
4
|
-
export const prebuild = async (contentDirectoryPath, { localSchema, groups, disableOpenApi, } = {}) => {
|
|
4
|
+
export const prebuild = async (contentDirectoryPath, { localSchema, groups, disableOpenApi, strict, } = {}) => {
|
|
5
5
|
if (process.env.IS_MULTI_TENANT === 'true') {
|
|
6
6
|
console.log('Skipping prebuild in multi-tenant mode.');
|
|
7
7
|
return;
|
|
@@ -26,6 +26,7 @@ export const prebuild = async (contentDirectoryPath, { localSchema, groups, disa
|
|
|
26
26
|
groups,
|
|
27
27
|
mintIgnore,
|
|
28
28
|
disableOpenApi,
|
|
29
|
+
strict,
|
|
29
30
|
});
|
|
30
31
|
return { fileImportsMap };
|
|
31
32
|
};
|
|
@@ -3,8 +3,8 @@ export declare class ConfigUpdater<T> {
|
|
|
3
3
|
private type;
|
|
4
4
|
constructor(type: ConfigType);
|
|
5
5
|
getConfigType(): "mint" | "docs";
|
|
6
|
-
getConfig(configPath: string, onError?: (message: string) => void): Promise<T>;
|
|
7
|
-
validateConfigJsonString: (configContents: string, onError?: (message: string) => void) => Promise<{
|
|
6
|
+
getConfig(configPath: string, strict?: boolean, onError?: (message: string) => void): Promise<T>;
|
|
7
|
+
validateConfigJsonString: (configContents: string, strict?: boolean, onError?: (message: string) => void) => Promise<{
|
|
8
8
|
data: T;
|
|
9
9
|
warnings: import("zod").ZodIssue[];
|
|
10
10
|
success: true;
|
|
@@ -6,7 +6,7 @@ import { join } from 'path';
|
|
|
6
6
|
const { readFile } = _promises;
|
|
7
7
|
export class ConfigUpdater {
|
|
8
8
|
constructor(type) {
|
|
9
|
-
this.validateConfigJsonString = async (configContents, onError) => {
|
|
9
|
+
this.validateConfigJsonString = async (configContents, strict, onError) => {
|
|
10
10
|
const configObj = this.parseConfigJson(configContents, onError);
|
|
11
11
|
const validationResults = this.type === 'mint' ? validateMintConfig(configObj) : validateDocsConfig(configObj);
|
|
12
12
|
if (!validationResults.success) {
|
|
@@ -32,6 +32,9 @@ export class ConfigUpdater {
|
|
|
32
32
|
else {
|
|
33
33
|
console.warn(Chalk.yellow(warnMsg));
|
|
34
34
|
warnings.forEach((warning) => console.warn(Chalk.yellow(warning)));
|
|
35
|
+
if (strict) {
|
|
36
|
+
throw Error('Validation warnings treated as errors in strict mode');
|
|
37
|
+
}
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
return { ...validationResults, data: validationResults.data };
|
|
@@ -91,9 +94,9 @@ export class ConfigUpdater {
|
|
|
91
94
|
getConfigType() {
|
|
92
95
|
return this.type;
|
|
93
96
|
}
|
|
94
|
-
async getConfig(configPath, onError) {
|
|
97
|
+
async getConfig(configPath, strict, onError) {
|
|
95
98
|
const configContents = await this.readConfigFile(configPath);
|
|
96
|
-
const validationResults = await this.validateConfigJsonString(configContents, onError);
|
|
99
|
+
const validationResults = await this.validateConfigJsonString(configContents, strict, onError);
|
|
97
100
|
return validationResults.data;
|
|
98
101
|
}
|
|
99
102
|
}
|
|
@@ -82,31 +82,41 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
|
|
|
82
82
|
if ('openapi' in nav && nav.openapi !== null) {
|
|
83
83
|
const openapiProp = nav.openapi;
|
|
84
84
|
if (typeof openapiProp === 'string') {
|
|
85
|
-
return openapiProp;
|
|
85
|
+
return { source: openapiProp, directory: undefined };
|
|
86
86
|
}
|
|
87
87
|
else if (Array.isArray(openapiProp) && openapiProp.length > 0) {
|
|
88
|
-
return openapiProp[0];
|
|
88
|
+
return { source: openapiProp[0], directory: undefined };
|
|
89
89
|
}
|
|
90
90
|
else if (typeof openapiProp === 'object' &&
|
|
91
91
|
'source' in openapiProp &&
|
|
92
92
|
typeof openapiProp.source === 'string') {
|
|
93
|
-
|
|
93
|
+
const directory = 'directory' in openapiProp && typeof openapiProp.directory === 'string'
|
|
94
|
+
? openapiProp.directory
|
|
95
|
+
: undefined;
|
|
96
|
+
return {
|
|
97
|
+
source: openapiProp.source,
|
|
98
|
+
directory,
|
|
99
|
+
};
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
|
-
return undefined;
|
|
102
|
+
return { source: undefined, directory: undefined };
|
|
97
103
|
}
|
|
98
104
|
const skipBulkForNode = new Set();
|
|
99
105
|
const skipBulkForNodeId = new Set();
|
|
100
106
|
let numNodes = 0;
|
|
101
|
-
async function processNav(nav, inheritedOpenApi, openApiOwner) {
|
|
107
|
+
async function processNav(nav, inheritedOpenApi, inheritedDirectory, openApiOwner) {
|
|
102
108
|
const nodeId = numNodes++;
|
|
103
|
-
const
|
|
104
|
-
const
|
|
109
|
+
const extracted = extractOpenApiFromNav(nav);
|
|
110
|
+
const currentOpenApi = extracted.source ?? inheritedOpenApi;
|
|
111
|
+
const currentDirectory = extracted.source
|
|
112
|
+
? extracted.directory
|
|
113
|
+
: extracted.directory ?? inheritedDirectory;
|
|
114
|
+
const currentOpenApiOwner = extracted.source ? nodeId : openApiOwner;
|
|
105
115
|
let newNav = nav;
|
|
106
116
|
if ('pages' in newNav) {
|
|
107
117
|
newNav.pages = await Promise.all(newNav.pages.map(async (page) => {
|
|
108
118
|
if (typeof page === 'object' && page !== null && 'group' in page) {
|
|
109
|
-
return processNav(page, currentOpenApi, currentOpenApiOwner);
|
|
119
|
+
return processNav(page, currentOpenApi, currentDirectory, currentOpenApiOwner);
|
|
110
120
|
}
|
|
111
121
|
if (typeof page !== 'string') {
|
|
112
122
|
return page;
|
|
@@ -152,7 +162,7 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
|
|
|
152
162
|
processOpenApiWebhook(endpoint, webhookObject, schema, tempNav, tempDecoratedNav, writePromises, pagesAcc, {
|
|
153
163
|
openApiFilePath: openApiFile.originalFileLocation,
|
|
154
164
|
writeFiles,
|
|
155
|
-
outDir: DEFAULT_OUTPUT_DIR,
|
|
165
|
+
outDir: currentDirectory ?? DEFAULT_OUTPUT_DIR,
|
|
156
166
|
outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
|
|
157
167
|
overwrite,
|
|
158
168
|
localSchema,
|
|
@@ -170,7 +180,7 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
|
|
|
170
180
|
processOpenApiPath(endpoint, { [method.toLowerCase()]: opObject }, schema, tempNav, tempDecoratedNav, writePromises, pagesAcc, {
|
|
171
181
|
openApiFilePath: openApiFile.originalFileLocation,
|
|
172
182
|
writeFiles,
|
|
173
|
-
outDir: DEFAULT_OUTPUT_DIR,
|
|
183
|
+
outDir: currentDirectory ?? DEFAULT_OUTPUT_DIR,
|
|
174
184
|
outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
|
|
175
185
|
overwrite,
|
|
176
186
|
localSchema,
|
|
@@ -209,7 +219,7 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
|
|
|
209
219
|
const items = newNav[division];
|
|
210
220
|
newNav = {
|
|
211
221
|
...newNav,
|
|
212
|
-
[division]: await Promise.all(items.map((item) => processNav(item, currentOpenApi, currentOpenApiOwner))),
|
|
222
|
+
[division]: await Promise.all(items.map((item) => processNav(item, currentOpenApi, currentDirectory, currentOpenApiOwner))),
|
|
213
223
|
};
|
|
214
224
|
}
|
|
215
225
|
}
|
|
@@ -218,10 +228,10 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
|
|
|
218
228
|
}
|
|
219
229
|
return newNav;
|
|
220
230
|
}
|
|
221
|
-
const navAfterExplicit = await processNav(navigation, undefined);
|
|
231
|
+
const navAfterExplicit = await processNav(navigation, undefined, undefined, undefined);
|
|
222
232
|
async function generateBulkNav(node) {
|
|
223
233
|
let updated = node;
|
|
224
|
-
if (extractOpenApiFromNav(updated) && !skipBulkForNode.has(updated)) {
|
|
234
|
+
if (extractOpenApiFromNav(updated).source && !skipBulkForNode.has(updated)) {
|
|
225
235
|
const processed = await processOpenApiInNav(updated);
|
|
226
236
|
if (processed)
|
|
227
237
|
updated = processed;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { AsyncAPIFile } from '@mintlify/common';
|
|
2
2
|
import { OpenApiFile, DecoratedNavigationPage } from '@mintlify/models';
|
|
3
3
|
import { DocsConfig } from '@mintlify/validation';
|
|
4
|
-
export declare function updateDocsConfigFile({ contentDirectoryPath, openApiFiles, asyncApiFiles, docsConfig, localSchema, disableOpenApi, }: {
|
|
4
|
+
export declare function updateDocsConfigFile({ contentDirectoryPath, openApiFiles, asyncApiFiles, docsConfig, localSchema, disableOpenApi, strict, }: {
|
|
5
5
|
contentDirectoryPath: string;
|
|
6
6
|
openApiFiles: OpenApiFile[];
|
|
7
7
|
asyncApiFiles: AsyncAPIFile[];
|
|
8
8
|
docsConfig?: DocsConfig;
|
|
9
9
|
localSchema?: boolean;
|
|
10
10
|
disableOpenApi?: boolean;
|
|
11
|
+
strict?: boolean;
|
|
11
12
|
}): Promise<{
|
|
12
13
|
docsConfig: DocsConfig;
|
|
13
14
|
pagesAcc: Record<string, DecoratedNavigationPage>;
|
|
@@ -4,13 +4,13 @@ import { generateAsyncApiDivisions } from './generateAsyncApiDivisions.js';
|
|
|
4
4
|
import { generateOpenApiDivisions } from './generateOpenApiDivisions.js';
|
|
5
5
|
import { getCustomLanguages } from './getCustomLanguages.js';
|
|
6
6
|
const NOT_CORRECT_PATH_ERROR = 'must be run in a directory where a docs.json file exists.';
|
|
7
|
-
export async function updateDocsConfigFile({ contentDirectoryPath, openApiFiles, asyncApiFiles, docsConfig, localSchema, disableOpenApi, }) {
|
|
7
|
+
export async function updateDocsConfigFile({ contentDirectoryPath, openApiFiles, asyncApiFiles, docsConfig, localSchema, disableOpenApi, strict, }) {
|
|
8
8
|
const configPath = await getConfigPath(contentDirectoryPath, 'docs');
|
|
9
9
|
if (configPath == null && docsConfig == null) {
|
|
10
10
|
throw Error(NOT_CORRECT_PATH_ERROR);
|
|
11
11
|
}
|
|
12
12
|
if (docsConfig == null && configPath) {
|
|
13
|
-
docsConfig = await DocsConfigUpdater.getConfig(configPath);
|
|
13
|
+
docsConfig = await DocsConfigUpdater.getConfig(configPath, strict);
|
|
14
14
|
}
|
|
15
15
|
if (docsConfig == null) {
|
|
16
16
|
throw Error(NOT_CORRECT_PATH_ERROR);
|
|
@@ -14,8 +14,9 @@ type UpdateArgs = {
|
|
|
14
14
|
groups?: string[];
|
|
15
15
|
mintIgnore?: string[];
|
|
16
16
|
disableOpenApi?: boolean;
|
|
17
|
+
strict?: boolean;
|
|
17
18
|
};
|
|
18
|
-
export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, }: UpdateArgs) => Promise<{
|
|
19
|
+
export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, strict, }: UpdateArgs) => Promise<{
|
|
19
20
|
name: string;
|
|
20
21
|
$schema: string;
|
|
21
22
|
theme: "mint";
|
|
@@ -12,8 +12,8 @@ import { writeAsyncApiFiles } from './write/writeAsyncApiFiles.js';
|
|
|
12
12
|
import { writeFiles, writeFile } from './write/writeFiles.js';
|
|
13
13
|
import { writeOpenApiData } from './write/writeOpenApiData.js';
|
|
14
14
|
import { writeRssFiles } from './write/writeRssFiles.js';
|
|
15
|
-
export const update = async ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, }) => {
|
|
16
|
-
const mintConfigResult = await updateMintConfigFile(contentDirectoryPath, openApiFiles, localSchema);
|
|
15
|
+
export const update = async ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, strict, }) => {
|
|
16
|
+
const mintConfigResult = await updateMintConfigFile(contentDirectoryPath, openApiFiles, localSchema, strict);
|
|
17
17
|
// we used the original mint config without openapi pages injected
|
|
18
18
|
// because we will do it in `updateDocsConfigFile`, this will avoid duplicated openapi pages
|
|
19
19
|
const docsConfig = mintConfigResult != null ? upgradeToDocsConfig(mintConfigResult.originalMintConfig) : undefined;
|
|
@@ -24,6 +24,7 @@ export const update = async ({ contentDirectoryPath, staticFilenames, openApiFil
|
|
|
24
24
|
docsConfig: docsConfigPath ? undefined : docsConfig,
|
|
25
25
|
localSchema,
|
|
26
26
|
disableOpenApi,
|
|
27
|
+
strict,
|
|
27
28
|
});
|
|
28
29
|
const pagePromises = readPageContents({
|
|
29
30
|
contentDirectoryPath,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DecoratedNavigationPage, MintConfig, OpenApiFile } from '@mintlify/models';
|
|
2
|
-
export declare function updateMintConfigFile(contentDirectoryPath: string, openApiFiles: OpenApiFile[], localSchema?: boolean): Promise<{
|
|
2
|
+
export declare function updateMintConfigFile(contentDirectoryPath: string, openApiFiles: OpenApiFile[], localSchema?: boolean, strict?: boolean): Promise<{
|
|
3
3
|
mintConfig: MintConfig;
|
|
4
4
|
originalMintConfig: MintConfig;
|
|
5
5
|
pagesAcc: Record<string, DecoratedNavigationPage>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { getConfigPath } from '../../../utils.js';
|
|
2
2
|
import { MintConfigUpdater } from '../ConfigUpdater.js';
|
|
3
3
|
import { generateOpenApiAnchorsOrTabs } from './generateOpenApiAnchorsOrTabs.js';
|
|
4
|
-
export async function updateMintConfigFile(contentDirectoryPath, openApiFiles, localSchema) {
|
|
4
|
+
export async function updateMintConfigFile(contentDirectoryPath, openApiFiles, localSchema, strict) {
|
|
5
5
|
const configPath = await getConfigPath(contentDirectoryPath, 'mint');
|
|
6
6
|
if (configPath == null) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
|
-
const mintConfig = await MintConfigUpdater.getConfig(configPath);
|
|
9
|
+
const mintConfig = await MintConfigUpdater.getConfig(configPath, strict);
|
|
10
10
|
const { mintConfig: newMintConfig, pagesAcc, openApiFiles: newOpenApiFiles, } = await generateOpenApiAnchorsOrTabs(mintConfig, openApiFiles, undefined, localSchema);
|
|
11
11
|
await MintConfigUpdater.writeConfigFile(newMintConfig);
|
|
12
12
|
return {
|