apiforge-analyzer 1.3.8 → 1.3.10
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/README.md +474 -474
- package/dist/cjs/cli.js +38 -2
- package/dist/cjs/detect.js +10 -1
- package/dist/cjs/express-mount-hook.js +82 -0
- package/dist/cjs/express-preload.js +17 -0
- package/dist/cjs/frameworks/express.js +41 -22
- package/dist/cjs/uploader.js +11 -0
- package/dist/esm/cli.js +40 -4
- package/dist/esm/detect.js +10 -1
- package/dist/esm/express-mount-hook.js +77 -0
- package/dist/esm/express-preload.js +15 -0
- package/dist/esm/frameworks/express.js +41 -22
- package/dist/esm/uploader.js +11 -0
- package/dist/types/express-mount-hook.d.ts +19 -0
- package/dist/types/express-preload.d.ts +1 -0
- package/dist/types/uploader.d.ts +6 -0
- package/package.json +66 -66
package/dist/esm/uploader.js
CHANGED
|
@@ -2,6 +2,16 @@ import axios from 'axios';
|
|
|
2
2
|
import { writeFileSync, unlinkSync, existsSync } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import { enrichRoutes } from './export.js';
|
|
5
|
+
/** The backend's fields for a visibility choice — nothing when none was made. */
|
|
6
|
+
function visibilityFields(choice) {
|
|
7
|
+
if (choice === 'ORG_WIDE')
|
|
8
|
+
return { visibility: 'ORG_WIDE', isPrivate: false };
|
|
9
|
+
if (choice === 'TEAM')
|
|
10
|
+
return { visibility: 'TEAM', isPrivate: false };
|
|
11
|
+
if (choice === 'PRIVATE')
|
|
12
|
+
return { visibility: 'TEAM', isPrivate: true };
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
5
15
|
/** Status file written to the project root so the CLI can detect completion. */
|
|
6
16
|
const STATUS_FILE = '.apiforge-status.json';
|
|
7
17
|
export function writeStatusFile(status, data) {
|
|
@@ -36,6 +46,7 @@ export async function uploadRoutes(routes, options) {
|
|
|
36
46
|
framework: enrichedRoutes[0]?.framework || 'unknown',
|
|
37
47
|
architectureType: options.architectureType || 'monolithic',
|
|
38
48
|
services: options.services || [],
|
|
49
|
+
...visibilityFields(options.visibility ?? process.env.APIFORGE_VISIBILITY),
|
|
39
50
|
};
|
|
40
51
|
try {
|
|
41
52
|
const response = await axios.post(`${backendUrl}/api/cli/submit`, payload, {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records where every router / sub-app is mounted, at the moment it is mounted.
|
|
3
|
+
*
|
|
4
|
+
* The Express analyzer reads mount prefixes back off the router stack after the fact, which loses them:
|
|
5
|
+
* - Express 5 (router@2) keeps no path on a layer at all (only compiled matchers), so every mounted
|
|
6
|
+
* router's routes came out without their prefix, and same-looking ones collapsed as duplicates.
|
|
7
|
+
* - A sub-app (`app.use('/admin', express())`) is wrapped in a `mounted_app` function with no `stack`,
|
|
8
|
+
* so none of its routes were found.
|
|
9
|
+
* - Express 4's mount regexp for a parameterised prefix (`/users/:id/posts`) doesn't turn back into the path.
|
|
10
|
+
*
|
|
11
|
+
* Wrapping `use()` tags each layer it adds with the mount path as written, and a sub-app's layer with the
|
|
12
|
+
* sub-app itself; express.ts prefers those tags and falls back to the old regexp reading without them.
|
|
13
|
+
* Must run before the app registers its routes — the CLI preloads it (express-preload.ts).
|
|
14
|
+
*/
|
|
15
|
+
export declare const MOUNT_PATH = "__apiforgeMountPath";
|
|
16
|
+
export declare const SUB_APP = "__apiforgeSubApp";
|
|
17
|
+
/** An app's router stack: `_router` in Express 4, the `router` getter in Express 5 (which throws in 4). */
|
|
18
|
+
export declare function appStack(app: any): any[] | undefined;
|
|
19
|
+
export declare function installExpressMountHook(express: any): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/uploader.d.ts
CHANGED
|
@@ -11,7 +11,13 @@ export interface UploadOptions {
|
|
|
11
11
|
apiKey: string;
|
|
12
12
|
architectureType?: ArchitectureType;
|
|
13
13
|
services?: ServiceMeta[];
|
|
14
|
+
/**
|
|
15
|
+
* Who can see the new project (APIForge spec §6.1 levels, chosen at creation per §6.3). Defaults to the
|
|
16
|
+
* CLI's answer in APIFORGE_VISIBILITY; with neither, the backend's default ("Only me") applies.
|
|
17
|
+
*/
|
|
18
|
+
visibility?: ProjectVisibility;
|
|
14
19
|
}
|
|
20
|
+
export type ProjectVisibility = 'ORG_WIDE' | 'TEAM' | 'PRIVATE';
|
|
15
21
|
export interface UploadResult {
|
|
16
22
|
pendingImportId: string;
|
|
17
23
|
routeCount: number;
|
package/package.json
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "apiforge-analyzer",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "Universal API documentation generator for Express, Next.js, Vite, React Router, and Node.js",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/cjs/index.js",
|
|
7
|
-
"module": "./dist/esm/index.js",
|
|
8
|
-
"types": "./dist/types/index.d.ts",
|
|
9
|
-
"bin": {
|
|
10
|
-
"apiforge-analyzer": "./dist/esm/cli.js",
|
|
11
|
-
"apiforge": "./dist/esm/cli.js"
|
|
12
|
-
},
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"import": "./dist/esm/index.js",
|
|
16
|
-
"require": "./dist/cjs/index.js",
|
|
17
|
-
"types": "./dist/types/index.d.ts"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist",
|
|
22
|
-
"README.md"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "npm run build:esm && npm run build:cjs && npm run build:types",
|
|
26
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
27
|
-
"build:cjs": "tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'}))\"",
|
|
28
|
-
"build:types": "tsc -p tsconfig.types.json",
|
|
29
|
-
"prepublishOnly": "npm run build",
|
|
30
|
-
"test": "node ../test-apps/run-all.cjs"
|
|
31
|
-
},
|
|
32
|
-
"keywords": [
|
|
33
|
-
"api",
|
|
34
|
-
"documentation",
|
|
35
|
-
"openapi",
|
|
36
|
-
"swagger",
|
|
37
|
-
"express",
|
|
38
|
-
"nextjs",
|
|
39
|
-
"vite",
|
|
40
|
-
"react-router",
|
|
41
|
-
"nodejs",
|
|
42
|
-
"analyzer",
|
|
43
|
-
"cli"
|
|
44
|
-
],
|
|
45
|
-
"author": "APIForge",
|
|
46
|
-
"license": "MIT",
|
|
47
|
-
"peerDependencies": {
|
|
48
|
-
"express": "^4.0.0 || ^5.0.0"
|
|
49
|
-
},
|
|
50
|
-
"peerDependenciesMeta": {
|
|
51
|
-
"express": {
|
|
52
|
-
"optional": true
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"dependencies": {
|
|
56
|
-
"@clack/prompts": "^0.9.1",
|
|
57
|
-
"axios": "^1.6.0",
|
|
58
|
-
"ts-morph": "^28.0.0"
|
|
59
|
-
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"@types/express": "^4.17.21",
|
|
62
|
-
"@types/node": "^20.0.0",
|
|
63
|
-
"fastify": "^5.12.1",
|
|
64
|
-
"typescript": "^5.3.0",
|
|
65
|
-
"zod": "^4.5.4"
|
|
66
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "apiforge-analyzer",
|
|
3
|
+
"version": "1.3.10",
|
|
4
|
+
"description": "Universal API documentation generator for Express, Next.js, Vite, React Router, and Node.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/cjs/index.js",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"apiforge-analyzer": "./dist/esm/cli.js",
|
|
11
|
+
"apiforge": "./dist/esm/cli.js"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/esm/index.js",
|
|
16
|
+
"require": "./dist/cjs/index.js",
|
|
17
|
+
"types": "./dist/types/index.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "npm run build:esm && npm run build:cjs && npm run build:types",
|
|
26
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
27
|
+
"build:cjs": "tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'}))\"",
|
|
28
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
29
|
+
"prepublishOnly": "npm run build",
|
|
30
|
+
"test": "node ../test-apps/run-all.cjs"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"api",
|
|
34
|
+
"documentation",
|
|
35
|
+
"openapi",
|
|
36
|
+
"swagger",
|
|
37
|
+
"express",
|
|
38
|
+
"nextjs",
|
|
39
|
+
"vite",
|
|
40
|
+
"react-router",
|
|
41
|
+
"nodejs",
|
|
42
|
+
"analyzer",
|
|
43
|
+
"cli"
|
|
44
|
+
],
|
|
45
|
+
"author": "APIForge",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"express": "^4.0.0 || ^5.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"express": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@clack/prompts": "^0.9.1",
|
|
57
|
+
"axios": "^1.6.0",
|
|
58
|
+
"ts-morph": "^28.0.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/express": "^4.17.21",
|
|
62
|
+
"@types/node": "^20.0.0",
|
|
63
|
+
"fastify": "^5.12.1",
|
|
64
|
+
"typescript": "^5.3.0",
|
|
65
|
+
"zod": "^4.5.4"
|
|
66
|
+
}
|
|
67
67
|
}
|