flowdoc-gen 0.1.1 → 0.1.2
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/dist/bin.js +1 -1
- package/dist/index.d.ts +114 -2
- package/dist/index.js +12 -15
- package/dist/{init-3GG2S3V3.js → init-6XHCTCLE.js} +8 -15
- package/package.json +1 -1
- package/dist/bin.d.ts +0 -1
- package/dist/chunk-3GGK6LWE.js +0 -1166
- package/dist/chunk-P6Z6T3W4.js +0 -51
- package/dist/chunk-SAMPAR3A.js +0 -93
- package/dist/chunk-VG2YJHSH.js +0 -52
- package/dist/chunk-XXW6UJOX.js +0 -604
- package/dist/generate-E4V2RQYB.js +0 -6
- package/dist/generate-J6FGBLQ4.js +0 -7
- package/dist/generate-MNQL7RGI.js +0 -7
- package/dist/init-27XS6ADW.js +0 -53
- package/dist/init-HVJTHT4U.js +0 -6
- package/dist/serve-NNDUXHXZ.js +0 -94
- package/dist/serve-VKTQ5E5O.js +0 -7
- package/dist/serve-Y4E3DTAJ.js +0 -94
package/dist/bin.js
CHANGED
|
@@ -9,7 +9,7 @@ var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
9
9
|
var pkg = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
|
|
10
10
|
program.name("flowdoc").description("Auto-generate beautiful API documentation from your Express codebase").version(pkg.version);
|
|
11
11
|
program.command("init").description("Scaffold a flowdoc.config.ts in the current directory").action(async () => {
|
|
12
|
-
const { init } = await import("./init-
|
|
12
|
+
const { init } = await import("./init-6XHCTCLE.js");
|
|
13
13
|
init();
|
|
14
14
|
});
|
|
15
15
|
program.command("generate").description("Parse your routes and write docs to the output folder").option("-c, --config <path>", "Path to flowdoc config file").option("-o, --output <path>", "Override output directory").option("-q, --quiet", "Suppress output").action(async (opts) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,115 @@
|
|
|
1
|
-
import { FlowDocSpec } from '@flowdoc/core';
|
|
2
1
|
import { Request, Response, NextFunction } from 'express';
|
|
3
2
|
|
|
3
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
4
|
+
type ParameterLocation = "path" | "query" | "header" | "cookie";
|
|
5
|
+
type SchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
6
|
+
interface JsonSchema {
|
|
7
|
+
type?: SchemaType | SchemaType[];
|
|
8
|
+
format?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
example?: unknown;
|
|
11
|
+
enum?: unknown[];
|
|
12
|
+
properties?: Record<string, JsonSchema>;
|
|
13
|
+
items?: JsonSchema;
|
|
14
|
+
required?: string[];
|
|
15
|
+
additionalProperties?: boolean | JsonSchema;
|
|
16
|
+
anyOf?: JsonSchema[];
|
|
17
|
+
oneOf?: JsonSchema[];
|
|
18
|
+
allOf?: JsonSchema[];
|
|
19
|
+
nullable?: boolean;
|
|
20
|
+
minimum?: number;
|
|
21
|
+
maximum?: number;
|
|
22
|
+
minLength?: number;
|
|
23
|
+
maxLength?: number;
|
|
24
|
+
minItems?: number;
|
|
25
|
+
maxItems?: number;
|
|
26
|
+
pattern?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
default?: unknown;
|
|
29
|
+
}
|
|
30
|
+
interface RouteParameter {
|
|
31
|
+
name: string;
|
|
32
|
+
in: ParameterLocation;
|
|
33
|
+
required: boolean;
|
|
34
|
+
schema: JsonSchema;
|
|
35
|
+
description?: string;
|
|
36
|
+
example?: unknown;
|
|
37
|
+
}
|
|
38
|
+
interface RequestBody {
|
|
39
|
+
required: boolean;
|
|
40
|
+
description?: string;
|
|
41
|
+
content: {
|
|
42
|
+
"application/json"?: {
|
|
43
|
+
schema: JsonSchema;
|
|
44
|
+
};
|
|
45
|
+
"multipart/form-data"?: {
|
|
46
|
+
schema: JsonSchema;
|
|
47
|
+
};
|
|
48
|
+
"application/x-www-form-urlencoded"?: {
|
|
49
|
+
schema: JsonSchema;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
interface ResponseBody {
|
|
54
|
+
description: string;
|
|
55
|
+
content?: {
|
|
56
|
+
"application/json"?: {
|
|
57
|
+
schema: JsonSchema;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
interface RouteDoc {
|
|
62
|
+
method: HttpMethod;
|
|
63
|
+
path: string;
|
|
64
|
+
summary?: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
tags: string[];
|
|
67
|
+
parameters: RouteParameter[];
|
|
68
|
+
requestBody?: RequestBody;
|
|
69
|
+
responses: Record<string, ResponseBody>;
|
|
70
|
+
deprecated?: boolean;
|
|
71
|
+
security?: Array<Record<string, string[]>>;
|
|
72
|
+
middleware?: string[];
|
|
73
|
+
}
|
|
74
|
+
interface ApiGroup {
|
|
75
|
+
name: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
routes: RouteDoc[];
|
|
78
|
+
}
|
|
79
|
+
interface FlowDocSpec {
|
|
80
|
+
info: {
|
|
81
|
+
title: string;
|
|
82
|
+
version: string;
|
|
83
|
+
description?: string;
|
|
84
|
+
baseUrl: string;
|
|
85
|
+
};
|
|
86
|
+
auth?: {
|
|
87
|
+
type: "bearer" | "apiKey" | "basic" | "oauth2";
|
|
88
|
+
headerName?: string;
|
|
89
|
+
queryName?: string;
|
|
90
|
+
};
|
|
91
|
+
groups: ApiGroup[];
|
|
92
|
+
generatedAt: string;
|
|
93
|
+
sourceFramework: "express" | "nestjs";
|
|
94
|
+
}
|
|
95
|
+
interface FlowDocConfig {
|
|
96
|
+
name: string;
|
|
97
|
+
version?: string;
|
|
98
|
+
description?: string;
|
|
99
|
+
framework: "express" | "nestjs";
|
|
100
|
+
entry: string;
|
|
101
|
+
baseUrl?: string;
|
|
102
|
+
auth?: FlowDocSpec["auth"];
|
|
103
|
+
output?: string;
|
|
104
|
+
theme?: {
|
|
105
|
+
brand?: string;
|
|
106
|
+
logo?: string;
|
|
107
|
+
darkMode?: boolean;
|
|
108
|
+
};
|
|
109
|
+
groups?: Record<string, string[]>;
|
|
110
|
+
exclude?: string[];
|
|
111
|
+
}
|
|
112
|
+
|
|
4
113
|
interface GenerateOptions {
|
|
5
114
|
config?: string;
|
|
6
115
|
output?: string;
|
|
@@ -33,4 +142,7 @@ interface FlowDocMiddlewareOptions {
|
|
|
33
142
|
*/
|
|
34
143
|
declare const flowdoc: (opts?: FlowDocMiddlewareOptions) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
35
144
|
|
|
36
|
-
|
|
145
|
+
/** Type-safe config helper — use in flowdoc.config.ts */
|
|
146
|
+
declare const defineConfig: (config: FlowDocConfig) => FlowDocConfig;
|
|
147
|
+
|
|
148
|
+
export { type FlowDocConfig, type FlowDocMiddlewareOptions, type FlowDocSpec, type GenerateOptions, type JsonSchema, type RouteDoc, type ServeOptions, defineConfig, flowdoc, generate, init, serve };
|
package/dist/index.js
CHANGED
|
@@ -1244,31 +1244,24 @@ var serve = async (opts = {}) => {
|
|
|
1244
1244
|
import { writeFileSync as writeFileSync2, existsSync as existsSync5 } from "fs";
|
|
1245
1245
|
import { resolve as resolve5 } from "path";
|
|
1246
1246
|
import chalk3 from "chalk";
|
|
1247
|
-
var CONFIG_TEMPLATE = `import
|
|
1247
|
+
var CONFIG_TEMPLATE = `import { defineConfig } from "flowdoc-gen";
|
|
1248
1248
|
|
|
1249
|
-
|
|
1249
|
+
export default defineConfig({
|
|
1250
1250
|
name: "My API",
|
|
1251
1251
|
version: "1.0.0",
|
|
1252
1252
|
description: "API documentation generated by flowdoc",
|
|
1253
1253
|
framework: "express",
|
|
1254
|
-
entry: "./src",
|
|
1255
|
-
baseUrl: "http://localhost:3000",
|
|
1256
|
-
auth: {
|
|
1257
|
-
type: "bearer",
|
|
1258
|
-
},
|
|
1254
|
+
entry: "./src",
|
|
1259
1255
|
output: "./docs-output",
|
|
1260
1256
|
theme: {
|
|
1261
1257
|
brand: "#6366f1",
|
|
1262
1258
|
darkMode: true,
|
|
1263
1259
|
},
|
|
1264
|
-
//
|
|
1265
|
-
//
|
|
1266
|
-
// "
|
|
1267
|
-
//
|
|
1268
|
-
|
|
1269
|
-
};
|
|
1270
|
-
|
|
1271
|
-
export default config;
|
|
1260
|
+
// groups: [
|
|
1261
|
+
// { name: "Auth", match: "/auth/**" },
|
|
1262
|
+
// { name: "Users", match: "/users/**" },
|
|
1263
|
+
// ],
|
|
1264
|
+
});
|
|
1272
1265
|
`;
|
|
1273
1266
|
var init = (cwd = process.cwd()) => {
|
|
1274
1267
|
const configPath = resolve5(cwd, "flowdoc.config.ts");
|
|
@@ -1366,7 +1359,11 @@ var buildHtml = ({ baseUrl, brand }) => `<!DOCTYPE html>
|
|
|
1366
1359
|
</head>
|
|
1367
1360
|
<body><div id="root"></div></body>
|
|
1368
1361
|
</html>`;
|
|
1362
|
+
|
|
1363
|
+
// src/index.ts
|
|
1364
|
+
var defineConfig = (config) => config;
|
|
1369
1365
|
export {
|
|
1366
|
+
defineConfig,
|
|
1370
1367
|
flowdoc,
|
|
1371
1368
|
generate,
|
|
1372
1369
|
init,
|
|
@@ -2,31 +2,24 @@
|
|
|
2
2
|
import { writeFileSync, existsSync } from "fs";
|
|
3
3
|
import { resolve } from "path";
|
|
4
4
|
import chalk from "chalk";
|
|
5
|
-
var CONFIG_TEMPLATE = `import
|
|
5
|
+
var CONFIG_TEMPLATE = `import { defineConfig } from "flowdoc-gen";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export default defineConfig({
|
|
8
8
|
name: "My API",
|
|
9
9
|
version: "1.0.0",
|
|
10
10
|
description: "API documentation generated by flowdoc",
|
|
11
11
|
framework: "express",
|
|
12
|
-
entry: "./src",
|
|
13
|
-
baseUrl: "http://localhost:3000",
|
|
14
|
-
auth: {
|
|
15
|
-
type: "bearer",
|
|
16
|
-
},
|
|
12
|
+
entry: "./src",
|
|
17
13
|
output: "./docs-output",
|
|
18
14
|
theme: {
|
|
19
15
|
brand: "#6366f1",
|
|
20
16
|
darkMode: true,
|
|
21
17
|
},
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
// "
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default config;
|
|
18
|
+
// groups: [
|
|
19
|
+
// { name: "Auth", match: "/auth/**" },
|
|
20
|
+
// { name: "Users", match: "/users/**" },
|
|
21
|
+
// ],
|
|
22
|
+
});
|
|
30
23
|
`;
|
|
31
24
|
var init = (cwd = process.cwd()) => {
|
|
32
25
|
const configPath = resolve(cwd, "flowdoc.config.ts");
|
package/package.json
CHANGED
package/dist/bin.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|