@mintlify/scraping 4.0.231 → 4.0.233

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.231",
3
+ "version": "4.0.233",
4
4
  "description": "Scrape documentation frameworks to Mintlify docs",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -38,7 +38,7 @@
38
38
  "format:check": "prettier . --check"
39
39
  },
40
40
  "dependencies": {
41
- "@mintlify/common": "1.0.375",
41
+ "@mintlify/common": "1.0.377",
42
42
  "@mintlify/openapi-parser": "^0.0.7",
43
43
  "fs-extra": "^11.1.1",
44
44
  "hast-util-to-mdast": "^10.1.0",
@@ -58,10 +58,10 @@
58
58
  },
59
59
  "devDependencies": {
60
60
  "@mintlify/eslint-config-typescript": "1.0.13",
61
- "@mintlify/models": "0.0.189",
61
+ "@mintlify/models": "0.0.190",
62
62
  "@mintlify/prettier-config": "1.0.4",
63
63
  "@mintlify/ts-config": "2.0.2",
64
- "@mintlify/validation": "0.1.362",
64
+ "@mintlify/validation": "0.1.364",
65
65
  "@trivago/prettier-plugin-sort-imports": "^4.2.1",
66
66
  "@tsconfig/recommended": "1.x",
67
67
  "@types/hast": "^3.0.4",
@@ -77,5 +77,5 @@
77
77
  "typescript": "^5.5.3",
78
78
  "vitest": "^2.0.4"
79
79
  },
80
- "gitHead": "ac5006c64de5ace7b7516691d1366462056e6ea3"
80
+ "gitHead": "0ccb32b16c5a402d2557209b60cfd218f93bc5c5"
81
81
  }
@@ -13,6 +13,7 @@ type GenerateAsyncApiPagesOptions = {
13
13
  outDir?: string;
14
14
  outDirBasePath?: string;
15
15
  overwrite?: boolean;
16
+ localSchema?: boolean;
16
17
  };
17
18
 
18
19
  type AsyncApiPageGenerationResult = {
@@ -30,8 +31,10 @@ export async function generateAsyncApiPagesForDocsConfig(
30
31
  let document: AsyncAPIDocumentInterface | undefined = undefined;
31
32
  let isUrl: boolean;
32
33
  if (typeof spec === 'string' || spec instanceof URL) {
33
- const { document: asyncApiDocument, isUrl: isUrlFromDefinition } =
34
- await getAsyncApiDefinition(spec);
34
+ const { document: asyncApiDocument, isUrl: isUrlFromDefinition } = await getAsyncApiDefinition(
35
+ spec,
36
+ opts?.localSchema
37
+ );
35
38
  if (asyncApiDocument) {
36
39
  document = asyncApiDocument;
37
40
  }
@@ -1,17 +1,24 @@
1
- import { AsyncAPIDocumentInterface, validateAsyncApi } from '@mintlify/common';
1
+ import {
2
+ AsyncAPIDocumentInterface,
3
+ validateAsyncApi,
4
+ isAllowedLocalSchemaUrl,
5
+ } from '@mintlify/common';
2
6
  import * as fs from 'fs/promises';
3
7
  import * as path from 'path';
4
8
 
5
9
  import { fetchAsyncApi } from '../utils/network.js';
6
10
 
7
11
  export const getAsyncApiDefinition = async (
8
- pathOrDocumentOrUrl: string | URL
12
+ pathOrDocumentOrUrl: string | URL,
13
+ localSchema?: boolean
9
14
  ): Promise<{ document: AsyncAPIDocumentInterface | undefined; isUrl: boolean }> => {
10
15
  let document: AsyncAPIDocumentInterface | undefined = undefined;
11
16
  if (typeof pathOrDocumentOrUrl === 'string') {
12
- if (pathOrDocumentOrUrl.startsWith('http://')) {
17
+ if (pathOrDocumentOrUrl.startsWith('http:') && !localSchema) {
13
18
  // This is an invalid location either for a file or a URL
14
- throw new Error('Only HTTPS URLs are supported. Please provide an HTTPS URL');
19
+ throw new Error(
20
+ 'Only HTTPS URLs are supported. HTTP URLs are only supported with the cli option --local-schema.'
21
+ );
15
22
  } else {
16
23
  try {
17
24
  const url = new URL(pathOrDocumentOrUrl);
@@ -35,8 +42,10 @@ export const getAsyncApiDefinition = async (
35
42
  }
36
43
  const isUrl = pathOrDocumentOrUrl instanceof URL;
37
44
  if (pathOrDocumentOrUrl instanceof URL) {
38
- if (pathOrDocumentOrUrl.protocol !== 'https:') {
39
- throw new Error('Only HTTPS URLs are supported. Please provide an HTTPS URL');
45
+ if (!isAllowedLocalSchemaUrl(pathOrDocumentOrUrl.toString(), localSchema)) {
46
+ throw new Error(
47
+ 'Only HTTPS URLs are supported. HTTP URLs are only supported with the cli option --local-schema.'
48
+ );
40
49
  }
41
50
  document = await fetchAsyncApi(pathOrDocumentOrUrl);
42
51
  }
@@ -49,9 +49,7 @@ export const processAsyncApiChannel = ({
49
49
  findNavGroup,
50
50
  }: ProcessAsyncApiChannelArgs) => {
51
51
  const asyncApiFilePathFromRoot = opts?.asyncApiFilePath
52
- ? opts.asyncApiFilePath.startsWith('https://')
53
- ? opts.asyncApiFilePath
54
- : optionallyAddLeadingSlash(opts.asyncApiFilePath)
52
+ ? optionallyAddLeadingSlash(opts.asyncApiFilePath)
55
53
  : undefined;
56
54
 
57
55
  const tags = channel.tags().all();
@@ -3,6 +3,7 @@ import {
3
3
  OperationObject,
4
4
  optionallyAddLeadingSlash,
5
5
  slugToTitle,
6
+ isAllowedLocalSchemaUrl,
6
7
  buildOpenApiMetaTag,
7
8
  } from '@mintlify/common';
8
9
  import type { DecoratedNavigationPage } from '@mintlify/models';
@@ -20,12 +21,15 @@ import {
20
21
  import { fetchOpenApi } from '../utils/network.js';
21
22
 
22
23
  export const getOpenApiDefinition = async (
23
- pathOrDocumentOrUrl: string | OpenAPI.Document | URL
24
+ pathOrDocumentOrUrl: string | OpenAPI.Document | URL,
25
+ localSchema?: boolean
24
26
  ): Promise<{ document: OpenAPI.Document; isUrl: boolean }> => {
25
27
  if (typeof pathOrDocumentOrUrl === 'string') {
26
- if (pathOrDocumentOrUrl.startsWith('http://')) {
28
+ if (pathOrDocumentOrUrl.startsWith('http:') && !localSchema) {
27
29
  // This is an invalid location either for a file or a URL
28
- throw new Error('Only HTTPS URLs are supported. Please provide an HTTPS URL');
30
+ throw new Error(
31
+ 'Only HTTPS URLs are supported. HTTP URLs are only supported with the cli option --local-schema.'
32
+ );
29
33
  } else {
30
34
  try {
31
35
  const url = new URL(pathOrDocumentOrUrl);
@@ -39,8 +43,10 @@ export const getOpenApiDefinition = async (
39
43
  }
40
44
  const isUrl = pathOrDocumentOrUrl instanceof URL;
41
45
  if (pathOrDocumentOrUrl instanceof URL) {
42
- if (pathOrDocumentOrUrl.protocol !== 'https:') {
43
- throw new Error('Only HTTPS URLs are supported. Please provide an HTTPS URL');
46
+ if (!isAllowedLocalSchemaUrl(pathOrDocumentOrUrl.toString(), localSchema)) {
47
+ throw new Error(
48
+ 'Only HTTPS URLs are supported. HTTP URLs are only supported with the cli option --local-schema.'
49
+ );
44
50
  }
45
51
  pathOrDocumentOrUrl = await fetchOpenApi(pathOrDocumentOrUrl);
46
52
  }
@@ -75,6 +81,7 @@ export type GenerateOpenApiPagesOptions = {
75
81
  outDir?: string;
76
82
  outDirBasePath?: string;
77
83
  overwrite?: boolean;
84
+ localSchema?: boolean;
78
85
  };
79
86
 
80
87
  export type OpenApiPageGenerationResult<N, DN> = {
@@ -21,7 +21,7 @@ export async function generateOpenApiPages(
21
21
  pathOrDocumentOrUrl: string | OpenAPI.Document | URL,
22
22
  opts?: GenerateOpenApiPagesOptions
23
23
  ): Promise<OpenApiPageGenerationResult<Navigation, DecoratedNavigation>> {
24
- const { document, isUrl } = await getOpenApiDefinition(pathOrDocumentOrUrl);
24
+ const { document, isUrl } = await getOpenApiDefinition(pathOrDocumentOrUrl, opts?.localSchema);
25
25
  const { schema } = await validate(document);
26
26
 
27
27
  if (
@@ -16,7 +16,7 @@ export async function generateOpenApiPagesForDocsConfig(
16
16
  pathOrDocumentOrUrl: string | OpenAPI.Document | URL,
17
17
  opts?: GenerateOpenApiPagesOptions
18
18
  ): Promise<OpenApiPageGenerationResult<GroupsConfig, DecoratedGroupsConfig>> {
19
- const { document, isUrl } = await getOpenApiDefinition(pathOrDocumentOrUrl);
19
+ const { document, isUrl } = await getOpenApiDefinition(pathOrDocumentOrUrl, opts?.localSchema);
20
20
  const { schema } = await validate(document);
21
21
 
22
22
  if (