@mintlify/prebuild 1.0.606 → 1.0.608

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,7 +1,7 @@
1
1
  import { getOpenApiDocumentFromUrl, optionallyAddLeadingSlash, isAllowedLocalSchemaUrl, potentiallyParseOpenApiString, } from '@mintlify/common';
2
2
  import { generateOpenApiPagesForDocsConfig } from '@mintlify/scraping';
3
3
  import { findNavGroup } from '@mintlify/scraping/bin/apiPages/common.js';
4
- import { processOpenApiPath } from '@mintlify/scraping/bin/openapi/common.js';
4
+ import { processOpenApiPath, processOpenApiWebhook, } from '@mintlify/scraping/bin/openapi/common.js';
5
5
  import { divisions, } from '@mintlify/validation';
6
6
  import * as path from 'path';
7
7
  const DEFAULT_OUTPUT_DIR = 'api-reference';
@@ -88,9 +88,12 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
88
88
  return undefined;
89
89
  }
90
90
  const skipBulkForNode = new Set();
91
+ const skipBulkForNodeId = new Set();
92
+ let numNodes = 0;
91
93
  async function processNav(nav, inheritedOpenApi, openApiOwner) {
94
+ const nodeId = numNodes++;
92
95
  const currentOpenApi = extractOpenApiFromNav(nav) ?? inheritedOpenApi;
93
- const currentOpenApiOwner = extractOpenApiFromNav(nav) ? nav : openApiOwner;
96
+ const currentOpenApiOwner = extractOpenApiFromNav(nav) ? nodeId : openApiOwner;
94
97
  let newNav = nav;
95
98
  if ('pages' in newNav) {
96
99
  newNav.pages = await Promise.all(newNav.pages.map(async (page) => {
@@ -122,25 +125,42 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
122
125
  throw new Error(`Openapi file ${openapiPath} referenced in docs.json does not exist`);
123
126
  }
124
127
  const schema = openApiFile.spec;
125
- const pathItemObject = (schema.paths ?? {})[endpoint];
126
- if (!pathItemObject || typeof pathItemObject !== 'object') {
127
- throw new Error(`Endpoint ${endpoint} not found in ${openapiPath}`);
128
- }
129
- const opObject = pathItemObject[method.toLowerCase()];
130
- if (!opObject) {
131
- throw new Error(`Method ${method.toUpperCase()} for endpoint ${endpoint} not found in ${openapiPath}`);
132
- }
128
+ const isWebhook = method.toLowerCase() === 'webhook';
133
129
  const tempNav = [];
134
130
  const tempDecoratedNav = [];
135
131
  const writePromises = [];
136
- processOpenApiPath(endpoint, { [method.toLowerCase()]: opObject }, schema, tempNav, tempDecoratedNav, writePromises, pagesAcc, {
137
- openApiFilePath: openApiFile.originalFileLocation,
138
- writeFiles,
139
- outDir: DEFAULT_OUTPUT_DIR,
140
- outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
141
- overwrite,
142
- localSchema,
143
- }, findNavGroup);
132
+ if (isWebhook) {
133
+ const webhookObject = schema.webhooks?.[endpoint];
134
+ if (!webhookObject || typeof webhookObject !== 'object') {
135
+ throw new Error(`Webhook ${endpoint} not found in ${openapiPath}`);
136
+ }
137
+ processOpenApiWebhook(endpoint, webhookObject, schema, tempNav, tempDecoratedNav, writePromises, pagesAcc, {
138
+ openApiFilePath: openApiFile.originalFileLocation,
139
+ writeFiles,
140
+ outDir: DEFAULT_OUTPUT_DIR,
141
+ outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
142
+ overwrite,
143
+ localSchema,
144
+ }, findNavGroup);
145
+ }
146
+ else {
147
+ const pathItemObject = (schema.paths ?? {})[endpoint];
148
+ if (!pathItemObject || typeof pathItemObject !== 'object') {
149
+ throw new Error(`Endpoint ${endpoint} not found in ${openapiPath}`);
150
+ }
151
+ const opObject = pathItemObject[method.toLowerCase()];
152
+ if (!opObject) {
153
+ throw new Error(`Method ${method.toUpperCase()} for endpoint ${endpoint} not found in ${openapiPath}`);
154
+ }
155
+ processOpenApiPath(endpoint, { [method.toLowerCase()]: opObject }, schema, tempNav, tempDecoratedNav, writePromises, pagesAcc, {
156
+ openApiFilePath: openApiFile.originalFileLocation,
157
+ writeFiles,
158
+ outDir: DEFAULT_OUTPUT_DIR,
159
+ outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
160
+ overwrite,
161
+ localSchema,
162
+ }, findNavGroup);
163
+ }
144
164
  await Promise.all(writePromises);
145
165
  let slug;
146
166
  const firstEntry = tempNav[0];
@@ -160,8 +180,9 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
160
180
  if (!slug) {
161
181
  throw new Error('Failed to generate OpenAPI endpoint page');
162
182
  }
163
- if (currentOpenApiOwner)
164
- skipBulkForNode.add(currentOpenApiOwner);
183
+ if (currentOpenApiOwner && !explicitOpenapiPath) {
184
+ skipBulkForNodeId.add(currentOpenApiOwner);
185
+ }
165
186
  return slug;
166
187
  }
167
188
  }
@@ -177,6 +198,9 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
177
198
  };
178
199
  }
179
200
  }
201
+ if (skipBulkForNodeId.has(nodeId)) {
202
+ skipBulkForNode.add(newNav);
203
+ }
180
204
  return newNav;
181
205
  }
182
206
  const navAfterExplicit = await processNav(navigation, undefined);