mushroom-cli 1.2.7 → 1.2.8
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 +7 -0
- package/dist/docs/docs.v2.js +2 -2
- package/dist/gen/gen-list-api.js +52 -0
- package/dist/gen.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,6 +132,13 @@ npx mushroom-cli parameters --no-check-update
|
|
|
132
132
|
|
|
133
133
|
## Version
|
|
134
134
|
|
|
135
|
+
### 1.2.8
|
|
136
|
+
|
|
137
|
+
Improvement
|
|
138
|
+
|
|
139
|
+
- gen docs: fix bug: gen docs fail when entity action has codehint.delegator.params
|
|
140
|
+
- gen docs: fix bug: gen wrong docs for entity view params
|
|
141
|
+
|
|
135
142
|
### 1.2.6, 1.2.7
|
|
136
143
|
|
|
137
144
|
Hot fixed
|
package/dist/docs/docs.v2.js
CHANGED
|
@@ -1025,7 +1025,7 @@ function renderGeneralAction(args) {
|
|
|
1025
1025
|
type: (field.type === 'array' ? 'array of ' : '') + (field.items?.type ?? 'string'),
|
|
1026
1026
|
description: field.description ?? '',
|
|
1027
1027
|
required: field.required ? 'required' : 'optional',
|
|
1028
|
-
validation: getValidationStringDocs(
|
|
1028
|
+
validation: getValidationStringDocs(field, true),
|
|
1029
1029
|
})
|
|
1030
1030
|
}).join('');
|
|
1031
1031
|
} else {
|
|
@@ -1150,7 +1150,7 @@ function renderEntityViewRolePage(entityName, viewName, grant) {
|
|
|
1150
1150
|
type: (p.isArray ? 'array of ' : '') + (p.type ?? 'string'),
|
|
1151
1151
|
description: p.description ?? '',
|
|
1152
1152
|
defaultValue: p.defaultValue ? `, default (${p.defaultValue})` : '',
|
|
1153
|
-
required: p.required ? 'required' : 'optional',
|
|
1153
|
+
required: p.validation?.required ? 'required' : 'optional',
|
|
1154
1154
|
validation: getValidationStringDocs(p.validation, true),
|
|
1155
1155
|
}),
|
|
1156
1156
|
)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as common from '../common.js';
|
|
2
|
+
export function listApi(source) {
|
|
3
|
+
const entities = common.getEntities(source, ["*"], true);
|
|
4
|
+
const endpoints = new Set();
|
|
5
|
+
for (const entityName in entities) {
|
|
6
|
+
const actions = entities[entityName].actions || {};
|
|
7
|
+
for (const actionName in actions) {
|
|
8
|
+
const action = actions[actionName];
|
|
9
|
+
if (!Array.isArray(action) || !action.length || action.every(a => !a.enabled))
|
|
10
|
+
continue;
|
|
11
|
+
let method;
|
|
12
|
+
let id = '';
|
|
13
|
+
if (actionName == 'findById') {
|
|
14
|
+
method = 'GET';
|
|
15
|
+
id = '/{{id}}';
|
|
16
|
+
}
|
|
17
|
+
if (actionName == 'findMany')
|
|
18
|
+
method = 'GET';
|
|
19
|
+
else if (actionName == 'createOne' || actionName == 'createMany')
|
|
20
|
+
method = 'POST';
|
|
21
|
+
else if (actionName?.startsWith('_raw_http_method_')) {
|
|
22
|
+
method = 'POST';
|
|
23
|
+
id = '/' + actionName.substring('_raw_http_method_'.length);
|
|
24
|
+
}
|
|
25
|
+
else if (actionName == 'updateOne') {
|
|
26
|
+
method = 'PUT';
|
|
27
|
+
id = '/{{id}}';
|
|
28
|
+
}
|
|
29
|
+
else if (actionName == 'updateMany')
|
|
30
|
+
method = 'PUT';
|
|
31
|
+
else if (actionName == 'updatePartially') {
|
|
32
|
+
method = 'PATCH';
|
|
33
|
+
id = '/{{id}}';
|
|
34
|
+
}
|
|
35
|
+
else if (actionName == 'deleteOne') {
|
|
36
|
+
method = 'DELETE';
|
|
37
|
+
id = '/{{id}}';
|
|
38
|
+
}
|
|
39
|
+
else if (actionName == 'deleteMany')
|
|
40
|
+
method = 'DELETE';
|
|
41
|
+
endpoints.add(`${method} ${source.rootUrl}${entityName}s${id}`);
|
|
42
|
+
}
|
|
43
|
+
const views = entities[entityName].views || {};
|
|
44
|
+
for (const viewName in views) {
|
|
45
|
+
const view = views[viewName];
|
|
46
|
+
if (!Array.isArray(view) || !view.length || view.every(v => !v.enabled))
|
|
47
|
+
continue;
|
|
48
|
+
endpoints.add(`GET ${source.rootUrl}${entityName}s/views/${viewName}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
endpoints.forEach(e => console.log(e));
|
|
52
|
+
}
|
package/dist/gen.js
CHANGED
|
@@ -10,6 +10,7 @@ import genDatabaseDocs from './gen/gen-db-docs.js';
|
|
|
10
10
|
import * as javascriptDriverGenerator from './gen/gen-js-driver.js';
|
|
11
11
|
import genJavascriptDriverTarball from './gen/gen-js-driver-tarball.js';
|
|
12
12
|
import * as typescriptDriverGenerator from './gen/gen-ts-driver.js';
|
|
13
|
+
import * as listApi from './gen/gen-list-api.js';
|
|
13
14
|
import * as csharp from './gen/gen-csharp.js';
|
|
14
15
|
export default async function gen(args) {
|
|
15
16
|
let projectName = args[1];
|
|
@@ -96,7 +97,9 @@ export default async function gen(args) {
|
|
|
96
97
|
case 'c#-driver':
|
|
97
98
|
csharp.genCSharpDriver(args, projectName, project, alias, source);
|
|
98
99
|
break;
|
|
99
|
-
case '':
|
|
100
|
+
case 'list-api':
|
|
101
|
+
listApi.listApi(source);
|
|
102
|
+
break;
|
|
100
103
|
case undefined:
|
|
101
104
|
case 'help':
|
|
102
105
|
case 'man':
|