@mintlify/scraping 4.0.998 → 4.0.1000

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/scraping",
3
- "version": "4.0.998",
3
+ "version": "4.0.1000",
4
4
  "description": "Scrape documentation frameworks to Mintlify docs",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -43,7 +43,7 @@
43
43
  "format:check": "oxfmt --check"
44
44
  },
45
45
  "dependencies": {
46
- "@mintlify/common": "1.0.1130",
46
+ "@mintlify/common": "1.0.1132",
47
47
  "fast-xml-parser": "5.7.3",
48
48
  "fs-extra": "11.1.1",
49
49
  "graphql": "16.11.0",
@@ -63,9 +63,9 @@
63
63
  "zod": "3.24.0"
64
64
  },
65
65
  "devDependencies": {
66
- "@mintlify/models": "0.0.352",
66
+ "@mintlify/models": "0.0.353",
67
67
  "@mintlify/ts-config": "2.0.2",
68
- "@mintlify/validation": "0.1.847",
68
+ "@mintlify/validation": "0.1.849",
69
69
  "@tsconfig/recommended": "1.0.2",
70
70
  "@types/hast": "3.0.4",
71
71
  "@types/mdast": "4.0.4",
@@ -79,5 +79,5 @@
79
79
  "typescript": "5.5.3",
80
80
  "vitest": "2.1.9"
81
81
  },
82
- "gitHead": "5af8270e14b6c226994968ae107b2513882b9729"
82
+ "gitHead": "64f3cb09194b3f7a7259c9a08c4e47b7454bf9e9"
83
83
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ applyOverlays,
2
3
  getOpenApiTitleAndDescription,
3
4
  OperationObject,
4
5
  optionallyAddLeadingSlash,
@@ -10,6 +11,7 @@ import {
10
11
  prepareStringToBeValidFilename,
11
12
  generateUniqueFilenameWithoutExtension,
12
13
  getTagDisplayName,
14
+ type LoadedOverlay,
13
15
  } from '@mintlify/common';
14
16
  import type { DecoratedNavigationPage, PageMetaTags } from '@mintlify/models';
15
17
  import { XMint } from '@mintlify/validation';
@@ -30,8 +32,11 @@ export type OpenApiExtensions = {
30
32
 
31
33
  export const getOpenApiDefinition = async (
32
34
  pathOrDocumentOrUrl: string | OpenAPI.Document | URL,
33
- localSchema?: boolean
35
+ localSchema?: boolean,
36
+ overlays?: readonly LoadedOverlay[]
34
37
  ): Promise<{ document: OpenAPI.Document; isUrl: boolean }> => {
38
+ // Overlays only apply to documents loaded here; in-memory documents arrive overlaid.
39
+ let loadedFromSource = false;
35
40
  if (typeof pathOrDocumentOrUrl === 'string') {
36
41
  if (pathOrDocumentOrUrl.startsWith('http:') && !localSchema) {
37
42
  // This is an invalid location either for a file or a URL
@@ -46,6 +51,7 @@ export const getOpenApiDefinition = async (
46
51
  const pathname = path.join(process.cwd(), pathOrDocumentOrUrl.toString());
47
52
  const file = await fs.readFile(pathname, 'utf-8');
48
53
  pathOrDocumentOrUrl = yaml.load(file) as OpenAPI.Document;
54
+ loadedFromSource = true;
49
55
  }
50
56
  }
51
57
  }
@@ -57,6 +63,11 @@ export const getOpenApiDefinition = async (
57
63
  );
58
64
  }
59
65
  pathOrDocumentOrUrl = await fetchOpenApi(pathOrDocumentOrUrl);
66
+ loadedFromSource = true;
67
+ }
68
+
69
+ if (loadedFromSource && overlays && overlays.length > 0) {
70
+ pathOrDocumentOrUrl = applyOverlays(pathOrDocumentOrUrl, overlays) as OpenAPI.Document;
60
71
  }
61
72
 
62
73
  return { document: pathOrDocumentOrUrl, isUrl };
@@ -124,6 +135,7 @@ export type GenerateOpenApiPagesOptions = {
124
135
  overwrite?: boolean;
125
136
  localSchema?: boolean;
126
137
  writeFile?: (filename: string, content: string) => void | Promise<void>;
138
+ overlays?: readonly LoadedOverlay[];
127
139
  };
128
140
 
129
141
  export type OpenApiPageGenerationResult<N, DN> = {
@@ -20,7 +20,11 @@ export async function generateOpenApiPages(
20
20
  pathOrDocumentOrUrl: string | OpenAPI.Document | URL,
21
21
  opts?: GenerateOpenApiPagesOptions
22
22
  ): Promise<OpenApiPageGenerationResult<Navigation, DecoratedNavigation>> {
23
- const { document, isUrl } = await getOpenApiDefinition(pathOrDocumentOrUrl, opts?.localSchema);
23
+ const { document, isUrl } = await getOpenApiDefinition(
24
+ pathOrDocumentOrUrl,
25
+ opts?.localSchema,
26
+ opts?.overlays
27
+ );
24
28
  const { schema } = await validate(document);
25
29
 
26
30
  if (
@@ -15,7 +15,11 @@ export async function generateOpenApiPagesForDocsConfig(
15
15
  pathOrDocumentOrUrl: string | OpenAPI.Document | URL,
16
16
  opts?: GenerateOpenApiPagesOptions
17
17
  ): Promise<OpenApiPageGenerationResult<GroupsConfig, DecoratedGroupsConfig>> {
18
- const { document, isUrl } = await getOpenApiDefinition(pathOrDocumentOrUrl, opts?.localSchema);
18
+ const { document, isUrl } = await getOpenApiDefinition(
19
+ pathOrDocumentOrUrl,
20
+ opts?.localSchema,
21
+ opts?.overlays
22
+ );
19
23
  const { schema } = await validate(document);
20
24
 
21
25
  if (