@mintlify/prebuild 1.0.800 → 1.0.802

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,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';
@@ -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
  }
@@ -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 {