@mintlify/scraping 4.0.687 → 4.0.689

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.687",
3
+ "version": "4.0.689",
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": "prettier . --check"
44
44
  },
45
45
  "dependencies": {
46
- "@mintlify/common": "1.0.824",
46
+ "@mintlify/common": "1.0.826",
47
47
  "@mintlify/openapi-parser": "^0.0.8",
48
48
  "fs-extra": "11.1.1",
49
49
  "hast-util-to-mdast": "10.1.0",
@@ -82,5 +82,5 @@
82
82
  "typescript": "5.5.3",
83
83
  "vitest": "2.1.9"
84
84
  },
85
- "gitHead": "dbb1d51caa0d27cb7ab44f8a5e237b0782bb96d4"
85
+ "gitHead": "43cfc30e331c3b552d21f17953dd83cecbbdf2f4"
86
86
  }
@@ -1,8 +1,8 @@
1
1
  import { AsyncAPIDocumentInterface, AsyncAPIChannel, validateAsyncApi } from '@mintlify/common';
2
+ import { findNavGroup } from '@mintlify/common';
2
3
  import { DecoratedNavigationPage } from '@mintlify/models';
3
4
  import { DecoratedGroupsConfig, GroupsConfig } from '@mintlify/validation';
4
5
 
5
- import { findNavGroup } from '../apiPages/common.js';
6
6
  import { getAsyncApiDefinition } from './getAsyncApiDefinition.js';
7
7
  import { processAsyncApiChannel } from './processAsyncApiChannel.js';
8
8
 
@@ -1,4 +1,10 @@
1
- import { optionallyAddLeadingSlash, camelToSentenceCase } from '@mintlify/common';
1
+ import {
2
+ optionallyAddLeadingSlash,
3
+ camelToSentenceCase,
4
+ prepareStringToBeValidFilename,
5
+ generateUniqueFilenameWithoutExtension,
6
+ DEFAULT_WEBSOCKETS_GROUP_NAME,
7
+ } from '@mintlify/common';
2
8
  import { AsyncAPIChannel } from '@mintlify/common';
3
9
  import { DecoratedNavigationPage, NavigationEntry } from '@mintlify/models';
4
10
  import {
@@ -11,12 +17,6 @@ import fse from 'fs-extra';
11
17
  import { outputFile } from 'fs-extra';
12
18
  import { join, resolve } from 'path';
13
19
 
14
- import {
15
- DEFAULT_WEBSOCKETS_GROUP_NAME,
16
- prepareStringToBeValidFilename,
17
- generateUniqueFilenameWithoutExtension,
18
- } from '../apiPages/common.js';
19
-
20
20
  type GenerateAsyncApiPagesOptions = {
21
21
  asyncApiFilePath?: string;
22
22
  version?: string;
@@ -7,6 +7,8 @@ import {
7
7
  isAllowedLocalSchemaUrl,
8
8
  buildOpenApiMetaTag,
9
9
  registerXMintContent,
10
+ prepareStringToBeValidFilename,
11
+ generateUniqueFilenameWithoutExtension,
10
12
  } from '@mintlify/common';
11
13
  import type { DecoratedNavigationPage, PageMetaTags } from '@mintlify/models';
12
14
  import { XMint } from '@mintlify/validation';
@@ -17,10 +19,6 @@ import yaml from 'js-yaml';
17
19
  import { OpenAPI, OpenAPIV3 } from 'openapi-types';
18
20
  import path, { join, parse, posix } from 'path';
19
21
 
20
- import {
21
- prepareStringToBeValidFilename,
22
- generateUniqueFilenameWithoutExtension,
23
- } from '../apiPages/common.js';
24
22
  import { fetchOpenApi } from '../utils/network.js';
25
23
 
26
24
  export type OpenApiExtensions = {
@@ -1,4 +1,4 @@
1
- import { validate } from '@mintlify/common';
1
+ import { validate, DEFAULT_API_GROUP_NAME } from '@mintlify/common';
2
2
  import type {
3
3
  DecoratedNavigation,
4
4
  DecoratedNavigationGroup,
@@ -8,7 +8,6 @@ import type {
8
8
  } from '@mintlify/models';
9
9
  import { OpenAPI } from 'openapi-types';
10
10
 
11
- import { DEFAULT_API_GROUP_NAME } from '../apiPages/common.js';
12
11
  import {
13
12
  getOpenApiDefinition,
14
13
  GenerateOpenApiPagesOptions,
@@ -1,9 +1,8 @@
1
- import { validate } from '@mintlify/common';
1
+ import { validate, findNavGroup } from '@mintlify/common';
2
2
  import { DecoratedNavigationPage } from '@mintlify/models';
3
3
  import { DecoratedGroupsConfig, GroupsConfig } from '@mintlify/validation';
4
4
  import { OpenAPI } from 'openapi-types';
5
5
 
6
- import { findNavGroup } from '../apiPages/common.js';
7
6
  import {
8
7
  getOpenApiDefinition,
9
8
  GenerateOpenApiPagesOptions,
package/tsconfig.json CHANGED
@@ -7,6 +7,6 @@
7
7
  "declaration": true,
8
8
  "types": ["vitest/globals"]
9
9
  },
10
- "include": ["**/*.ts"],
10
+ "include": ["**/*.ts", "../common/__test__/openapi/prepareStringToBeValidFilename.test.ts"],
11
11
  "exclude": ["node_modules", "bin"]
12
12
  }
@@ -1,67 +0,0 @@
1
- import { prepareStringToBeValidFilename } from '../src/apiPages/common.js';
2
-
3
- describe('prepareStringToBeValidFilename', () => {
4
- it('should replace spaces with dashes', () => {
5
- expect(prepareStringToBeValidFilename('hello world')).toBe('hello-world');
6
- });
7
- it('should be all lowercase', () => {
8
- expect(prepareStringToBeValidFilename('Hello World')).toBe('hello-world');
9
- });
10
- it('Remove periods', () => {
11
- expect(prepareStringToBeValidFilename('Get-a-list-of-all-shelves-in-the-repo.')).toBe(
12
- 'get-a-list-of-all-shelves-in-the-repo'
13
- );
14
- });
15
- it('Remove path params', () => {
16
- expect(prepareStringToBeValidFilename('get-repos-{repo_id}-commits-bulk')).toBe(
17
- 'get-repos--commits-bulk'
18
- );
19
- });
20
- it('Remove trailing dash', () => {
21
- expect(prepareStringToBeValidFilename('get-repos-{repo_id}-commits-')).toBe(
22
- 'get-repos--commits'
23
- );
24
- });
25
- it('Remove leading dash', () => {
26
- expect(prepareStringToBeValidFilename('-get-repos-{repo_id}-commits-')).toBe(
27
- 'get-repos--commits'
28
- );
29
- });
30
- it('Remove parentheses', () => {
31
- expect(
32
- prepareStringToBeValidFilename(
33
- 'Compare-a-ref-(commitbranchworkspacetagtree)-to-this-workspace'
34
- )
35
- ).toBe('compare-a-ref-commitbranchworkspacetagtree-to-this-workspace');
36
- });
37
- it('Remove slashes', () => {
38
- expect(
39
- prepareStringToBeValidFilename(
40
- 'Compare-a-ref-commit/branch/workspace/tag/tree-to-this-workspace'
41
- )
42
- ).toBe('compare-a-ref-commitbranchworkspacetagtree-to-this-workspace');
43
- });
44
- it('Remove newline', () => {
45
- expect(
46
- prepareStringToBeValidFilename(
47
- 'Get-file-entry.-Either-one-of-workspace-branch-or-commit-ID-needs-to-be-specified.-This-api-supports-providing-download-url-for-large-files.\n'
48
- )
49
- ).toBe(
50
- 'get-file-entry-either-one-of-workspace-branch-or-commit-id-needs-to-be-specified-this-api-supports-providing-download-url-for-large-files'
51
- );
52
- });
53
- it('Remove comma', () => {
54
- expect(
55
- prepareStringToBeValidFilename(
56
- 'Get-file-entry.-Either-one-of-workspace,-branch-or-commit-ID-needs-to-be-specified.-This-api-supports-providing-download-url-for-large-files.'
57
- )
58
- ).toBe(
59
- 'get-file-entry-either-one-of-workspace-branch-or-commit-id-needs-to-be-specified-this-api-supports-providing-download-url-for-large-files'
60
- );
61
- });
62
- it('Remove apostrophe', () => {
63
- expect(prepareStringToBeValidFilename("List-user's-repositories")).toBe(
64
- 'list-users-repositories'
65
- );
66
- });
67
- });
@@ -1,8 +0,0 @@
1
- import { NavigationEntry } from '@mintlify/models';
2
- import { DecoratedGroupsConfig, DecoratedPagesConfig, GroupsConfig, PagesConfig } from '@mintlify/validation';
3
- export declare const DEFAULT_API_GROUP_NAME = "API Reference";
4
- export declare const DEFAULT_WEBSOCKETS_GROUP_NAME = "Websockets";
5
- export declare function findNavGroup(nav: GroupsConfig, groupName?: string): PagesConfig;
6
- export declare function findNavGroup(nav: DecoratedGroupsConfig, groupName?: string): DecoratedPagesConfig;
7
- export declare const prepareStringToBeValidFilename: (str?: string) => string | undefined;
8
- export declare const generateUniqueFilenameWithoutExtension: (pages: NavigationEntry[], base: string) => string;
@@ -1,41 +0,0 @@
1
- export const DEFAULT_API_GROUP_NAME = 'API Reference';
2
- export const DEFAULT_WEBSOCKETS_GROUP_NAME = 'Websockets';
3
- export function findNavGroup(nav, groupName = DEFAULT_API_GROUP_NAME) {
4
- const group = nav.find((fileOrGroup) => typeof fileOrGroup === 'object' && 'group' in fileOrGroup && fileOrGroup.group === groupName);
5
- if (group === undefined || !('pages' in group)) {
6
- const newGroup = {
7
- group: groupName,
8
- pages: [],
9
- };
10
- nav.push(newGroup);
11
- return newGroup.pages;
12
- }
13
- if (Array.isArray(group.pages)) {
14
- return group.pages;
15
- }
16
- return [];
17
- }
18
- export const prepareStringToBeValidFilename = (str) => str
19
- ? str
20
- .replaceAll(' ', '-')
21
- .replace(/\{.*?\}/g, '-') // remove path parameters
22
- .replace(/^-/, '')
23
- .replace(/-$/, '')
24
- .replace(/[{}(),.'\n\/]/g, '') // remove special characters
25
- .replaceAll(/--/g, '-') // replace double hyphens
26
- .toLowerCase()
27
- : undefined;
28
- // returns a filename that is unique within the given array of pages
29
- export const generateUniqueFilenameWithoutExtension = (pages, base) => {
30
- let filename = base;
31
- if (pages.includes(filename)) {
32
- let extension = 1;
33
- filename = `${base}-${extension}`;
34
- while (pages.includes(filename)) {
35
- extension += 1;
36
- filename = `${base}-${extension}`;
37
- }
38
- }
39
- return filename.toLowerCase();
40
- };
41
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/apiPages/common.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC;AACtD,MAAM,CAAC,MAAM,6BAA6B,GAAG,YAAY,CAAC;AAI1D,MAAM,UAAU,YAAY,CAC1B,GAAyC,EACzC,YAAoB,sBAAsB;IAE1C,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CACpB,CAAC,WAAW,EAAE,EAAE,CACd,OAAO,WAAW,KAAK,QAAQ,IAAI,OAAO,IAAI,WAAW,IAAI,WAAW,CAAC,KAAK,KAAK,SAAS,CAC/F,CAAC;IACF,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,CA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SAAS,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC;AAChC,CAAC,CAAC"}
@@ -1,64 +0,0 @@
1
- // Functions used for both OpenAPI and AsyncAPI page generation
2
- import { NavigationEntry } from '@mintlify/models';
3
- import {
4
- DecoratedGroupsConfig,
5
- DecoratedPagesConfig,
6
- GroupsConfig,
7
- PagesConfig,
8
- } from '@mintlify/validation';
9
-
10
- export const DEFAULT_API_GROUP_NAME = 'API Reference';
11
- export const DEFAULT_WEBSOCKETS_GROUP_NAME = 'Websockets';
12
-
13
- export function findNavGroup(nav: GroupsConfig, groupName?: string): PagesConfig;
14
- export function findNavGroup(nav: DecoratedGroupsConfig, groupName?: string): DecoratedPagesConfig;
15
- export function findNavGroup(
16
- nav: GroupsConfig | DecoratedGroupsConfig,
17
- groupName: string = DEFAULT_API_GROUP_NAME
18
- ): PagesConfig | DecoratedPagesConfig {
19
- const group = nav.find(
20
- (fileOrGroup) =>
21
- typeof fileOrGroup === 'object' && 'group' in fileOrGroup && fileOrGroup.group === groupName
22
- );
23
- if (group === undefined || !('pages' in group)) {
24
- const newGroup = {
25
- group: groupName,
26
- pages: [],
27
- };
28
- nav.push(newGroup);
29
- return newGroup.pages;
30
- }
31
- if (Array.isArray(group.pages)) {
32
- return group.pages;
33
- }
34
- return [];
35
- }
36
-
37
- export const prepareStringToBeValidFilename = (str?: string) =>
38
- str
39
- ? str
40
- .replaceAll(' ', '-')
41
- .replace(/\{.*?\}/g, '-') // remove path parameters
42
- .replace(/^-/, '')
43
- .replace(/-$/, '')
44
- .replace(/[{}(),.'\n\/]/g, '') // remove special characters
45
- .replaceAll(/--/g, '-') // replace double hyphens
46
- .toLowerCase()
47
- : undefined;
48
-
49
- // returns a filename that is unique within the given array of pages
50
- export const generateUniqueFilenameWithoutExtension = (
51
- pages: NavigationEntry[],
52
- base: string
53
- ): string => {
54
- let filename = base;
55
- if (pages.includes(filename)) {
56
- let extension = 1;
57
- filename = `${base}-${extension}`;
58
- while (pages.includes(filename)) {
59
- extension += 1;
60
- filename = `${base}-${extension}`;
61
- }
62
- }
63
- return filename.toLowerCase();
64
- };