@mintlify/common 1.0.1185 → 1.0.1186

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,5 +1,8 @@
1
1
  import type { OpenApiFile, DecoratedNavigationPage } from '@mintlify/models';
2
2
  import { AsyncAPIFile } from '../types/asyncapi.js';
3
+ export declare class InvalidEndpointFrontmatterError extends Error {
4
+ name: string;
5
+ }
3
6
  export declare const getDecoratedNavPageAndSlug: (pagePath: string, pageContent: string, openApiFiles: OpenApiFile[], asyncApiFiles: AsyncAPIFile[]) => {
4
7
  pageMetadata: DecoratedNavigationPage;
5
8
  slug: string;
@@ -5,6 +5,13 @@ import { removeLeadingSlash, optionallyAddLeadingSlash } from '../fs/index.js';
5
5
  import { getOpenApiTitleAndDescription } from '../openapi/getOpenApiTitleAndDescription.js';
6
6
  import { pagePathToSlug } from './pagePathToSlug.js';
7
7
  import { slugToTitle } from './slugToTitle.js';
8
+ const ENDPOINT_FRONTMATTER_FIELDS = ['api', 'openapi', 'asyncapi'];
9
+ export class InvalidEndpointFrontmatterError extends Error {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.name = 'InvalidEndpointFrontmatterError';
13
+ }
14
+ }
8
15
  export const getDecoratedNavPageAndSlug = (pagePath, pageContent, openApiFiles, asyncApiFiles) => {
9
16
  let metadata = {};
10
17
  try {
@@ -25,6 +32,12 @@ export const getDecoratedNavPageAndSlug = (pagePath, pageContent, openApiFiles,
25
32
  throw new Error(`Unable to parse page metadata in ${pagePath}`);
26
33
  }
27
34
  }
35
+ for (const field of ENDPOINT_FRONTMATTER_FIELDS) {
36
+ const value = metadata[field];
37
+ if (value != null && typeof value !== 'string') {
38
+ throw new InvalidEndpointFrontmatterError(`Invalid "${field}" frontmatter in ${pagePath}: expected a single endpoint string (e.g. "GET /users"), received ${Array.isArray(value) ? 'an array' : typeof value}`);
39
+ }
40
+ }
28
41
  const slug = pagePathToSlug(pagePath);
29
42
  const defaultTitle = slugToTitle(slug);
30
43
  let schemaTitle;