mushroom-cli 1.2.0-alpha.16 → 1.2.0-alpha.18
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 +6 -0
- package/dist/gen/gen-ts-driver.js +10 -11
- package/package.json +22 -12
package/README.md
CHANGED
|
@@ -60,23 +60,24 @@ function generateTypescriptClass(objectDefination, className, options) {
|
|
|
60
60
|
let code = `export interface ${className} {\n`;
|
|
61
61
|
for (const fieldName in objectDefination) {
|
|
62
62
|
const optionalMark = options?.checkRequired && objectDefination[fieldName].required ? '' : '?';
|
|
63
|
+
const nullType = optionalMark ? ' | null' : '';
|
|
63
64
|
if (objectDefination[fieldName].type == 'object') {
|
|
64
65
|
const fieldClassName = className + '_' + toTypeScriptClassName(fieldName);
|
|
65
|
-
code += ` ${fieldName}${optionalMark}: ${fieldClassName}
|
|
66
|
+
code += ` ${fieldName}${optionalMark}: ${fieldClassName}${nullType};\n`;
|
|
66
67
|
childrenCode += generateTypescriptClass(objectDefination[fieldName].fields ?? {}, fieldClassName);
|
|
67
68
|
}
|
|
68
69
|
else if (objectDefination[fieldName].type == 'array') {
|
|
69
70
|
if (objectDefination[fieldName].items?.type == 'object') {
|
|
70
71
|
const fieldClassName = className + '_' + toTypeScriptClassName(fieldName);
|
|
71
|
-
code += ` ${fieldName}${optionalMark}: ${fieldClassName}[]
|
|
72
|
+
code += ` ${fieldName}${optionalMark}: ${fieldClassName}[]${nullType};\n`;
|
|
72
73
|
childrenCode += generateTypescriptClass(objectDefination[fieldName].items?.fields ?? {}, fieldClassName);
|
|
73
74
|
}
|
|
74
75
|
else {
|
|
75
|
-
code += ` ${fieldName}${optionalMark}: ${getCSharpTypeFromMushroomType(objectDefination[fieldName].items?.type ?? '')}[]
|
|
76
|
+
code += ` ${fieldName}${optionalMark}: ${getCSharpTypeFromMushroomType(objectDefination[fieldName].items?.type ?? '')}[]${nullType};\n`;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
else {
|
|
79
|
-
code += ` ${fieldName}${optionalMark}: ${getCSharpTypeFromMushroomType(objectDefination[fieldName].type)}
|
|
80
|
+
code += ` ${fieldName}${optionalMark}: ${getCSharpTypeFromMushroomType(objectDefination[fieldName].type)}${nullType};\n`;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
code += '}\n\n';
|
|
@@ -86,8 +87,8 @@ function generateTypescriptClassFromViewParameters(parameters) {
|
|
|
86
87
|
if (Array.isArray(parameters)) {
|
|
87
88
|
return ('{\n' +
|
|
88
89
|
parameters
|
|
89
|
-
.map((p) => ` ${p.field}${p.validation?.required && p.defaultValue === undefined ? '' : '?'}: ${getCSharpTypeFromMushroomType(p.type || 'string')}${p.isArray ? '[]' : ''}
|
|
90
|
-
.join('
|
|
90
|
+
.map((p) => ` ${p.field}${p.validation?.required && p.defaultValue === undefined ? '' : '?'}: ${getCSharpTypeFromMushroomType(p.type || 'string')}${p.isArray ? '[]' : ''}${p.validation?.required && p.defaultValue === undefined ? '' : ' | null'};`)
|
|
91
|
+
.join('\n') +
|
|
91
92
|
'\n}');
|
|
92
93
|
}
|
|
93
94
|
return '{}';
|
|
@@ -193,8 +194,7 @@ export type IdValue = ${source.idType == 'AutoIncInt' || source.idType == 'AutoI
|
|
|
193
194
|
}
|
|
194
195
|
default: {
|
|
195
196
|
if (actionName.indexOf('_raw_http_method_') === 0) {
|
|
196
|
-
customMethodCode += ` ${actionName.substring('_raw_http_method_'.length)}Async: (rawRequest: MushroomRequest) => Promise<MushroomResponse<any
|
|
197
|
-
`;
|
|
197
|
+
customMethodCode += ` ${actionName.substring('_raw_http_method_'.length)}Async: (rawRequest: MushroomRequest) => Promise<MushroomResponse<any>>;\n`;
|
|
198
198
|
break;
|
|
199
199
|
}
|
|
200
200
|
else {
|
|
@@ -229,7 +229,7 @@ ${customMethodCode}}
|
|
|
229
229
|
return `MushroomViewFunction<${outputType}, ${inputType}>`;
|
|
230
230
|
});
|
|
231
231
|
viewCode += `
|
|
232
|
-
${viewName}Async: ${viewParameterTypes.join(' | ')}
|
|
232
|
+
${viewName}Async: ${viewParameterTypes.join(' | ')};`;
|
|
233
233
|
}
|
|
234
234
|
if (viewCode) {
|
|
235
235
|
code += `export interface ${typescriptClassName}$ViewsResource {
|
|
@@ -358,8 +358,7 @@ export declare type IdValue = ${source.idType == 'AutoIncInt' || source.idType =
|
|
|
358
358
|
}
|
|
359
359
|
default: {
|
|
360
360
|
if (actionName.indexOf('_raw_http_method_') === 0) {
|
|
361
|
-
customMethodCode += ` ${actionName.substring('_raw_http_method_'.length)}Async: (rawRequest: MushroomRequest) => Promise<MushroomResponse<any
|
|
362
|
-
`;
|
|
361
|
+
customMethodCode += ` ${actionName.substring('_raw_http_method_'.length)}Async: (rawRequest: MushroomRequest) => Promise<MushroomResponse<any>>;\n`;
|
|
363
362
|
break;
|
|
364
363
|
}
|
|
365
364
|
else {
|
package/package.json
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mushroom-cli",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.18",
|
|
4
4
|
"description": "Mushroom CLI",
|
|
5
5
|
"main": "dist/mr.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc && copyfiles -u 2 ./src/docs/* ./dist/docs/",
|
|
9
|
-
"format": "prettier --write
|
|
10
|
-
"lint": "eslint ./src",
|
|
9
|
+
"format": "prettier --write **/*",
|
|
10
|
+
"lint": "eslint ./src/**/*.ts",
|
|
11
11
|
"release": "npm run build && npm publish --access public --tag alpha",
|
|
12
|
-
"
|
|
12
|
+
"preinstall": "npx only-allow npm",
|
|
13
|
+
"prepare": "husky"
|
|
14
|
+
},
|
|
15
|
+
"lint-staged": {
|
|
16
|
+
"!(*.ts)": "prettier --write --ignore-unknown",
|
|
17
|
+
"src/**/*.ts": [
|
|
18
|
+
"eslint --quiet",
|
|
19
|
+
"prettier --write"
|
|
20
|
+
]
|
|
13
21
|
},
|
|
14
22
|
"files": [
|
|
15
23
|
"dist"
|
|
@@ -25,28 +33,30 @@
|
|
|
25
33
|
"author": "suco2007",
|
|
26
34
|
"license": "ISC",
|
|
27
35
|
"dependencies": {
|
|
28
|
-
"jsdom": "^25.0.
|
|
36
|
+
"jsdom": "^25.0.1",
|
|
29
37
|
"json5": "^2.2.3",
|
|
30
|
-
"minify": "^11.4.
|
|
38
|
+
"minify": "^11.4.1",
|
|
31
39
|
"node-fetch": "^3.3.2",
|
|
32
40
|
"open": "^10.1.0",
|
|
33
41
|
"readline-sync": "^1.4.10",
|
|
34
42
|
"targz": "^1.0.1"
|
|
35
43
|
},
|
|
36
44
|
"devDependencies": {
|
|
37
|
-
"@eslint/js": "^9.
|
|
45
|
+
"@eslint/js": "^9.11.1",
|
|
38
46
|
"@types/jsdom": "^21.1.7",
|
|
39
47
|
"@types/minify": "^9.1.4",
|
|
40
|
-
"@types/node": "^22.
|
|
48
|
+
"@types/node": "^22.7.4",
|
|
41
49
|
"@types/node-fetch": "^2.6.11",
|
|
42
50
|
"@types/readline-sync": "^1.4.8",
|
|
43
51
|
"@types/targz": "^1.0.4",
|
|
44
52
|
"copyfiles": "^2.4.1",
|
|
45
|
-
"eslint": "^9.
|
|
46
|
-
"husky": "^
|
|
53
|
+
"eslint": "^9.11.1",
|
|
54
|
+
"husky": "^9.1.6",
|
|
55
|
+
"lint-staged": "^15.2.10",
|
|
56
|
+
"only-allow": "^1.2.1",
|
|
47
57
|
"prettier": "^3.3.3",
|
|
48
|
-
"typescript": "^5.
|
|
49
|
-
"typescript-eslint": "^8.
|
|
58
|
+
"typescript": "^5.6.2",
|
|
59
|
+
"typescript-eslint": "^8.8.0"
|
|
50
60
|
},
|
|
51
61
|
"engines": {
|
|
52
62
|
"node": ">=14.0.0"
|