@mintlify/previewing 4.0.527 → 4.0.528

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,33 +1,27 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { categorizeFilePaths, createPage, generateDecoratedDocsNavigationFromPages, } from '@mintlify/prebuild';
11
2
  import { promises as _promises } from 'fs';
12
3
  import { join } from 'path';
13
4
  import { CMD_EXEC_PATH } from '../../constants.js';
14
5
  const { readFile } = _promises;
15
- const createFilenamePageMetadataMap = (_a) => __awaiter(void 0, [_a], void 0, function* ({ contentDirectoryPath, contentFilenames, openApiFiles, asyncApiFiles, pagesAcc = {}, }) {
6
+ const createFilenamePageMetadataMap = async ({ contentDirectoryPath, contentFilenames, openApiFiles, asyncApiFiles, pagesAcc = {}, }) => {
16
7
  const contentPromises = [];
17
8
  contentFilenames.forEach((filename) => {
18
- contentPromises.push((() => __awaiter(void 0, void 0, void 0, function* () {
9
+ contentPromises.push((async () => {
19
10
  const sourcePath = join(contentDirectoryPath, filename);
20
- const contentStr = (yield readFile(sourcePath)).toString();
21
- const { slug, pageMetadata } = yield createPage(filename, contentStr, contentDirectoryPath, openApiFiles, asyncApiFiles, true);
22
- pagesAcc = Object.assign(Object.assign({}, pagesAcc), { [slug]: pageMetadata });
23
- }))());
11
+ const contentStr = (await readFile(sourcePath)).toString();
12
+ const { slug, pageMetadata } = await createPage(filename, contentStr, contentDirectoryPath, openApiFiles, asyncApiFiles, true);
13
+ pagesAcc = {
14
+ ...pagesAcc,
15
+ [slug]: pageMetadata,
16
+ };
17
+ })());
24
18
  });
25
- yield Promise.all(contentPromises);
19
+ await Promise.all(contentPromises);
26
20
  return pagesAcc;
27
- });
28
- export const generateNav = (pagesAcc, docsConfig) => __awaiter(void 0, void 0, void 0, function* () {
29
- const { contentFilenames, openApiFiles, asyncApiFiles } = yield categorizeFilePaths(CMD_EXEC_PATH);
30
- const filenamePageMetadataMap = yield createFilenamePageMetadataMap({
21
+ };
22
+ export const generateNav = async (pagesAcc, docsConfig) => {
23
+ const { contentFilenames, openApiFiles, asyncApiFiles } = await categorizeFilePaths(CMD_EXEC_PATH);
24
+ const filenamePageMetadataMap = await createFilenamePageMetadataMap({
31
25
  contentDirectoryPath: CMD_EXEC_PATH,
32
26
  contentFilenames,
33
27
  openApiFiles,
@@ -36,4 +30,4 @@ export const generateNav = (pagesAcc, docsConfig) => __awaiter(void 0, void 0, v
36
30
  });
37
31
  const generatedDocsNav = generateDecoratedDocsNavigationFromPages(filenamePageMetadataMap, docsConfig.navigation);
38
32
  return generatedDocsNav;
39
- });
33
+ };
@@ -1,19 +1,10 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { findAndRemoveImports, stringifyTree, topologicalSort, hasImports, optionallyAddLeadingSlash, optionallyRemoveLeadingSlash, } from '@mintlify/common';
11
2
  import { outputFile } from 'fs-extra';
12
3
  import { join } from 'path';
13
4
  import { NEXT_PUBLIC_PATH } from '../../constants.js';
14
5
  import { getOriginalSnippets } from './getSnippets.js';
15
6
  import { resolveAllImports } from './resolveAllImports.js';
16
- const findAllDependents = (initialFileWithSlash, allSnippets, processedDataCache) => __awaiter(void 0, void 0, void 0, function* () {
7
+ const findAllDependents = async (initialFileWithSlash, allSnippets, processedDataCache) => {
17
8
  const affected = new Set([initialFileWithSlash]);
18
9
  const queue = [initialFileWithSlash];
19
10
  while (queue.length > 0) {
@@ -25,7 +16,7 @@ const findAllDependents = (initialFileWithSlash, allSnippets, processedDataCache
25
16
  let processedData = processedDataCache.get(potentialDependentFile);
26
17
  if (processedData == null) {
27
18
  const clonedTree = structuredClone(snippet.tree);
28
- processedData = yield findAndRemoveImports(clonedTree);
19
+ processedData = await findAndRemoveImports(clonedTree);
29
20
  processedDataCache.set(potentialDependentFile, processedData);
30
21
  }
31
22
  if (processedData.importMap[currentSourceFile]) {
@@ -37,30 +28,36 @@ const findAllDependents = (initialFileWithSlash, allSnippets, processedDataCache
37
28
  }
38
29
  }
39
30
  return affected;
40
- });
41
- export const generateDependentSnippets = (changedFilename, newImportData) => __awaiter(void 0, void 0, void 0, function* () {
31
+ };
32
+ export const generateDependentSnippets = async (changedFilename, newImportData) => {
42
33
  const processedDataCache = new Map();
43
- const allOriginalSnippets = yield getOriginalSnippets();
34
+ const allOriginalSnippets = await getOriginalSnippets();
44
35
  const updatedSnippetFileKey = optionallyAddLeadingSlash(changedFilename);
45
- const affectedSnippets = yield findAllDependents(updatedSnippetFileKey, allOriginalSnippets, processedDataCache);
46
- const snippetPromises = Array.from(affectedSnippets).map((filename) => __awaiter(void 0, void 0, void 0, function* () {
36
+ const affectedSnippets = await findAllDependents(updatedSnippetFileKey, allOriginalSnippets, processedDataCache);
37
+ const snippetPromises = Array.from(affectedSnippets).map(async (filename) => {
47
38
  const cachedData = processedDataCache.get(filename);
48
39
  if (cachedData)
49
- return Object.assign({ filename }, cachedData);
40
+ return { filename, ...cachedData };
50
41
  const originalSnippet = allOriginalSnippets.find((s) => optionallyAddLeadingSlash(s.filename) === filename);
51
42
  if (!originalSnippet)
52
43
  return null;
53
- const processed = yield findAndRemoveImports(structuredClone(originalSnippet.tree));
44
+ const processed = await findAndRemoveImports(structuredClone(originalSnippet.tree));
54
45
  processedDataCache.set(filename, processed);
55
- return Object.assign({ filename }, processed);
56
- }));
57
- const snippets = (yield Promise.all(snippetPromises)).filter((item) => item != null);
46
+ return { filename, ...processed };
47
+ });
48
+ const snippets = (await Promise.all(snippetPromises)).filter((item) => item != null);
58
49
  const idx = snippets.findIndex((item) => item.filename === updatedSnippetFileKey);
59
50
  if (idx !== -1) {
60
- snippets[idx] = Object.assign(Object.assign({}, newImportData), { filename: updatedSnippetFileKey });
51
+ snippets[idx] = {
52
+ ...newImportData,
53
+ filename: updatedSnippetFileKey,
54
+ };
61
55
  }
62
56
  else {
63
- snippets.push(Object.assign(Object.assign({}, newImportData), { filename: updatedSnippetFileKey }));
57
+ snippets.push({
58
+ ...newImportData,
59
+ filename: updatedSnippetFileKey,
60
+ });
64
61
  }
65
62
  const graph = {};
66
63
  snippets.forEach((item) => {
@@ -75,12 +72,12 @@ export const generateDependentSnippets = (changedFilename, newImportData) => __a
75
72
  for (const currentSnippet of orderedSnippets) {
76
73
  let processedTree = currentSnippet.tree;
77
74
  if (currentSnippet.filename !== updatedSnippetFileKey && hasImports(currentSnippet)) {
78
- processedTree = yield resolveAllImports(currentSnippet);
75
+ processedTree = await resolveAllImports(currentSnippet);
79
76
  }
80
77
  const targetFilename = optionallyRemoveLeadingSlash(currentSnippet.filename);
81
78
  const targetPath = join(NEXT_PUBLIC_PATH, targetFilename);
82
- yield outputFile(targetPath, stringifyTree(processedTree), { flag: 'w' });
79
+ await outputFile(targetPath, stringifyTree(processedTree), { flag: 'w' });
83
80
  processedSnippets.push(targetFilename);
84
81
  }
85
82
  return processedSnippets;
86
- });
83
+ };
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { findAndRemoveImports, optionallyRemoveLeadingSlash, resolveAllImports, stringifyTree, } from '@mintlify/common';
11
2
  import { preparseMdxTree, getFileListSync } from '@mintlify/prebuild';
12
3
  import { promises as _promises } from 'fs';
@@ -15,22 +6,22 @@ import { join } from 'path';
15
6
  import { CMD_EXEC_PATH, NEXT_PROPS_PATH } from '../../constants.js';
16
7
  import { getProcessedSnippets } from './getSnippets.js';
17
8
  const { readFile } = _promises;
18
- export const generatePagesWithImports = (updatedSnippets) => __awaiter(void 0, void 0, void 0, function* () {
19
- const snippets = yield getProcessedSnippets();
9
+ export const generatePagesWithImports = async (updatedSnippets) => {
10
+ const snippets = await getProcessedSnippets();
20
11
  const pageFilenames = getFileListSync(CMD_EXEC_PATH).filter((file) => file.endsWith('.mdx') && !file.startsWith('_snippets/') && !file.startsWith('snippets/'));
21
- yield Promise.all(pageFilenames.map((pageFilename) => __awaiter(void 0, void 0, void 0, function* () {
12
+ await Promise.all(pageFilenames.map(async (pageFilename) => {
22
13
  const sourcePath = join(CMD_EXEC_PATH, pageFilename);
23
- const contentStr = (yield readFile(sourcePath)).toString();
14
+ const contentStr = (await readFile(sourcePath)).toString();
24
15
  try {
25
- const tree = yield preparseMdxTree(contentStr, CMD_EXEC_PATH, sourcePath);
26
- const importsResponse = yield findAndRemoveImports(tree);
16
+ const tree = await preparseMdxTree(contentStr, CMD_EXEC_PATH, sourcePath);
17
+ const importsResponse = await findAndRemoveImports(tree);
27
18
  if (Object.keys(importsResponse.importMap).some((importPath) => updatedSnippets.has(optionallyRemoveLeadingSlash(importPath)))) {
28
- const content = yield resolveAllImports({
19
+ const content = await resolveAllImports({
29
20
  snippets,
30
- fileWithImports: Object.assign(Object.assign({}, importsResponse), { filename: pageFilename }),
21
+ fileWithImports: { ...importsResponse, filename: pageFilename },
31
22
  });
32
23
  const targetPath = join(NEXT_PROPS_PATH, pageFilename);
33
- yield outputFile(targetPath, stringifyTree(content), {
24
+ await outputFile(targetPath, stringifyTree(content), {
34
25
  flag: 'w',
35
26
  });
36
27
  }
@@ -40,5 +31,5 @@ export const generatePagesWithImports = (updatedSnippets) => __awaiter(void 0, v
40
31
  console.log(pageFilename);
41
32
  console.log(err);
42
33
  }
43
- })));
44
- });
34
+ }));
35
+ };
@@ -1,24 +1,15 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { generateOpenApiAnchorsOrTabs, categorizeFilePaths, generateOpenApiDivisions, MintConfigUpdater, DocsConfigUpdater, } from '@mintlify/prebuild';
11
2
  import { upgradeToDocsConfig } from '@mintlify/validation';
12
3
  import fse from 'fs-extra';
13
4
  import { join } from 'path';
14
5
  import { CMD_EXEC_PATH, CLIENT_PATH } from '../../constants.js';
15
- export const getDocsState = () => __awaiter(void 0, void 0, void 0, function* () {
16
- const { openApiFiles } = yield categorizeFilePaths(CMD_EXEC_PATH);
6
+ export const getDocsState = async () => {
7
+ const { openApiFiles } = await categorizeFilePaths(CMD_EXEC_PATH);
17
8
  try {
18
- const mintConfig = yield MintConfigUpdater.getConfig(join(CMD_EXEC_PATH, 'mint.json'));
9
+ const mintConfig = await MintConfigUpdater.getConfig(join(CMD_EXEC_PATH, 'mint.json'));
19
10
  const docsConfig = upgradeToDocsConfig(mintConfig);
20
- const { mintConfig: newMintConfig } = yield generateOpenApiAnchorsOrTabs(mintConfig, openApiFiles, CLIENT_PATH);
21
- const { newDocsConfig, pagesAcc, openApiFiles: newOpenApiFiles, } = yield generateOpenApiDivisions(docsConfig, openApiFiles, CLIENT_PATH);
11
+ const { mintConfig: newMintConfig } = await generateOpenApiAnchorsOrTabs(mintConfig, openApiFiles, CLIENT_PATH);
12
+ const { newDocsConfig, pagesAcc, openApiFiles: newOpenApiFiles, } = await generateOpenApiDivisions(docsConfig, openApiFiles, CLIENT_PATH);
22
13
  return {
23
14
  mintConfig: newMintConfig,
24
15
  pagesAcc,
@@ -26,12 +17,12 @@ export const getDocsState = () => __awaiter(void 0, void 0, void 0, function* ()
26
17
  docsConfig: newDocsConfig,
27
18
  };
28
19
  }
29
- catch (_a) {
20
+ catch {
30
21
  const docsJsonPath = join(CMD_EXEC_PATH, 'docs.json');
31
- if (!(yield fse.pathExists(docsJsonPath)))
22
+ if (!(await fse.pathExists(docsJsonPath)))
32
23
  throw new Error('No config found');
33
- const docsConfig = yield DocsConfigUpdater.getConfig(docsJsonPath);
34
- const { newDocsConfig, pagesAcc, openApiFiles: newOpenApiFiles, } = yield generateOpenApiDivisions(docsConfig, openApiFiles, CLIENT_PATH);
24
+ const docsConfig = await DocsConfigUpdater.getConfig(docsJsonPath);
25
+ const { newDocsConfig, pagesAcc, openApiFiles: newOpenApiFiles, } = await generateOpenApiDivisions(docsConfig, openApiFiles, CLIENT_PATH);
35
26
  return { pagesAcc, openApiFiles: newOpenApiFiles, docsConfig: newDocsConfig };
36
27
  }
37
- });
28
+ };
@@ -1,23 +1,14 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { optionallyAddLeadingSlash } from '@mintlify/common';
11
2
  import { getFileListSync, preparseMdxTree } from '@mintlify/prebuild';
12
3
  import { promises as _promises } from 'fs';
13
4
  import { join } from 'path';
14
5
  import { CMD_EXEC_PATH, NEXT_PUBLIC_PATH } from '../../constants.js';
15
6
  const { readFile } = _promises;
16
- const getSnippetBase = (BASE_DIR) => __awaiter(void 0, void 0, void 0, function* () {
7
+ const getSnippetBase = async (BASE_DIR) => {
17
8
  const snippetFilenames = getFileListSync(BASE_DIR).filter((file) => file.endsWith('.mdx') && file.startsWith('snippets/'));
18
- const promises = snippetFilenames.map((snippetFilename) => __awaiter(void 0, void 0, void 0, function* () {
9
+ const promises = snippetFilenames.map(async (snippetFilename) => {
19
10
  try {
20
- const tree = yield preparseMdxTree((yield readFile(join(BASE_DIR, snippetFilename))).toString(), BASE_DIR, join(BASE_DIR, snippetFilename));
11
+ const tree = await preparseMdxTree((await readFile(join(BASE_DIR, snippetFilename))).toString(), BASE_DIR, join(BASE_DIR, snippetFilename));
21
12
  return {
22
13
  filename: optionallyAddLeadingSlash(snippetFilename),
23
14
  tree,
@@ -27,8 +18,8 @@ const getSnippetBase = (BASE_DIR) => __awaiter(void 0, void 0, void 0, function*
27
18
  console.warn(`Error reading snippet file ${snippetFilename}`);
28
19
  return;
29
20
  }
30
- }));
31
- return (yield Promise.all(promises)).filter(Boolean);
32
- });
21
+ });
22
+ return (await Promise.all(promises)).filter(Boolean);
23
+ };
33
24
  export const getProcessedSnippets = () => getSnippetBase(NEXT_PUBLIC_PATH);
34
25
  export const getOriginalSnippets = () => getSnippetBase(CMD_EXEC_PATH);
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { findAndRemoveImports, hasImports, getFileCategory, openApiCheck, stringifyTree, } from '@mintlify/common';
11
2
  import { createPage, MintConfigUpdater, DocsConfigUpdater, preparseMdxTree, } from '@mintlify/prebuild';
12
3
  import Chalk from 'chalk';
@@ -35,9 +26,9 @@ const listener = (callback) => {
35
26
  .on('change', (filename) => onChangeEvent(filename, callback))
36
27
  .on('unlink', onUnlinkEvent);
37
28
  };
38
- const onAddEvent = (filename, callback) => __awaiter(void 0, void 0, void 0, function* () {
29
+ const onAddEvent = async (filename, callback) => {
39
30
  try {
40
- const category = yield onUpdateEvent(filename, callback);
31
+ const category = await onUpdateEvent(filename, callback);
41
32
  switch (category) {
42
33
  case 'page':
43
34
  console.log('New page detected: ', filename);
@@ -67,10 +58,10 @@ const onAddEvent = (filename, callback) => __awaiter(void 0, void 0, void 0, fun
67
58
  catch (error) {
68
59
  console.error(error.message);
69
60
  }
70
- });
71
- const onChangeEvent = (filename, callback) => __awaiter(void 0, void 0, void 0, function* () {
61
+ };
62
+ const onChangeEvent = async (filename, callback) => {
72
63
  try {
73
- const category = yield onUpdateEvent(filename, callback);
64
+ const category = await onUpdateEvent(filename, callback);
74
65
  switch (category) {
75
66
  case 'page':
76
67
  console.log('Page edited: ', filename);
@@ -100,8 +91,8 @@ const onChangeEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
100
91
  catch (error) {
101
92
  console.error(error.message);
102
93
  }
103
- });
104
- const onUnlinkEvent = (filename) => __awaiter(void 0, void 0, void 0, function* () {
94
+ };
95
+ const onUnlinkEvent = async (filename) => {
105
96
  try {
106
97
  const potentialCategory = getFileCategory(filename);
107
98
  const targetPath = getTargetPath(potentialCategory, filename);
@@ -113,7 +104,7 @@ const onUnlinkEvent = (filename) => __awaiter(void 0, void 0, void 0, function*
113
104
  potentialCategory === 'snippet-v2' ||
114
105
  potentialCategory === 'css' ||
115
106
  potentialCategory === 'js') {
116
- yield fse.remove(targetPath);
107
+ await fse.remove(targetPath);
117
108
  }
118
109
  switch (potentialCategory) {
119
110
  case 'page':
@@ -125,16 +116,16 @@ const onUnlinkEvent = (filename) => __awaiter(void 0, void 0, void 0, function*
125
116
  break;
126
117
  case 'mintConfig':
127
118
  console.error('⚠️ mint.json has been deleted.');
128
- yield validateConfigFiles();
119
+ await validateConfigFiles();
129
120
  break;
130
121
  case 'docsConfig':
131
122
  console.error('⚠️ docs.json has been deleted.');
132
- yield validateConfigFiles();
123
+ await validateConfigFiles();
133
124
  break;
134
125
  case 'potentialJsonOpenApiSpec':
135
126
  case 'potentialYamlOpenApiSpec':
136
- yield updateOpenApiFiles();
137
- yield updateGeneratedNav();
127
+ await updateOpenApiFiles();
128
+ await updateGeneratedNav();
138
129
  break;
139
130
  case 'css':
140
131
  console.log(`CSS file deleted: ${filename}`);
@@ -150,7 +141,7 @@ const onUnlinkEvent = (filename) => __awaiter(void 0, void 0, void 0, function*
150
141
  catch (error) {
151
142
  console.error(error.message);
152
143
  }
153
- });
144
+ };
154
145
  const getTargetPath = (potentialCategory, filePath) => {
155
146
  switch (potentialCategory) {
156
147
  case 'page':
@@ -172,12 +163,12 @@ const getTargetPath = (potentialCategory, filePath) => {
172
163
  throw new Error('Invalid category');
173
164
  }
174
165
  };
175
- const validateConfigFiles = () => __awaiter(void 0, void 0, void 0, function* () {
166
+ const validateConfigFiles = async () => {
176
167
  try {
177
168
  const mintConfigPath = pathUtil.join(CMD_EXEC_PATH, 'mint.json');
178
169
  const docsConfigPath = pathUtil.join(CMD_EXEC_PATH, 'docs.json');
179
- const mintConfigExists = yield fse.pathExists(mintConfigPath);
180
- const docsConfigExists = yield fse.pathExists(docsConfigPath);
170
+ const mintConfigExists = await fse.pathExists(mintConfigPath);
171
+ const docsConfigExists = await fse.pathExists(docsConfigPath);
181
172
  if (!mintConfigExists && !docsConfigExists) {
182
173
  console.error('⚠️ Error: Neither mint.json nor docs.json found in the directory');
183
174
  process.exit(1);
@@ -186,13 +177,13 @@ const validateConfigFiles = () => __awaiter(void 0, void 0, void 0, function* ()
186
177
  catch (error) {
187
178
  console.error('⚠️ Error validating configuration files:', error);
188
179
  }
189
- });
180
+ };
190
181
  /**
191
182
  * This function is called when a file is added or changed
192
183
  * @param filename
193
184
  * @returns FileCategory
194
185
  */
195
- const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0, function* () {
186
+ const onUpdateEvent = async (filename, callback) => {
196
187
  const filePath = pathUtil.join(CMD_EXEC_PATH, filename);
197
188
  const potentialCategory = getFileCategory(filename);
198
189
  const targetPath = getTargetPath(potentialCategory, filename);
@@ -204,46 +195,46 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
204
195
  switch (potentialCategory) {
205
196
  case 'page': {
206
197
  regenerateNav = true;
207
- let contentStr = (yield readFile(filePath)).toString();
208
- const tree = yield preparseMdxTree(contentStr, CMD_EXEC_PATH, filePath);
209
- const importsResponse = yield findAndRemoveImports(tree);
198
+ let contentStr = (await readFile(filePath)).toString();
199
+ const tree = await preparseMdxTree(contentStr, CMD_EXEC_PATH, filePath);
200
+ const importsResponse = await findAndRemoveImports(tree);
210
201
  if (hasImports(importsResponse)) {
211
- contentStr = stringifyTree(yield resolveAllImports(Object.assign(Object.assign({}, importsResponse), { filename })));
202
+ contentStr = stringifyTree(await resolveAllImports({ ...importsResponse, filename }));
212
203
  }
213
- const { pageContent } = yield createPage(filename, contentStr, CMD_EXEC_PATH, [], []);
214
- yield fse.outputFile(targetPath, pageContent, {
204
+ const { pageContent } = await createPage(filename, contentStr, CMD_EXEC_PATH, [], []);
205
+ await fse.outputFile(targetPath, pageContent, {
215
206
  flag: 'w',
216
207
  });
217
208
  break;
218
209
  }
219
210
  case 'snippet': {
220
- yield fse.copy(filePath, targetPath);
211
+ await fse.copy(filePath, targetPath);
221
212
  break;
222
213
  }
223
214
  case 'snippet-v2': {
224
- let contentStr = (yield readFile(filePath)).toString();
225
- const tree = yield preparseMdxTree(contentStr, CMD_EXEC_PATH, filePath);
226
- const importsResponse = yield findAndRemoveImports(tree);
215
+ let contentStr = (await readFile(filePath)).toString();
216
+ const tree = await preparseMdxTree(contentStr, CMD_EXEC_PATH, filePath);
217
+ const importsResponse = await findAndRemoveImports(tree);
227
218
  if (hasImports(importsResponse)) {
228
- contentStr = stringifyTree(yield resolveAllImports(Object.assign(Object.assign({}, importsResponse), { filename })));
219
+ contentStr = stringifyTree(await resolveAllImports({ ...importsResponse, filename }));
229
220
  }
230
- yield fse.outputFile(targetPath, contentStr, {
221
+ await fse.outputFile(targetPath, contentStr, {
231
222
  flag: 'w',
232
223
  });
233
- const updatedSnippets = yield generateDependentSnippets(filename, importsResponse);
234
- yield generatePagesWithImports(new Set(updatedSnippets));
224
+ const updatedSnippets = await generateDependentSnippets(filename, importsResponse);
225
+ await generatePagesWithImports(new Set(updatedSnippets));
235
226
  break;
236
227
  }
237
228
  case 'mintConfig':
238
229
  case 'docsConfig': {
239
230
  regenerateNav = true;
240
231
  try {
241
- const { mintConfig, openApiFiles, docsConfig } = yield getDocsState();
232
+ const { mintConfig, openApiFiles, docsConfig } = await getDocsState();
242
233
  if (mintConfig) {
243
- yield MintConfigUpdater.writeConfigFile(mintConfig, CLIENT_PATH);
234
+ await MintConfigUpdater.writeConfigFile(mintConfig, CLIENT_PATH);
244
235
  }
245
- yield DocsConfigUpdater.writeConfigFile(docsConfig, CLIENT_PATH);
246
- yield updateOpenApiFiles(openApiFiles);
236
+ await DocsConfigUpdater.writeConfigFile(docsConfig, CLIENT_PATH);
237
+ await updateOpenApiFiles(openApiFiles);
247
238
  }
248
239
  catch (err) {
249
240
  console.error(err);
@@ -254,19 +245,19 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
254
245
  case 'potentialJsonOpenApiSpec': {
255
246
  let doc;
256
247
  try {
257
- const file = yield fs.readFile(filePath, 'utf-8');
258
- doc = yield openApiCheck(yaml.load(file));
248
+ const file = await fs.readFile(filePath, 'utf-8');
249
+ doc = await openApiCheck(yaml.load(file));
259
250
  }
260
- catch (_a) {
251
+ catch {
261
252
  doc = undefined;
262
253
  }
263
254
  if (doc) {
264
- yield upsertOpenApiFile({
255
+ await upsertOpenApiFile({
265
256
  filename: pathUtil.parse(filename).name,
266
257
  originalFileLocation: '/' + filename,
267
258
  spec: doc,
268
259
  });
269
- yield updateOpenApiFiles();
260
+ await updateOpenApiFiles();
270
261
  regenerateNav = true;
271
262
  category = 'openApi';
272
263
  }
@@ -275,8 +266,8 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
275
266
  case 'css':
276
267
  case 'js':
277
268
  case 'staticFile': {
278
- if (yield isFileSizeValid(filePath, 5)) {
279
- yield fse.copy(filePath, targetPath);
269
+ if (await isFileSizeValid(filePath, 5)) {
270
+ await fse.copy(filePath, targetPath);
280
271
  }
281
272
  else {
282
273
  console.error(Chalk.red(`🚨 The file at ${filename} is too big. The maximum file size is 5 mb.`));
@@ -286,9 +277,9 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
286
277
  }
287
278
  if (regenerateNav) {
288
279
  // TODO: Instead of re-generating the entire nav, optimize by just updating the specific page that changed.
289
- yield updateGeneratedNav();
280
+ await updateGeneratedNav();
290
281
  }
291
282
  callback();
292
283
  return category;
293
- });
284
+ };
294
285
  export default listener;
@@ -1,18 +1,9 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { resolveAllImports as baseResolveAllImports } from '@mintlify/common';
11
2
  import { getProcessedSnippets } from './getSnippets.js';
12
- export const resolveAllImports = (fileWithImports) => __awaiter(void 0, void 0, void 0, function* () {
13
- const snippets = yield getProcessedSnippets();
14
- return yield baseResolveAllImports({
3
+ export const resolveAllImports = async (fileWithImports) => {
4
+ const snippets = await getProcessedSnippets();
5
+ return await baseResolveAllImports({
15
6
  snippets,
16
7
  fileWithImports,
17
8
  });
18
- });
9
+ };
@@ -1,43 +1,34 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import fse from 'fs-extra';
11
2
  import { join } from 'path';
12
3
  import { NEXT_PROPS_PATH } from '../../constants.js';
13
4
  import { generateNav } from './generate.js';
14
5
  import { getDocsState } from './getDocsState.js';
15
6
  import { readJsonFile } from './utils.js';
16
- export const updateGeneratedNav = () => __awaiter(void 0, void 0, void 0, function* () {
17
- const { pagesAcc, docsConfig } = yield getDocsState();
18
- const generatedDocsNav = yield generateNav(pagesAcc, docsConfig);
7
+ export const updateGeneratedNav = async () => {
8
+ const { pagesAcc, docsConfig } = await getDocsState();
9
+ const generatedDocsNav = await generateNav(pagesAcc, docsConfig);
19
10
  const targetDocsPath = join(NEXT_PROPS_PATH, 'generatedDocsNav.json');
20
- yield fse.outputFile(targetDocsPath, JSON.stringify(generatedDocsNav, null, 2), {
11
+ await fse.outputFile(targetDocsPath, JSON.stringify(generatedDocsNav, null, 2), {
21
12
  flag: 'w',
22
13
  });
23
- });
24
- export const updateOpenApiFiles = (providedOpenApiFiles) => __awaiter(void 0, void 0, void 0, function* () {
14
+ };
15
+ export const updateOpenApiFiles = async (providedOpenApiFiles) => {
25
16
  if (providedOpenApiFiles == undefined) {
26
- const { openApiFiles } = yield getDocsState();
17
+ const { openApiFiles } = await getDocsState();
27
18
  providedOpenApiFiles = openApiFiles;
28
19
  }
29
20
  const targetPath = join(NEXT_PROPS_PATH, 'openApiFiles.json');
30
- yield fse.outputFile(targetPath, JSON.stringify(providedOpenApiFiles, null, 2), {
21
+ await fse.outputFile(targetPath, JSON.stringify(providedOpenApiFiles, null, 2), {
31
22
  flag: 'w',
32
23
  });
33
- });
34
- export const upsertOpenApiFile = (openApiFile) => __awaiter(void 0, void 0, void 0, function* () {
24
+ };
25
+ export const upsertOpenApiFile = async (openApiFile) => {
35
26
  const sourcePath = join(NEXT_PROPS_PATH, 'openApiFiles.json');
36
27
  let existingOpenApiFiles = [];
37
28
  try {
38
- existingOpenApiFiles = (yield readJsonFile(sourcePath));
29
+ existingOpenApiFiles = (await readJsonFile(sourcePath));
39
30
  }
40
- catch (_a) { }
31
+ catch { }
41
32
  const existingIndex = existingOpenApiFiles.findIndex((file) => file.originalFileLocation === openApiFile.originalFileLocation);
42
33
  if (existingIndex >= 0) {
43
34
  existingOpenApiFiles[existingIndex] = openApiFile;
@@ -45,7 +36,7 @@ export const upsertOpenApiFile = (openApiFile) => __awaiter(void 0, void 0, void
45
36
  else {
46
37
  existingOpenApiFiles.push(openApiFile);
47
38
  }
48
- yield fse.outputFile(sourcePath, JSON.stringify(existingOpenApiFiles, null, 2), {
39
+ await fse.outputFile(sourcePath, JSON.stringify(existingOpenApiFiles, null, 2), {
49
40
  flag: 'w',
50
41
  });
51
- });
42
+ };
@@ -1,27 +1,18 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { promises as _promises } from 'fs';
11
2
  import fse from 'fs-extra';
12
3
  const { stat } = _promises;
13
4
  export const getFileExtension = (filename) => {
14
5
  return filename.substring(filename.lastIndexOf('.') + 1, filename.length) || filename;
15
6
  };
16
- export const isFileSizeValid = (path, maxFileSizeInMb) => __awaiter(void 0, void 0, void 0, function* () {
7
+ export const isFileSizeValid = async (path, maxFileSizeInMb) => {
17
8
  const maxFileSizeBytes = maxFileSizeInMb * 1000000;
18
- const stats = yield stat(path);
9
+ const stats = await stat(path);
19
10
  return stats.size <= maxFileSizeBytes;
20
- });
11
+ };
21
12
  export function isError(obj) {
22
13
  return Object.prototype.toString.call(obj) === '[object Error]';
23
14
  }
24
- export const readJsonFile = (path) => __awaiter(void 0, void 0, void 0, function* () {
25
- const file = yield fse.readFile(path, 'utf-8');
15
+ export const readJsonFile = async (path) => {
16
+ const file = await fse.readFile(path, 'utf-8');
26
17
  return JSON.parse(file);
27
- });
18
+ };