miqro 1.9.3 → 2.0.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/README.md +0 -1
- package/dist/cli.js +11 -6
- package/dist/cmds/doc-json.d.ts +1 -1
- package/dist/cmds/doc-json.js +4 -3
- package/dist/cmds/start.d.ts +1 -1
- package/dist/cmds/start.js +1 -1
- package/dist/utils/db/index.js +6 -6
- package/dist/utils/doc/index.d.ts +5 -16
- package/dist/utils/doc/index.js +9 -29
- package/dist/utils/index.d.ts +1 -1
- package/package.json +6 -6
- package/dist/cmds/doc-md.d.ts +0 -2
- package/dist/cmds/doc-md.js +0 -234
package/README.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ const test_1 = require("./cmds/test");
|
|
|
7
7
|
const watch_1 = require("./cmds/watch");
|
|
8
8
|
const new_1 = require("./cmds/new");
|
|
9
9
|
const doc_json_1 = require("./cmds/doc-json");
|
|
10
|
-
|
|
10
|
+
//import {main as apiDocMD} from "./cmds/doc-md.ts.disable";
|
|
11
11
|
const config_init_1 = require("./cmds/config-init");
|
|
12
12
|
const config_1 = require("./cmds/config");
|
|
13
13
|
const config_bash_1 = require("./cmds/config-bash");
|
|
@@ -58,11 +58,11 @@ const db_migrate_1 = require("./cmds/db-migrate");
|
|
|
58
58
|
cb: doc_json_1.main,
|
|
59
59
|
description: `api folder auto doc as a json.`
|
|
60
60
|
},
|
|
61
|
-
["doc:md"]: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
61
|
+
/*["doc:md"]: {
|
|
62
|
+
cb: apiDocMD,
|
|
63
|
+
tabs: 4,
|
|
64
|
+
description: `api folder auto doc as a markdown.`
|
|
65
|
+
},*/
|
|
66
66
|
/*["new:front"]: {
|
|
67
67
|
section: "front end development",
|
|
68
68
|
cb: newTSFront,
|
|
@@ -75,6 +75,11 @@ const db_migrate_1 = require("./cmds/db-migrate");
|
|
|
75
75
|
cb: start_1.main,
|
|
76
76
|
description: `start script in cluster mode.`
|
|
77
77
|
},
|
|
78
|
+
["cluster"]: {
|
|
79
|
+
tabs: 4,
|
|
80
|
+
cb: start_1.main,
|
|
81
|
+
description: `alias for start command.`
|
|
82
|
+
},
|
|
78
83
|
["watch"]: {
|
|
79
84
|
//section: "watch",
|
|
80
85
|
cb: watch_1.main,
|
package/dist/cmds/doc-json.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const usage = "usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath>";
|
|
1
|
+
export declare const usage = "usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath> [apiName]";
|
|
2
2
|
export declare const main: () => void;
|
package/dist/cmds/doc-json.js
CHANGED
|
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.main = exports.usage = void 0;
|
|
4
4
|
const core_1 = require("@miqro/core");
|
|
5
5
|
const doc_1 = require("../utils/doc");
|
|
6
|
-
exports.usage = `usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath
|
|
6
|
+
exports.usage = `usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath> [apiName]`;
|
|
7
7
|
const main = () => {
|
|
8
|
-
if (process.argv.length
|
|
8
|
+
if (process.argv.length < 5 || process.argv.length > 6) {
|
|
9
9
|
throw new Error(exports.usage);
|
|
10
10
|
}
|
|
11
11
|
const dirname = process.argv[3];
|
|
12
12
|
const subPath = process.argv[4];
|
|
13
|
+
const apiName = process.argv[5];
|
|
13
14
|
(0, core_1.loadConfig)();
|
|
14
|
-
console.log(JSON.stringify((0, doc_1.getDOCJSON)({ dirname, subPath }, (0, core_1.getLogger)("miqro")), undefined, 2));
|
|
15
|
+
console.log(JSON.stringify((0, doc_1.getDOCJSON)({ dirname, subPath, apiName }, (0, core_1.getLogger)("miqro")), undefined, 2));
|
|
15
16
|
};
|
|
16
17
|
exports.main = main;
|
package/dist/cmds/start.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const usage = "usage: [NODE_ENV=development] CLUSTER_COUNT=
|
|
1
|
+
export declare const usage = "usage: [NODE_ENV=development] CLUSTER_COUNT=os.cpus().length [DISABLE_RESTART=true|false] npx miqro start <script> [...args]";
|
|
2
2
|
export declare const main: () => void;
|
package/dist/cmds/start.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.main = exports.usage = void 0;
|
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const runner_1 = require("@miqro/runner");
|
|
6
6
|
const core_1 = require("@miqro/core");
|
|
7
|
-
exports.usage = "usage: [NODE_ENV=development] CLUSTER_COUNT=
|
|
7
|
+
exports.usage = "usage: [NODE_ENV=development] CLUSTER_COUNT=os.cpus().length [DISABLE_RESTART=true|false] npx miqro start <script> [...args]";
|
|
8
8
|
const main = () => {
|
|
9
9
|
if (process.argv.length <= 3) {
|
|
10
10
|
throw new Error(`invalid number of args\n${exports.usage}`);
|
package/dist/utils/db/index.js
CHANGED
|
@@ -21,12 +21,12 @@ const loadSequelizeRC = (sequelizercPath = core_1.ConfigPathResolver.getSequeliz
|
|
|
21
21
|
// noinspection SpellCheckingInspection
|
|
22
22
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
23
23
|
const sequelizerc = require(sequelizercPath);
|
|
24
|
-
return (0, parser_1.parse)(sequelizerc,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
return (0, parser_1.parse)(sequelizerc, {
|
|
25
|
+
config: "string",
|
|
26
|
+
"migrations-path": "string",
|
|
27
|
+
"seeders-path": "string",
|
|
28
|
+
"models-path": "string"
|
|
29
|
+
}, "no_extra", sequelizercPath);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
exports.loadSequelizeRC = loadSequelizeRC;
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const getDOCJSON: ({ dirname, subPath }: {
|
|
1
|
+
import { Logger } from "@miqro/core";
|
|
2
|
+
import { RouterJSONDoc } from "@miqro/core/dist/common/router-utils";
|
|
3
|
+
export declare const getDOCJSON: ({ dirname, subPath, apiName }: {
|
|
4
|
+
apiName?: string | undefined;
|
|
4
5
|
dirname: string;
|
|
5
6
|
subPath: string;
|
|
6
|
-
}, logger: Logger) =>
|
|
7
|
-
path?: string | string[];
|
|
8
|
-
method?: Method | Method[];
|
|
9
|
-
description?: string;
|
|
10
|
-
policy?: GroupPolicy;
|
|
11
|
-
headers?: ParseOptions | ParseOptions[];
|
|
12
|
-
session?: false | true | SessionHandlerOptions;
|
|
13
|
-
params?: boolean | ParseOptions | ParseOptions[] | string;
|
|
14
|
-
query?: boolean | ParseOptions | ParseOptions[] | string;
|
|
15
|
-
body?: boolean | ParseOptions | ParseOptions[] | string;
|
|
16
|
-
response?: ParseOptions | ParseOptions[] | string;
|
|
17
|
-
featureName: string;
|
|
18
|
-
}[];
|
|
7
|
+
}, logger: Logger) => RouterJSONDoc;
|
package/dist/utils/doc/index.js
CHANGED
|
@@ -2,35 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDOCJSON = void 0;
|
|
4
4
|
const core_1 = require("@miqro/core");
|
|
5
|
-
const api_router_utils_1 = require("@miqro/core/dist/common/api-router-utils");
|
|
6
5
|
const path_1 = require("path");
|
|
7
|
-
const getDOCJSON = ({ dirname, subPath }, logger) => {
|
|
8
|
-
const apiTraverse =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const { params, query, body, headers } = options && options.request ? options.request : {
|
|
17
|
-
params: undefined,
|
|
18
|
-
query: undefined,
|
|
19
|
-
body: undefined,
|
|
20
|
-
headers: undefined
|
|
21
|
-
};
|
|
22
|
-
const result = options && options.response !== true ? options.response : undefined;
|
|
23
|
-
return {
|
|
24
|
-
path,
|
|
25
|
-
method,
|
|
26
|
-
headers,
|
|
27
|
-
session: session ? typeof session === "function" ? true : session : false,
|
|
28
|
-
policy,
|
|
29
|
-
params,
|
|
30
|
-
description, query, body, result,
|
|
31
|
-
featureName
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
return docJSON;
|
|
6
|
+
const getDOCJSON = ({ dirname, subPath, apiName }, logger) => {
|
|
7
|
+
//const apiTraverse = traverseAPIRouteDir(basename(dirname).toUpperCase(), resolve(ConfigPathResolver.getBaseDirname(), dirname), subPath, undefined, logger);
|
|
8
|
+
console.log(apiName);
|
|
9
|
+
const router = (0, core_1.APIRouter)({
|
|
10
|
+
apiName,
|
|
11
|
+
dirname: (0, path_1.resolve)(core_1.ConfigPathResolver.getBaseDirname(), dirname),
|
|
12
|
+
path: subPath
|
|
13
|
+
}, logger);
|
|
14
|
+
return router.getJSONDoc();
|
|
35
15
|
};
|
|
36
16
|
exports.getDOCJSON = getDOCJSON;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ExecSyncOptionsWithBufferEncoding } from "child_process";
|
|
3
3
|
export declare const execSync: (cmd: string, options?: ExecSyncOptionsWithBufferEncoding) => void;
|
|
4
|
-
export
|
|
4
|
+
export type Callback<T = any> = (...args: any[]) => T;
|
|
5
5
|
export declare const extractFlags: (args: string[], options?: {
|
|
6
6
|
flags: {
|
|
7
7
|
[name: string]: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miqro",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"author": "claukers",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@miqro/core": "^
|
|
21
|
-
"@miqro/parser": "^0.1
|
|
22
|
-
"@miqro/runner": "^1.2.
|
|
23
|
-
"@miqro/test": "^0.2.
|
|
20
|
+
"@miqro/core": "^2.0.2",
|
|
21
|
+
"@miqro/parser": "^1.0.1",
|
|
22
|
+
"@miqro/runner": "^1.2.10",
|
|
23
|
+
"@miqro/test": "^0.2.9",
|
|
24
24
|
"deep-diff": "1.0.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/cookie": "0.4.1",
|
|
28
28
|
"@types/deep-diff": "1.0.1",
|
|
29
29
|
"@types/node": "17.0.23",
|
|
30
|
-
"typescript": "
|
|
30
|
+
"typescript": "5.0.4"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
33
|
"node": ">=14.0.0",
|
package/dist/cmds/doc-md.d.ts
DELETED
package/dist/cmds/doc-md.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = exports.usage = void 0;
|
|
4
|
-
const core_1 = require("@miqro/core");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const doc_1 = require("../utils/doc");
|
|
8
|
-
exports.usage = `usage: [NODE_ENV=development] npx miqro doc:md <api_folder> <subPath> <out.md>`;
|
|
9
|
-
const main = () => {
|
|
10
|
-
if (process.argv.length !== 6) {
|
|
11
|
-
throw new Error(exports.usage);
|
|
12
|
-
}
|
|
13
|
-
const dirname = process.argv[3];
|
|
14
|
-
const subPath = process.argv[4];
|
|
15
|
-
const outPath = process.argv[5];
|
|
16
|
-
(0, core_1.loadConfig)();
|
|
17
|
-
const parseOptionMap2ParseOptionList = (map) => {
|
|
18
|
-
return Object.keys(map).map(name => {
|
|
19
|
-
const val = map[name];
|
|
20
|
-
return typeof val !== "object" ? {
|
|
21
|
-
name,
|
|
22
|
-
required: true,
|
|
23
|
-
type: val
|
|
24
|
-
} : val.required === undefined ? {
|
|
25
|
-
...val,
|
|
26
|
-
required: true,
|
|
27
|
-
name
|
|
28
|
-
} : {
|
|
29
|
-
...val,
|
|
30
|
-
name
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
const docJSON = (0, doc_1.getDOCJSON)({ dirname, subPath }, (0, core_1.getLogger)("miqro"));
|
|
35
|
-
const policyTable = (policy) => {
|
|
36
|
-
if (policy) {
|
|
37
|
-
return `|policy|groups|\n|----|----|\n|${policy.groupPolicy}|${policy.groups.join(", ")}|`;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return "";
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const methodUrlTable = (options) => {
|
|
44
|
-
if (options && options.path) {
|
|
45
|
-
const rows = [];
|
|
46
|
-
const paths = options.path instanceof Array ? options.path : [options.path];
|
|
47
|
-
for (const p of paths) {
|
|
48
|
-
if (options.method instanceof Array) {
|
|
49
|
-
for (const m of options.method) {
|
|
50
|
-
rows.push(`|${m}|${p}|`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
rows.push(`|${options.method}|${p}|`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return `|method|path|\n|----|----|\n${rows.join("\n")}`;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
return "";
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const getRange = (o, t) => {
|
|
64
|
-
let range = " ";
|
|
65
|
-
switch (t) {
|
|
66
|
-
case "string":
|
|
67
|
-
if (o.stringMinLength !== undefined || o.stringMaxLength !== undefined) {
|
|
68
|
-
range = "";
|
|
69
|
-
}
|
|
70
|
-
if (o.stringMinLength !== undefined) {
|
|
71
|
-
range = `${o.stringMinLength}:`;
|
|
72
|
-
}
|
|
73
|
-
if (o.stringMaxLength !== undefined) {
|
|
74
|
-
range += `:${o.stringMaxLength}`;
|
|
75
|
-
}
|
|
76
|
-
break;
|
|
77
|
-
case "number":
|
|
78
|
-
if (o.numberMin !== undefined || o.numberMax !== undefined) {
|
|
79
|
-
range = "";
|
|
80
|
-
}
|
|
81
|
-
if (o.numberMin !== undefined) {
|
|
82
|
-
range = `${o.numberMin}:`;
|
|
83
|
-
}
|
|
84
|
-
if (o.numberMax !== undefined) {
|
|
85
|
-
range += `:${o.numberMax}`;
|
|
86
|
-
}
|
|
87
|
-
if (o.numberMinDecimals !== undefined) {
|
|
88
|
-
range = `${range ? " " : ""}decimal ${o.numberMinDecimals}:`;
|
|
89
|
-
}
|
|
90
|
-
if (o.numberMaxDecimals !== undefined) {
|
|
91
|
-
range += `${range ? " " : ""}${o.numberMinDecimals !== undefined ? "" : "decimal "}:${o.numberMaxDecimals}`;
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
case "array":
|
|
95
|
-
if (o.arrayMinLength !== undefined || o.arrayMaxLength !== undefined) {
|
|
96
|
-
range = "";
|
|
97
|
-
}
|
|
98
|
-
if (o.arrayMinLength !== undefined) {
|
|
99
|
-
range = `${o.arrayMinLength}:`;
|
|
100
|
-
}
|
|
101
|
-
if (o.arrayMaxLength !== undefined) {
|
|
102
|
-
range += `:${o.arrayMaxLength}`;
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
return range;
|
|
107
|
-
};
|
|
108
|
-
const parseOptionTable = (options, subName = "", tableHeaders = 0) => {
|
|
109
|
-
if (typeof options !== "boolean" && options) {
|
|
110
|
-
let padding = "";
|
|
111
|
-
for (let i = 0; i < tableHeaders; i++) {
|
|
112
|
-
padding += "| ";
|
|
113
|
-
}
|
|
114
|
-
const hl = "|----|----|----|----|----|----|----|----|----|----|";
|
|
115
|
-
const list = options.options instanceof Array ? options.options : parseOptionMap2ParseOptionList(options.options);
|
|
116
|
-
const headers = `|**name**|**description**|**type**|**arrayRange**|**arrayType**|**range**|**values**|**defaultValue**|**required**|**allowNull**|`;
|
|
117
|
-
return `${tableHeaders >= 0 ? `${padding}${headers}\n${tableHeaders === 0 ? `${padding}${hl}\n` : ""}` : ""}${list.map(o => {
|
|
118
|
-
const arrayRange = o.type === "array" ? getRange(o, o.type) : " ";
|
|
119
|
-
const range = o.type === "array" ? (o.arrayType ? getRange(o, o.arrayType) : " ") : getRange(o, o.type);
|
|
120
|
-
let out = `${padding}|${subName}${o.name}|${o.description ? o.description : " "}|${o.type}|${arrayRange}|${o.arrayType ? o.arrayType : " "}|` +
|
|
121
|
-
`${range}|` +
|
|
122
|
-
`${o.enumValues ? o.enumValues.join(", ") : " "}|${o.defaultValue !== undefined ? o.defaultValue : " "}|${o.required === undefined ? true : o.required}|${o.allowNull ? "true" : "false"}|`;
|
|
123
|
-
if (o.type === "multiple" || o.arrayType === "multiple") {
|
|
124
|
-
out += `\n${(o.multipleOptions ? o.multipleOptions : []).map(oM => {
|
|
125
|
-
return parseOptionTable({
|
|
126
|
-
options: [{
|
|
127
|
-
name: o.name,
|
|
128
|
-
...oM
|
|
129
|
-
}]
|
|
130
|
-
}, "", tableHeaders ? tableHeaders + 1 : 1);
|
|
131
|
-
})}`;
|
|
132
|
-
return out;
|
|
133
|
-
}
|
|
134
|
-
else if (o.type === "nested" || o.arrayType === "nested") {
|
|
135
|
-
out += `\n${parseOptionTable({ options: o.nestedOptions ? o.nestedOptions.options : [] }, `${subName}${o.name}${o.type === "array" ? "[..]" : ""}.`, tableHeaders ? tableHeaders + 1 : 1)}`;
|
|
136
|
-
return out;
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
return out;
|
|
140
|
-
}
|
|
141
|
-
}).join("\n")}`;
|
|
142
|
-
}
|
|
143
|
-
else if (options === false) {
|
|
144
|
-
return "";
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
return "";
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
const FAKE_TAB = " ";
|
|
151
|
-
const FAKE_DOUBLE_TAB = `${FAKE_TAB}${FAKE_TAB}`;
|
|
152
|
-
const featureIndex = `${docJSON.map(doc => {
|
|
153
|
-
return `- [${doc.featureName}](#${doc.featureName.toLowerCase()})\n\n${doc.description ? `${FAKE_TAB}${doc.description}\n\n` : ""}${FAKE_DOUBLE_TAB}${doc.path}`;
|
|
154
|
-
}).join("\n\n")}`;
|
|
155
|
-
(0, fs_1.writeFileSync)((0, path_1.resolve)(core_1.ConfigPathResolver.getBaseDirname(), outPath), `${featureIndex}\n\n` + docJSON.map(doc => {
|
|
156
|
-
const param = doc.params instanceof Array ? doc.params : [doc.params];
|
|
157
|
-
const paramsTable = [];
|
|
158
|
-
for (const q of param) {
|
|
159
|
-
let paramTable = typeof q === "string" ? `${q}` : parseOptionTable(q);
|
|
160
|
-
if (paramTable.split("\n").length > 1) {
|
|
161
|
-
paramTable = `### params${typeof q !== "boolean" && typeof q !== "string" && q && q.description ? ` (${q.description})` : ""}\n\n${paramTable}`;
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
paramTable = paramTable === "" ? "" : `### params${typeof q !== "boolean" && typeof q !== "string" && q && q.description ? ` (${q.description})` : ""}: ${paramTable}`;
|
|
165
|
-
}
|
|
166
|
-
if (paramTable !== "") {
|
|
167
|
-
paramsTable.push(paramTable);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
const query = doc.query instanceof Array ? doc.query : [doc.query];
|
|
171
|
-
const queryTables = [];
|
|
172
|
-
for (const q of query) {
|
|
173
|
-
let queryTable = typeof q === "string" ? `${q}` : parseOptionTable(q);
|
|
174
|
-
// let paramsTable = parseOptionTable(doc.params);
|
|
175
|
-
if (queryTable.split("\n").length > 1) {
|
|
176
|
-
queryTable = `### query${typeof q !== "boolean" && typeof q !== "string" && q && q.description ? ` (${q.description})` : ""}\n\n${queryTable}`;
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
queryTable = queryTable === "" ? "" : `### query${typeof q !== "boolean" && typeof q !== "string" && q && q.description ? ` (${q.description})` : ""}: ${queryTable}`;
|
|
180
|
-
}
|
|
181
|
-
if (queryTable !== "") {
|
|
182
|
-
queryTables.push(queryTable);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
/*if (paramsTable.split("\n").length > 1) {
|
|
186
|
-
paramsTable = `- params\n\n${paramsTable}`;
|
|
187
|
-
} else {
|
|
188
|
-
paramsTable = paramsTable === "" ? "" : `- params: ${paramsTable}`;
|
|
189
|
-
}*/
|
|
190
|
-
const body = doc.body instanceof Array ? doc.body : [doc.body];
|
|
191
|
-
const bodyTables = [];
|
|
192
|
-
for (const b of body) {
|
|
193
|
-
let bodyTable = typeof b === "string" ? `${b}` : parseOptionTable(b);
|
|
194
|
-
if (bodyTable.split("\n").length > 1) {
|
|
195
|
-
bodyTable = `### body${typeof b !== "boolean" && typeof b !== "string" && b && b.description ? ` (${b.description})` : ""}\n\n${bodyTable}`;
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
bodyTable = bodyTable === "" ? "" : `### body${typeof b !== "boolean" && typeof b !== "string" && b && b.description ? ` (${b.description})` : ""}: ${bodyTable}`;
|
|
199
|
-
}
|
|
200
|
-
if (bodyTable !== "") {
|
|
201
|
-
bodyTables.push(bodyTable);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
const results = doc.response instanceof Array ? doc.response : [doc.response];
|
|
205
|
-
const resultTables = [];
|
|
206
|
-
for (const r of results) {
|
|
207
|
-
if (!r) {
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
let resultsTable = r && typeof r !== "string" && typeof r !== "boolean" ? parseOptionTable(r) : r;
|
|
211
|
-
if (resultsTable.split("\n").length > 1) {
|
|
212
|
-
resultsTable = `### response${typeof r !== "boolean" && typeof r !== "string" && r.description ? ` (${r.description})` : ""}\n\n${resultsTable}`;
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
resultsTable = resultsTable === "" ? "" : `### response${typeof r !== "boolean" && typeof r !== "string" && r.description ? ` (${r.description})` : ""}: ${resultsTable}`;
|
|
216
|
-
}
|
|
217
|
-
if (resultsTable !== "") {
|
|
218
|
-
resultTables.push(resultsTable);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const pTable = policyTable(doc.policy);
|
|
222
|
-
return `## ${doc.featureName}\n\n` +
|
|
223
|
-
`${doc.description ? `${doc.description}\n\n` : ""}` +
|
|
224
|
-
`${pTable ? `${pTable}\n\n` : ""}` +
|
|
225
|
-
`### endpoint\n\n` +
|
|
226
|
-
`${methodUrlTable(doc)}\n\n` +
|
|
227
|
-
// `${paramsTable ? `${paramsTable}\n\n` : ""}` +
|
|
228
|
-
`${paramsTable.length > 0 ? `${paramsTable.join("\n\n")}\n\n` : ""}` +
|
|
229
|
-
`${queryTables.length > 0 ? `${queryTables.join("\n\n")}\n\n` : ""}` +
|
|
230
|
-
`${bodyTables.length > 0 ? `${bodyTables.join("\n\n")}\n\n` : ""}` +
|
|
231
|
-
`${resultTables.length > 0 ? `${resultTables.join("\n\n")}\n\n` : ""}`;
|
|
232
|
-
}).join("\n\n"));
|
|
233
|
-
};
|
|
234
|
-
exports.main = main;
|