mushroom-cli 1.2.6 → 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 +11 -0
- package/dist/docs/docs.v2.js +2 -2
- package/dist/gen/gen-csharp.js +1 -0
- package/dist/gen/gen-list-api.js +52 -0
- package/dist/gen/gen-ts-driver.js +9 -9
- package/dist/gen.js +4 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -132,6 +132,17 @@ 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
|
+
|
|
142
|
+
### 1.2.6, 1.2.7
|
|
143
|
+
|
|
144
|
+
Hot fixed
|
|
145
|
+
|
|
135
146
|
### 1.2.5
|
|
136
147
|
|
|
137
148
|
Improvement
|
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
|
)
|
package/dist/gen/gen-csharp.js
CHANGED
|
@@ -595,6 +595,7 @@ ${strEnumClasses}
|
|
|
595
595
|
}
|
|
596
596
|
content += ` [MongoDB.Bson.Serialization.Attributes.BsonExtraElements]
|
|
597
597
|
[Newtonsoft.Json.JsonIgnore]
|
|
598
|
+
[System.Text.Json.Serialization.JsonIgnore]
|
|
598
599
|
public System.Collections.Generic.Dictionary<string, object> Mushroom_ExtraProperties { get; set; }
|
|
599
600
|
|
|
600
601
|
}
|
|
@@ -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
|
+
}
|
|
@@ -92,16 +92,16 @@ function generateTypescriptClass(objectDefination, className, options) {
|
|
|
92
92
|
childrenCode += generateTypescriptClass(field.values.items.fields ?? {}, fieldClassName, options);
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
|
-
code += ` ${fieldName}${optionalMark}: Record<string, Array<${getTypescriptTypeFromMushroomType(field.values.items?.type
|
|
95
|
+
code += ` ${fieldName}${optionalMark}: Record<string, Array<${getTypescriptTypeFromMushroomType(field.values.items?.type)}${itemNullType}>${valueNullType}>${nullType};\n`;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
|
-
code += ` ${fieldName}${optionalMark}: Record<string, ${getTypescriptTypeFromMushroomType(field.values?.type
|
|
99
|
+
code += ` ${fieldName}${optionalMark}: Record<string, ${getTypescriptTypeFromMushroomType(field.values?.type)}${valueNullType}>${nullType};\n`;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
else if (field.type == 'array') {
|
|
103
103
|
const itemNullType = options?.checkRequired &&
|
|
104
|
-
(field.items
|
|
104
|
+
(field.items?.required || field.items?.validation?.required)
|
|
105
105
|
? ''
|
|
106
106
|
: ' | null | undefined';
|
|
107
107
|
if (field.items?.type == 'object') {
|
|
@@ -121,15 +121,15 @@ function generateTypescriptClass(objectDefination, className, options) {
|
|
|
121
121
|
childrenCode += generateTypescriptClass(field.items.values.fields ?? {}, fieldClassName, options);
|
|
122
122
|
}
|
|
123
123
|
else {
|
|
124
|
-
code += ` ${fieldName}${optionalMark}: Array<Record<string, ${getTypescriptTypeFromMushroomType(field.items.type
|
|
124
|
+
code += ` ${fieldName}${optionalMark}: Array<Record<string, ${getTypescriptTypeFromMushroomType(field.items.type)}${valueNullType}>${itemNullType}>${nullType};\n`;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
128
|
-
code += ` ${fieldName}${optionalMark}: Array<${getTypescriptTypeFromMushroomType(field.items?.type
|
|
128
|
+
code += ` ${fieldName}${optionalMark}: Array<${getTypescriptTypeFromMushroomType(field.items?.type)}${itemNullType}>${nullType};\n`;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
else {
|
|
132
|
-
code += ` ${fieldName}${optionalMark}: ${getTypescriptTypeFromMushroomType(field.type
|
|
132
|
+
code += ` ${fieldName}${optionalMark}: ${getTypescriptTypeFromMushroomType(field.type)}${nullType};\n`;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
code += '}\n\n';
|
|
@@ -139,7 +139,7 @@ function generateTypescriptClassFromViewParameters(parameters) {
|
|
|
139
139
|
if (Array.isArray(parameters)) {
|
|
140
140
|
return ('{\n' +
|
|
141
141
|
parameters
|
|
142
|
-
.map((p) => `${generateDescription(p.description)} ${p.field}${p.validation?.required && p.defaultValue === undefined ? '' : '?'}: ${getTypescriptTypeFromMushroomType(p.type
|
|
142
|
+
.map((p) => `${generateDescription(p.description)} ${p.field}${p.validation?.required && p.defaultValue === undefined ? '' : '?'}: ${getTypescriptTypeFromMushroomType(p.type)}${p.isArray ? '[]' : ''}${p.validation?.required && p.defaultValue === undefined ? '' : ' | null'};`)
|
|
143
143
|
.join('\n') +
|
|
144
144
|
'\n}');
|
|
145
145
|
}
|
|
@@ -155,13 +155,13 @@ function generateTopCustomClass(config, entityName, methodName, grantRole, postf
|
|
|
155
155
|
: isArray
|
|
156
156
|
? config.items?.fields
|
|
157
157
|
: config.fields;
|
|
158
|
-
const type =
|
|
158
|
+
const type = isKeyValue
|
|
159
159
|
? isArray
|
|
160
160
|
? config.values?.items?.type
|
|
161
161
|
: config.values?.type
|
|
162
162
|
: isArray
|
|
163
163
|
? config.items?.type
|
|
164
|
-
: config.type
|
|
164
|
+
: config.type;
|
|
165
165
|
let inputClassName;
|
|
166
166
|
if (type == 'object') {
|
|
167
167
|
if (fields) {
|
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':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mushroom-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "Mushroom CLI",
|
|
5
5
|
"main": "dist/mr.js",
|
|
6
6
|
"type": "module",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"author": "suco2007",
|
|
34
34
|
"license": "ISC",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"jsdom": "^29.
|
|
36
|
+
"jsdom": "^29.1.1",
|
|
37
37
|
"json5": "^2.2.3",
|
|
38
|
-
"minify": "^15.
|
|
38
|
+
"minify": "^15.3.1",
|
|
39
39
|
"node-fetch": "^3.3.2",
|
|
40
40
|
"open": "^11.0.0",
|
|
41
41
|
"readline-sync": "^1.4.10",
|