miqro 1.9.2 → 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 +22 -23
- package/dist/cli.js +41 -30
- package/dist/cmds/db-sync-makemigrations.d.ts +1 -1
- package/dist/cmds/db-sync-makemigrations.js +1 -1
- package/dist/cmds/doc-json.d.ts +1 -1
- package/dist/cmds/doc-json.js +4 -3
- package/dist/cmds/handler-apiroute-new.d.ts +1 -1
- package/dist/cmds/handler-apiroute-new.js +1 -1
- package/dist/cmds/handler-main-new.d.ts +1 -1
- package/dist/cmds/handler-main-new.js +1 -1
- package/dist/cmds/new.d.ts +1 -3
- package/dist/cmds/new.js +15 -23
- package/dist/cmds/start.d.ts +1 -1
- package/dist/cmds/start.js +1 -1
- package/dist/cmds/wc-new.d.ts +2 -0
- package/dist/cmds/wc-new.js +122 -0
- 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
|
@@ -13,38 +13,37 @@ npx miqro
|
|
|
13
13
|
```
|
|
14
14
|
Available commands:
|
|
15
15
|
|
|
16
|
+
|
|
16
17
|
==api development==
|
|
17
18
|
|
|
18
|
-
new
|
|
19
|
-
new:
|
|
20
|
-
new:
|
|
21
|
-
|
|
22
|
-
config
|
|
23
|
-
config:
|
|
24
|
-
config:
|
|
25
|
-
|
|
26
|
-
doc api folder auto doc as a json.
|
|
27
|
-
doc:md api folder auto doc as a markdown.
|
|
19
|
+
new:api create a new project.
|
|
20
|
+
new:api:main creates a new main file.
|
|
21
|
+
new:api:route creates a new route.
|
|
22
|
+
config print config as a json.
|
|
23
|
+
config:bash print config as a bash script.
|
|
24
|
+
config:env print config as a env file.
|
|
25
|
+
config:init inits your config folder.
|
|
26
|
+
doc api folder auto doc as a json.
|
|
28
27
|
|
|
29
28
|
==start helpers==
|
|
30
29
|
|
|
31
|
-
start
|
|
32
|
-
watch
|
|
33
|
-
serve
|
|
30
|
+
start start script in cluster mode.
|
|
31
|
+
watch watch folder for changes.
|
|
32
|
+
serve serve static files.
|
|
34
33
|
|
|
35
34
|
==testing==
|
|
36
35
|
|
|
37
|
-
test
|
|
38
|
-
new:test
|
|
36
|
+
test run test files.
|
|
37
|
+
new:test create new test.js file.
|
|
39
38
|
|
|
40
39
|
==sequelize helpers==
|
|
41
40
|
|
|
42
|
-
db:console
|
|
43
|
-
db:dump:data
|
|
44
|
-
db:push:data
|
|
45
|
-
db:make:migration
|
|
46
|
-
db:
|
|
47
|
-
db:migrate
|
|
48
|
-
db:init
|
|
49
|
-
db:create:model
|
|
41
|
+
db:console a query console for sequelize.
|
|
42
|
+
db:dump:data dump the data of the database.
|
|
43
|
+
db:push:data push a dump to the database.
|
|
44
|
+
db:make:migration generate migrations from model changes.
|
|
45
|
+
db:migration:forceclean force 'local' model state.
|
|
46
|
+
db:migrate loads config and run migrations.
|
|
47
|
+
db:init init sequelize configuration.
|
|
48
|
+
db:create:model creates an example model.
|
|
50
49
|
```
|
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");
|
|
@@ -26,85 +26,96 @@ const db_dump_data_1 = require("./cmds/db-dump-data");
|
|
|
26
26
|
const db_migrate_1 = require("./cmds/db-migrate");
|
|
27
27
|
// noinspection SpellCheckingInspection
|
|
28
28
|
(0, utils_1.mainCMD)({
|
|
29
|
-
["new"]: { section: "api development", cb: new_1.
|
|
30
|
-
["new:typescript"]: {
|
|
31
|
-
["new:main"]: {
|
|
29
|
+
["new:api"]: { section: "api development", cb: new_1.mainTS, tabs: 4, description: `create a new project.` },
|
|
30
|
+
//["new:typescript"]: {cb: newTS, tabs: 4, description: `create a new typescript project.`},
|
|
31
|
+
["new:api:main"]: {
|
|
32
32
|
//section: "http scafolding",
|
|
33
33
|
cb: handler_main_new_1.main,
|
|
34
|
-
tabs:
|
|
34
|
+
tabs: 3,
|
|
35
35
|
description: `creates a new main file.`
|
|
36
36
|
},
|
|
37
|
-
["new:route"]: { cb: handler_apiroute_new_1.main, tabs:
|
|
37
|
+
["new:api:route"]: { cb: handler_apiroute_new_1.main, tabs: 3, description: `creates a new route.` },
|
|
38
38
|
["config"]: {
|
|
39
39
|
//section: "config managment",
|
|
40
40
|
cb: config_1.main,
|
|
41
|
-
tabs:
|
|
41
|
+
tabs: 4,
|
|
42
42
|
description: `print config as a json.`
|
|
43
43
|
},
|
|
44
44
|
["config:bash"]: {
|
|
45
45
|
cb: config_bash_1.main,
|
|
46
|
-
tabs:
|
|
46
|
+
tabs: 3,
|
|
47
47
|
description: `print config as a bash script.`
|
|
48
48
|
},
|
|
49
49
|
["config:env"]: {
|
|
50
50
|
cb: config_env_1.main,
|
|
51
|
-
tabs:
|
|
51
|
+
tabs: 3,
|
|
52
52
|
description: `print config as a env file.`
|
|
53
53
|
},
|
|
54
|
-
["config:init"]: { cb: config_init_1.main, tabs:
|
|
54
|
+
["config:init"]: { cb: config_init_1.main, tabs: 3, description: `inits your config folder.` },
|
|
55
55
|
["doc"]: {
|
|
56
56
|
//section: "api documentation",
|
|
57
|
-
tabs:
|
|
57
|
+
tabs: 4,
|
|
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
|
+
/*["new:front"]: {
|
|
67
|
+
section: "front end development",
|
|
68
|
+
cb: newTSFront,
|
|
69
|
+
tabs: 3,
|
|
70
|
+
description: `create a new web-components project.`
|
|
71
|
+
},*/
|
|
66
72
|
["start"]: {
|
|
67
73
|
section: "start helpers",
|
|
68
|
-
tabs:
|
|
74
|
+
tabs: 4,
|
|
69
75
|
cb: start_1.main,
|
|
70
76
|
description: `start script in cluster mode.`
|
|
71
77
|
},
|
|
78
|
+
["cluster"]: {
|
|
79
|
+
tabs: 4,
|
|
80
|
+
cb: start_1.main,
|
|
81
|
+
description: `alias for start command.`
|
|
82
|
+
},
|
|
72
83
|
["watch"]: {
|
|
73
84
|
//section: "watch",
|
|
74
85
|
cb: watch_1.main,
|
|
75
|
-
tabs:
|
|
86
|
+
tabs: 4,
|
|
76
87
|
description: `watch folder for changes.`
|
|
77
88
|
},
|
|
78
89
|
["serve"]: {
|
|
79
90
|
//section: "serve static files",
|
|
80
|
-
tabs:
|
|
91
|
+
tabs: 4,
|
|
81
92
|
cb: serve_1.main, description: `serve static files.`
|
|
82
93
|
},
|
|
83
|
-
["test"]: { section: "testing", cb: test_1.main, tabs:
|
|
84
|
-
["new:test"]: { cb: new_test_1.main, tabs:
|
|
94
|
+
["test"]: { section: "testing", cb: test_1.main, tabs: 4, description: `run test files.` },
|
|
95
|
+
["new:test"]: { cb: new_test_1.main, tabs: 3, description: `create new test.js file.` },
|
|
85
96
|
["db:console"]: {
|
|
86
97
|
section: "sequelize helpers",
|
|
87
98
|
cb: db_console_1.main,
|
|
88
|
-
tabs:
|
|
99
|
+
tabs: 3,
|
|
89
100
|
description: `a query console for sequelize.`
|
|
90
101
|
},
|
|
91
102
|
["db:dump:data"]: {
|
|
92
103
|
cb: db_dump_data_1.main,
|
|
93
|
-
tabs:
|
|
104
|
+
tabs: 3,
|
|
94
105
|
description: `dump the data of the database.`
|
|
95
106
|
},
|
|
96
|
-
["db:push:data"]: { cb: db_push_data_1.main, tabs:
|
|
107
|
+
["db:push:data"]: { cb: db_push_data_1.main, tabs: 3, description: `push a dump to the database.` },
|
|
97
108
|
["db:make:migration"]: {
|
|
98
109
|
cb: db_makemigrations_1.main,
|
|
99
|
-
tabs:
|
|
110
|
+
tabs: 2,
|
|
100
111
|
description: `generate migrations from model changes.`
|
|
101
112
|
},
|
|
102
|
-
["db:
|
|
113
|
+
["db:migration:forceclean"]: {
|
|
103
114
|
cb: db_sync_makemigrations_1.main,
|
|
104
|
-
tabs:
|
|
115
|
+
tabs: 2,
|
|
105
116
|
description: `force 'local' model state.`
|
|
106
117
|
},
|
|
107
|
-
["db:migrate"]: { cb: db_migrate_1.main, tabs:
|
|
108
|
-
["db:init"]: { cb: db_init_1.main, tabs:
|
|
109
|
-
["db:create:model"]: { cb: db_createmodel_1.main, tabs:
|
|
118
|
+
["db:migrate"]: { cb: db_migrate_1.main, tabs: 3, description: `loads config and run migrations.` },
|
|
119
|
+
["db:init"]: { cb: db_init_1.main, tabs: 4, description: `init sequelize configuration.` },
|
|
120
|
+
["db:create:model"]: { cb: db_createmodel_1.main, tabs: 3, description: `creates an example model.` }
|
|
110
121
|
}, "npx miqro <command> [args]", console);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const usage = "usage: [NODE_ENV=development] npx miqro db:
|
|
1
|
+
export declare const usage = "usage: [NODE_ENV=development] npx miqro db:migration:forceclean";
|
|
2
2
|
export declare const main: () => void;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.main = exports.usage = void 0;
|
|
4
4
|
const db_1 = require("../utils/db");
|
|
5
5
|
const core_1 = require("@miqro/core");
|
|
6
|
-
exports.usage = "usage: [NODE_ENV=development] npx miqro db:
|
|
6
|
+
exports.usage = "usage: [NODE_ENV=development] npx miqro db:migration:forceclean";
|
|
7
7
|
const main = () => {
|
|
8
8
|
if (process.argv.length !== 3) {
|
|
9
9
|
throw new Error(`invalid number of args`);
|
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;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const usage = "usage: [NODE_ENV=development] npx miqro new:route <identifier ex: SRC_API_V1_HEALTH>";
|
|
1
|
+
export declare const usage = "usage: [NODE_ENV=development] npx miqro new:api:route <identifier ex: SRC_API_V1_HEALTH>";
|
|
2
2
|
export declare const main: () => void;
|
|
@@ -42,7 +42,7 @@ export default {
|
|
|
42
42
|
};
|
|
43
43
|
`
|
|
44
44
|
};
|
|
45
|
-
exports.usage = `usage: [NODE_ENV=development] npx miqro new:route <identifier ex: SRC_API_V1_HEALTH>`;
|
|
45
|
+
exports.usage = `usage: [NODE_ENV=development] npx miqro new:api:route <identifier ex: SRC_API_V1_HEALTH>`;
|
|
46
46
|
const main = () => {
|
|
47
47
|
if (process.argv.length !== 4 || process.argv[3].length < 1) {
|
|
48
48
|
throw new Error(exports.usage);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const usage = "usage: [NODE_ENV=development] npx miqro new:main <identifier ex: NEW_APP>";
|
|
1
|
+
export declare const usage = "usage: [NODE_ENV=development] npx miqro new:api:main <identifier ex: NEW_APP>";
|
|
2
2
|
export declare const main: () => void;
|
|
@@ -48,7 +48,7 @@ app.listen(PORT, () => {
|
|
|
48
48
|
});
|
|
49
49
|
`
|
|
50
50
|
};
|
|
51
|
-
exports.usage = `usage: [NODE_ENV=development] npx miqro new:main <identifier ex: NEW_APP>`;
|
|
51
|
+
exports.usage = `usage: [NODE_ENV=development] npx miqro new:api:main <identifier ex: NEW_APP>`;
|
|
52
52
|
const main = () => {
|
|
53
53
|
if (process.argv.length !== 4 || process.argv[3].length < 1) {
|
|
54
54
|
throw new Error(exports.usage);
|
package/dist/cmds/new.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const usageTS = "usage: npx miqro new:typescript <identifier ex: NEW_APP>";
|
|
3
|
-
export declare const mainJS: (typescript?: boolean) => void;
|
|
1
|
+
export declare const usageTS = "usage: npx miqro new:api <identifier ex: NEW_APP>";
|
|
4
2
|
export declare const mainTS: () => void;
|
package/dist/cmds/new.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mainTS = exports.
|
|
3
|
+
exports.mainTS = exports.usageTS = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
@@ -50,11 +50,10 @@ const packageTemplate = {
|
|
|
50
50
|
"license": "ISC"
|
|
51
51
|
}`
|
|
52
52
|
};
|
|
53
|
-
exports.
|
|
54
|
-
|
|
55
|
-
const mainJS = (typescript = false) => {
|
|
53
|
+
exports.usageTS = `usage: npx miqro new:api <identifier ex: NEW_APP>`;
|
|
54
|
+
const mainTS = () => {
|
|
56
55
|
if (process.argv.length !== 4 || process.argv[3].length < 1) {
|
|
57
|
-
throw new Error(
|
|
56
|
+
throw new Error(exports.usageTS);
|
|
58
57
|
}
|
|
59
58
|
const identifier = process.argv[3].toLocaleLowerCase();
|
|
60
59
|
const appFolder = (0, path_1.resolve)(process.cwd(), identifier);
|
|
@@ -65,15 +64,14 @@ const mainJS = (typescript = false) => {
|
|
|
65
64
|
(0, fs_1.mkdirSync)(appFolder, {
|
|
66
65
|
recursive: true
|
|
67
66
|
});
|
|
68
|
-
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "package.json"), packageTemplate[
|
|
67
|
+
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "package.json"), packageTemplate["ts"](identifier));
|
|
69
68
|
(0, utils_1.execSync)(`npm install miqro --save-dev`, {
|
|
70
69
|
cwd: appFolder
|
|
71
70
|
});
|
|
72
71
|
(0, utils_1.execSync)(`npm install @miqro/core --save`, {
|
|
73
72
|
cwd: appFolder
|
|
74
73
|
});
|
|
75
|
-
|
|
76
|
-
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "tsconfig.json"), `{
|
|
74
|
+
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "tsconfig.json"), `{
|
|
77
75
|
"compileOnSave": true,
|
|
78
76
|
"compilerOptions": {
|
|
79
77
|
"lib": ["es2021"],
|
|
@@ -97,24 +95,20 @@ const mainJS = (typescript = false) => {
|
|
|
97
95
|
"src"
|
|
98
96
|
]
|
|
99
97
|
}`);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, ".gitignore"), gitignoreTemplate.js());
|
|
110
|
-
}
|
|
98
|
+
(0, utils_1.execSync)(`npm install typescript --save-dev`, {
|
|
99
|
+
cwd: appFolder
|
|
100
|
+
});
|
|
101
|
+
(0, utils_1.execSync)(`npm install @types/node --save-dev`, {
|
|
102
|
+
cwd: appFolder
|
|
103
|
+
});
|
|
104
|
+
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, ".gitignore"), gitignoreTemplate.ts());
|
|
111
105
|
(0, utils_1.execSync)(`npm install @miqro/test --save-dev`, {
|
|
112
106
|
cwd: appFolder
|
|
113
107
|
});
|
|
114
|
-
(0, utils_1.execSync)(`npx miqro new:main src_main`, {
|
|
108
|
+
(0, utils_1.execSync)(`npx miqro new:api:main src_main`, {
|
|
115
109
|
cwd: appFolder
|
|
116
110
|
});
|
|
117
|
-
(0, utils_1.execSync)(`npx miqro new:route src_api_health`, {
|
|
111
|
+
(0, utils_1.execSync)(`npx miqro new:api:route src_api_health`, {
|
|
118
112
|
cwd: appFolder
|
|
119
113
|
});
|
|
120
114
|
(0, fs_1.mkdirSync)((0, path_1.resolve)(appFolder, "test"), {
|
|
@@ -127,6 +121,4 @@ const mainJS = (typescript = false) => {
|
|
|
127
121
|
console.log(`cd ${identifier}`);
|
|
128
122
|
console.log(`npm run start`);
|
|
129
123
|
};
|
|
130
|
-
exports.mainJS = mainJS;
|
|
131
|
-
const mainTS = () => (0, exports.mainJS)(true);
|
|
132
124
|
exports.mainTS = mainTS;
|
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}`);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mainTS = exports.usageTS = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const indexHTML = {
|
|
8
|
+
js: () => `<html>` +
|
|
9
|
+
`<script type="text/javascript" src="app.bundle.min.js"></script>` +
|
|
10
|
+
`<body>` +
|
|
11
|
+
`<app-component></app-component>` +
|
|
12
|
+
`</body>` +
|
|
13
|
+
`</html>`
|
|
14
|
+
};
|
|
15
|
+
const indexComponent = {
|
|
16
|
+
ts: () => `import WebComponents, {JSX, define, RenderFunctionThis} from "@miqro/web-components"\n` +
|
|
17
|
+
`\n` +
|
|
18
|
+
`define("app-component", function(this: RenderFunctionThis): JSX.Element {\n` +
|
|
19
|
+
` return (<p>Hello World!</p>);\n` +
|
|
20
|
+
`});\n`
|
|
21
|
+
};
|
|
22
|
+
const webpackconfig = {
|
|
23
|
+
ts: () => `const mode = process.env.NODE_ENV ? process.env.NODE_ENV : "development";
|
|
24
|
+
console.log("webpack mode [%s]", mode);
|
|
25
|
+
module.exports = {` +
|
|
26
|
+
` mode: "production",` +
|
|
27
|
+
` entry: "./dist/index.js",` +
|
|
28
|
+
` output: {` +
|
|
29
|
+
` path: require("path").resolve(__dirname, 'build'),` +
|
|
30
|
+
` filename: "app.bundle.min.js"` +
|
|
31
|
+
` }` +
|
|
32
|
+
`};`,
|
|
33
|
+
};
|
|
34
|
+
const gitignoreTemplate = {
|
|
35
|
+
ts: () => `node_modules/
|
|
36
|
+
dist/
|
|
37
|
+
`
|
|
38
|
+
};
|
|
39
|
+
const packageTemplate = {
|
|
40
|
+
ts: (name) => `{
|
|
41
|
+
"name": "${name}",
|
|
42
|
+
"version": "1.0.0",
|
|
43
|
+
"description": "",
|
|
44
|
+
"private": true,
|
|
45
|
+
"main": "dist/main.js",
|
|
46
|
+
"scripts": {
|
|
47
|
+
"prebuild": "rm -Rf build/; rm -Rf dist/; mkdir build && cp -R public/ build/",
|
|
48
|
+
"build": "tsc && NODE_ENV=production webpack",
|
|
49
|
+
"build:dev": "tsc && webpack",
|
|
50
|
+
"prestart": "npm run build:dev",
|
|
51
|
+
"start": "miqro serve build/ / --port 3000 & miqro watch src/ \\"npm run build:dev\\""
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
},
|
|
57
|
+
"author": "",
|
|
58
|
+
"license": "ISC"
|
|
59
|
+
}`
|
|
60
|
+
};
|
|
61
|
+
exports.usageTS = `usage: npx miqro new:front <identifier ex: NEW_APP>`;
|
|
62
|
+
const mainTS = () => {
|
|
63
|
+
if (process.argv.length !== 4 || process.argv[3].length < 1) {
|
|
64
|
+
throw new Error(exports.usageTS);
|
|
65
|
+
}
|
|
66
|
+
const identifier = process.argv[3].toLocaleLowerCase();
|
|
67
|
+
const appFolder = (0, path_1.resolve)(process.cwd(), identifier);
|
|
68
|
+
if ((0, fs_1.existsSync)(appFolder)) {
|
|
69
|
+
throw new Error(`${appFolder} already exists!`);
|
|
70
|
+
}
|
|
71
|
+
console.log(`creating ${appFolder}`);
|
|
72
|
+
(0, fs_1.mkdirSync)(appFolder, {
|
|
73
|
+
recursive: true
|
|
74
|
+
});
|
|
75
|
+
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "package.json"), packageTemplate["ts"](identifier));
|
|
76
|
+
(0, utils_1.execSync)(`npm install miqro --save-dev`, {
|
|
77
|
+
cwd: appFolder
|
|
78
|
+
});
|
|
79
|
+
/*execSync(
|
|
80
|
+
`npm install @miqro/web-components --save`,
|
|
81
|
+
{
|
|
82
|
+
cwd: appFolder
|
|
83
|
+
}
|
|
84
|
+
);*/
|
|
85
|
+
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "tsconfig.json"), `{
|
|
86
|
+
"compileOnSave": true,
|
|
87
|
+
"compilerOptions": {
|
|
88
|
+
"lib": ["es2021", "dom"],
|
|
89
|
+
"module": "commonjs",
|
|
90
|
+
"moduleResolution": "node",
|
|
91
|
+
"target": "es2021",
|
|
92
|
+
"strict": false,
|
|
93
|
+
"outDir": "./dist/",
|
|
94
|
+
"jsx": "react",
|
|
95
|
+
"jsxFactory": "WebComponents.jsxFactory",
|
|
96
|
+
"jsxFragmentFactory": "WebComponents.jsxFragmentFactory"
|
|
97
|
+
},
|
|
98
|
+
"exclude": [
|
|
99
|
+
"node_modules",
|
|
100
|
+
"test"
|
|
101
|
+
],
|
|
102
|
+
"include": [
|
|
103
|
+
"src"
|
|
104
|
+
]
|
|
105
|
+
}`);
|
|
106
|
+
(0, utils_1.execSync)(`npm install typescript --save-dev`, {
|
|
107
|
+
cwd: appFolder
|
|
108
|
+
});
|
|
109
|
+
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, ".gitignore"), gitignoreTemplate.ts());
|
|
110
|
+
(0, utils_1.execSync)(`npm install webpack-cli --save-dev`, {
|
|
111
|
+
cwd: appFolder
|
|
112
|
+
});
|
|
113
|
+
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "webpack.config.js"), webpackconfig.ts());
|
|
114
|
+
(0, fs_1.mkdirSync)((0, path_1.resolve)(appFolder, "src"));
|
|
115
|
+
(0, fs_1.mkdirSync)((0, path_1.resolve)(appFolder, "public"));
|
|
116
|
+
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "public", "index.html"), indexHTML.js());
|
|
117
|
+
(0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "src", "index" + (".tsx")), indexComponent.ts());
|
|
118
|
+
console.log(`new project created on ${appFolder}`);
|
|
119
|
+
console.log(`cd ${identifier}`);
|
|
120
|
+
console.log(`npm run start`);
|
|
121
|
+
};
|
|
122
|
+
exports.mainTS = mainTS;
|
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;
|