miqro 5.0.1 → 5.0.3

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/build/cli.js CHANGED
File without changes
package/build/cmd-map.js CHANGED
@@ -245,27 +245,29 @@ export const CMD_MAP = {
245
245
  //section: "api documentation",
246
246
  tabs: 4,
247
247
  cb: async () => {
248
- if (process.argv.length < 5 || process.argv.length > 6) {
249
- throw new Error(`usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath> [apiName]`);
248
+ if (process.argv.length < 5 || process.argv.length > 7) {
249
+ throw new Error(`usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath> [apiName] [ignore]`);
250
250
  }
251
251
  const dirname = process.argv[3];
252
252
  const subPath = process.argv[4];
253
253
  const apiName = process.argv[5];
254
+ const ignore = process.argv[6];
254
255
  loadConfig();
255
- console.log(JSON.stringify(await getDOCJSON({ dirname, subPath, apiName }), undefined, 2));
256
+ console.log(JSON.stringify(await getDOCJSON({ dirname, subPath, apiName, ignore: ignore ? ignore.split(",") : undefined }), undefined, 2));
256
257
  },
257
258
  description: `api folder auto doc as a json.`
258
259
  },
259
260
  ["doc:md"]: {
260
261
  cb: async () => {
261
- if (process.argv.length < 5 || process.argv.length > 6) {
262
- throw new Error(`usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath> [apiName]`);
262
+ if (process.argv.length < 5 || process.argv.length > 7) {
263
+ throw new Error(`usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath> [apiName] [ignore]`);
263
264
  }
264
265
  const dirname = process.argv[3];
265
266
  const subPath = process.argv[4];
266
267
  const apiName = process.argv[5];
268
+ const ignore = process.argv[6];
267
269
  loadConfig();
268
- console.log(await getMDDoc({ dirname, subPath, apiName }));
270
+ console.log(await getMDDoc({ dirname, subPath, apiName, ignore: ignore.split(",") }));
269
271
  },
270
272
  tabs: 4,
271
273
  description: `api folder auto doc as a markdown.`
@@ -1,5 +1,6 @@
1
1
  import { Logger, RouterJSONDoc } from "@miqro/core";
2
- export declare const getDOCJSON: ({ dirname, subPath, apiName }: {
2
+ export declare const getDOCJSON: ({ dirname, subPath, apiName, ignore }: {
3
+ ignore?: string[] | undefined;
3
4
  apiName?: string | undefined;
4
5
  dirname: string;
5
6
  subPath: string;
@@ -1,11 +1,12 @@
1
1
  import { APIRouter, ConfigPathResolver } from "@miqro/core";
2
2
  import { resolve } from "path";
3
- export const getDOCJSON = async ({ dirname, subPath, apiName }, logger) => {
3
+ export const getDOCJSON = async ({ dirname, subPath, apiName, ignore }, logger) => {
4
4
  //const apiTraverse = traverseAPIRouteDir(basename(dirname).toUpperCase(), resolve(ConfigPathResolver.getBaseDirname(), dirname), subPath, undefined, logger);
5
5
  const router = await APIRouter({
6
6
  apiName,
7
7
  dirname: resolve(ConfigPathResolver.getBaseDirname(), dirname),
8
- path: subPath
8
+ path: subPath,
9
+ ignore
9
10
  }, logger);
10
11
  return router.getJSONDoc();
11
12
  };
@@ -1,11 +1,13 @@
1
1
  import { Logger, ParserMode, SchemaProperties } from "@miqro/core";
2
2
  export declare function getMDDoc(args: {
3
+ ignore?: string[];
3
4
  showFilePath?: boolean;
4
5
  apiName?: string;
5
6
  dirname: string;
6
7
  subPath: string;
7
8
  }, logger?: Logger): Promise<string>;
8
9
  export declare function parserToString(parser: {
10
+ status?: number | number[];
9
11
  headers?: string | SchemaProperties | SchemaProperties[];
10
12
  headersMode?: ParserMode;
11
13
  query?: string | SchemaProperties | boolean | SchemaProperties[];
@@ -12,26 +12,28 @@ export async function getMDDoc(args, logger) {
12
12
  const pathData = jsonDOC[path];
13
13
  const methods = Object.keys(pathData);
14
14
  for (const method of methods) {
15
- const apiData = pathData[method];
16
- outMD += `## ${apiData.identifier}${args.showFilePath ? apiData.___filePath : ""}\n\n`;
17
- if (apiData.name) {
18
- outMD += `${apiData.name}\n\n`;
19
- }
20
- if (apiData.description) {
21
- outMD += `${apiData.description}\n\n`;
22
- }
23
- outMD += `[${method}] ${path}\n\n`;
24
- if (apiData.policy) {
25
- outMD += `### policy\n\n`;
26
- outMD += policyToString(apiData.policy);
27
- }
28
- if (apiData.request) {
29
- const requestOutMD = parserToString(apiData.request);
30
- outMD += requestOutMD !== "" ? `### request\n\n${requestOutMD}` : "";
31
- }
32
- if (apiData.response && typeof apiData.response !== "boolean") {
33
- const responseOutMD = parserToString(apiData.response);
34
- outMD += responseOutMD !== "" ? `### response\n\n${responseOutMD}` : "";
15
+ const apiDataList = pathData[method];
16
+ for (const apiData of apiDataList) {
17
+ outMD += `## ${apiData.identifier}${args.showFilePath ? apiData.___filePath : ""}\n\n`;
18
+ if (apiData.name) {
19
+ outMD += `${apiData.name}\n\n`;
20
+ }
21
+ if (apiData.description) {
22
+ outMD += `${apiData.description}\n\n`;
23
+ }
24
+ outMD += `[${method}] ${path}\n\n`;
25
+ if (apiData.policy) {
26
+ outMD += `### policy\n\n`;
27
+ outMD += policyToString(apiData.policy);
28
+ }
29
+ if (apiData.request) {
30
+ const requestOutMD = parserToString(apiData.request);
31
+ outMD += requestOutMD !== "" ? `### request\n\n${requestOutMD}` : "";
32
+ }
33
+ if (apiData.response && typeof apiData.response !== "boolean") {
34
+ const responseOutMD = parserToString(apiData.response);
35
+ outMD += responseOutMD !== "" ? `### response\n\n${responseOutMD}` : "";
36
+ }
35
37
  }
36
38
  }
37
39
  }
@@ -45,6 +47,9 @@ function policyToString(policy) {
45
47
  }
46
48
  export function parserToString(parser) {
47
49
  let outMD = "";
50
+ if (parser.status) {
51
+ outMD += `#### status\n\n${parser.status instanceof Array ? parser.status.join(",") : parser.status}\n\n`;
52
+ }
48
53
  if (parser.params && typeof parser.params !== "boolean") {
49
54
  outMD += `#### path params\n\n`;
50
55
  outMD += parserPartToString(parser.params, parser.paramsMode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miqro",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  "miqro": "build/cli.js"
10
10
  },
11
11
  "scripts": {
12
- "prepare": "npm run build",
12
+ "prepare2": "npm run build",
13
13
  "prebuild": "rm -Rf build;",
14
14
  "build": "tsc",
15
15
  "pretest": "npm run build",
@@ -19,8 +19,8 @@
19
19
  "author": "claukers",
20
20
  "license": "ISC",
21
21
  "dependencies": {
22
- "@miqro/core": "^5.0.2",
23
- "@miqro/parser": "^2.0.2",
22
+ "@miqro/core": "^5.0.10",
23
+ "@miqro/parser": "^2.0.3",
24
24
  "@miqro/runner": "^2.0.1"
25
25
  },
26
26
  "devDependencies": {