mushroom-cli 1.2.3 → 1.2.5
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 +12 -0
- package/dist/common.js +10 -0
- package/dist/docs/docs.v2.html +22 -10
- package/dist/docs/docs.v2.js +15 -5
- package/dist/gen/gen-api-docs.js +2 -2
- package/dist/gen/gen-csharp.js +1 -11
- package/dist/gen/gen-js-driver.js +4 -4
- package/dist/gen/gen-ts-driver.js +14 -24
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -132,6 +132,18 @@ npx mushroom-cli parameters --no-check-update
|
|
|
132
132
|
|
|
133
133
|
## Version
|
|
134
134
|
|
|
135
|
+
### 1.2.5
|
|
136
|
+
|
|
137
|
+
Improvement
|
|
138
|
+
|
|
139
|
+
- gen ts-driver, js-driver: add anchors in generated code to make easier to modify code by update-ts
|
|
140
|
+
|
|
141
|
+
### 1.2.4
|
|
142
|
+
|
|
143
|
+
Improvement
|
|
144
|
+
|
|
145
|
+
- gen docs: support to gen HTTP and cURL code snippets for `requestBodyType`: `Binary` and `FormData`
|
|
146
|
+
|
|
135
147
|
### 1.2.3
|
|
136
148
|
|
|
137
149
|
Improvement
|
package/dist/common.js
CHANGED
|
@@ -282,3 +282,13 @@ export function logWarning(message, ...parameters) {
|
|
|
282
282
|
export function logError(message, ...parameters) {
|
|
283
283
|
console.error(message, ...parameters);
|
|
284
284
|
}
|
|
285
|
+
export function toVietnameseNonTongue(str) {
|
|
286
|
+
const signText = 'ăâđêôơưàảãạáằẳẵặắầẩẫậấèẻẽẹéềểễệếìỉĩịíòỏõọóồổỗộốờởỡợớùủũụúừửữựứỳỷỹỵýĂÂĐÐÊÔƠƯÀẢÃẠÁẰẲẴẶẮẦẨẪẬẤÈẺẼẸÉỀỂỄỆẾÌỈĨỊÍÒỎÕỌÓỒỔỖỘỐỜỞỠỢỚÙỦŨỤÚỪỬỮỰỨỲỶỸỴÝ';
|
|
287
|
+
const unsignedText = 'aadeoouaaaaaaaaaaaaaaaeeeeeeeeeeiiiiiooooooooooooooouuuuuuuuuuyyyyyAADDEOOUAAAAAAAAAAAAAAAEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOUUUUUUUUUUYYYYY';
|
|
288
|
+
let returnValue = '';
|
|
289
|
+
for (let i = 0; i < str.length; i++) {
|
|
290
|
+
const index = signText.indexOf(str.charAt(i));
|
|
291
|
+
returnValue += index !== -1 ? unsignedText.charAt(index) : str.charAt(i);
|
|
292
|
+
}
|
|
293
|
+
return returnValue;
|
|
294
|
+
}
|
package/dist/docs/docs.v2.html
CHANGED
|
@@ -4506,8 +4506,13 @@ API.get{{EntityName}}().deleteAsync(arg, count -> {
|
|
|
4506
4506
|
const response = await mushroom.{{entityName}}.{{httpMethod}}Async({<span style="display: {{paramDisplay}}">
|
|
4507
4507
|
params: {{paramModel:html}},</span><span style="display: {{bodyDisplay}}">
|
|
4508
4508
|
body: {{bodyModel:html}}</span>
|
|
4509
|
-
})
|
|
4510
|
-
console.log("
|
|
4509
|
+
});<span style="display: {{responseJsonDisplay}}">
|
|
4510
|
+
console.log("Dữ liệu trả về, response: %o", response);
|
|
4511
|
+
// Kết quả: response.result
|
|
4512
|
+
// Metadata: response.meta</span><span style="display: {{responseBinaryDisplay}}">
|
|
4513
|
+
const blob = response.resultAsBlob();
|
|
4514
|
+
// Hoặc có thể dùng const text = response.resultAsText() để convert blob về string
|
|
4515
|
+
// Lưu ý: dùng response.result sẽ bị lỗi nếu quá trình convert blob về string rồi parse JSON bị lỗi</span>
|
|
4511
4516
|
} catch (error) {
|
|
4512
4517
|
console.error("Có lỗi: %o", error);
|
|
4513
4518
|
}</pre>
|
|
@@ -4547,7 +4552,7 @@ catch (Exception ex)
|
|
|
4547
4552
|
Code tham khảo:
|
|
4548
4553
|
<pre data-language="http">POST {{rootUrlPath}}{{entityName}}s/{{httpMethod}}{{queryString}} HTTP/1.1
|
|
4549
4554
|
Host: <span class="domain">{{domain}}</span>
|
|
4550
|
-
Content-Type:
|
|
4555
|
+
Content-Type: {{contentType}}
|
|
4551
4556
|
X-HTTP-Method-Override: {{httpMethod}}<span style="display: {{tokenDisplay}}">
|
|
4552
4557
|
Token: your token</span>
|
|
4553
4558
|
|
|
@@ -4558,17 +4563,24 @@ Token: your token</span>
|
|
|
4558
4563
|
<div class="curl-snippet">
|
|
4559
4564
|
cURL
|
|
4560
4565
|
<pre data-language="cURL">curl -X POST \
|
|
4561
|
-
'<span class="root-url">{{rootUrl}}</span>{{entityName}}s/{{httpMethod}}{{queryString}}'
|
|
4562
|
-
-H 'Content-Type:
|
|
4566
|
+
'<span class="root-url">{{rootUrl}}</span>{{entityName}}s/{{httpMethod}}{{queryString}}' \<span style="display: {{contentTypeDisplay}}">
|
|
4567
|
+
-H 'Content-Type: {{contentType}}' \</span>
|
|
4563
4568
|
-H 'X-HTTP-Method-Override: {{httpMethod}}' \<span style="display: {{tokenDisplay}}">
|
|
4564
|
-
-H 'Token: {<span>{</span>TOKEN}}' \</span>
|
|
4565
|
-
-d '{{bodyModel:html}}'</
|
|
4569
|
+
-H 'Token: {<span>{</span>TOKEN}}' \</span><span style="display: {{bodyDisplay}}">
|
|
4570
|
+
-d '{{bodyModel:html}}'</span><span style="display: {{formDataDisplay}}">
|
|
4571
|
+
-F "field=value" \
|
|
4572
|
+
-F "file=@/path/to/file.ext"</span><span style="display: {{binaryDisplay}}">
|
|
4573
|
+
-T "/path/to/file.ext"</span></pre>
|
|
4566
4574
|
Shell
|
|
4567
4575
|
<pre data-language="cURL">curl --request POST \
|
|
4568
|
-
--url '<span class="root-url">{{rootUrl}}</span>{{entityName}}s/{{httpMethod}}{{queryString}}'
|
|
4576
|
+
--url '<span class="root-url">{{rootUrl}}</span>{{entityName}}s/{{httpMethod}}{{queryString}}' \<span style="display: {{contentTypeDisplay}}">
|
|
4577
|
+
--header 'Content-Type: {{contentType}}' \</span>
|
|
4569
4578
|
--header 'X-HTTP-Method-Override: {{httpMethod}}' \<span style="display: {{tokenDisplay}}">
|
|
4570
|
-
--header 'Token: {<span>{</span>TOKEN}}' \</span>
|
|
4571
|
-
--data '{{bodyModel:html}}'</
|
|
4579
|
+
--header 'Token: {<span>{</span>TOKEN}}' \</span><span style="display: {{bodyDisplay}}">
|
|
4580
|
+
--data '{{bodyModel:html}}'</span><span style="display: {{formDataDisplay}}">
|
|
4581
|
+
--form "field=value" \
|
|
4582
|
+
--form "file=@/path/to/file.ext"</span><span style="display: {{binaryDisplay}}">
|
|
4583
|
+
--data-binary "@/path/to/file.ext"</span></pre>
|
|
4572
4584
|
</div>
|
|
4573
4585
|
</script>
|
|
4574
4586
|
<div class="mushroom-docs-template" id="template-codeSnippets-generalAction-Java">
|
package/dist/docs/docs.v2.js
CHANGED
|
@@ -1626,10 +1626,14 @@ window.codeSnippets = {
|
|
|
1626
1626
|
renderTemplate('template-codeSnippets-generalAction-Javascript', {
|
|
1627
1627
|
entityName: args.entityName,
|
|
1628
1628
|
httpMethod: getHttpMethod(args.actionName),
|
|
1629
|
+
requestBodyType: args.action?.codeHint?.delegator?.requestBodyType,
|
|
1629
1630
|
paramDisplay: args.action?.codeHint?.delegator?.param?.fields ? 'inline' : 'none',
|
|
1630
|
-
bodyDisplay: args.action?.codeHint?.delegator?.requestBody?.fields ? 'inline' : 'none',
|
|
1631
|
-
paramModel: formatHintModel(args.action
|
|
1632
|
-
bodyModel: formatHintModel(args.action
|
|
1631
|
+
bodyDisplay: (!args.action?.codeHint?.delegator?.requestBodyType || args.action?.codeHint?.delegator?.requestBodyType === 'JSON') && args.action?.codeHint?.delegator?.requestBody?.fields || args.action?.codeHint?.delegator?.requestBodyType === 'Binary' || args.action?.codeHint?.delegator?.requestBodyType === 'FormData' ? 'inline' : 'none',
|
|
1632
|
+
paramModel: formatHintModel(args.action?.codeHint?.delegator?.param?.fields, ' ', { mode: 'model' }).trim(),
|
|
1633
|
+
bodyModel: args.action?.codeHint?.delegator?.requestBodyType === 'Binary' ? 'file' : args.action?.codeHint?.delegator?.requestBodyType === 'FormData' ? 'formData' : formatHintModel(args.action?.codeHint?.delegator?.requestBody?.fields, ' ', { mode: 'model' }).trim(),
|
|
1634
|
+
isBinaryResponse: args.action?.codeHint?.delegator?.isBinaryResponse,
|
|
1635
|
+
responseBinaryDisplay: args.action?.codeHint?.delegator?.isBinaryResponse ? 'block' : 'none',
|
|
1636
|
+
responseJsonDisplay: args.action?.codeHint?.delegator?.isBinaryResponse ? 'none' : 'block',
|
|
1633
1637
|
}),
|
|
1634
1638
|
JavascriptParamModel: (args) =>
|
|
1635
1639
|
args.action?.codeHint?.delegator?.param?.fields
|
|
@@ -1648,7 +1652,7 @@ window.codeSnippets = {
|
|
|
1648
1652
|
})
|
|
1649
1653
|
: '',
|
|
1650
1654
|
JavascriptResultModel: (args) =>
|
|
1651
|
-
args.action?.codeHint?.delegator?.result?.fields
|
|
1655
|
+
args.action?.codeHint?.delegator?.result?.fields && !args.action?.codeHint?.delegator?.isBinaryResponse
|
|
1652
1656
|
? renderTemplate('template-codeSnippets-generalAction-JavascriptModel', {
|
|
1653
1657
|
undefinedModel: formatHintModel(args.action.codeHint.delegator.result.fields, undefined, { mode: 'model_undefined' }),
|
|
1654
1658
|
valueModel: formatHintModel(args.action.codeHint.delegator.result.fields, undefined, { mode: 'model' }),
|
|
@@ -1668,7 +1672,8 @@ window.codeSnippets = {
|
|
|
1668
1672
|
entityName: args.entityName,
|
|
1669
1673
|
queryString: genQueryString(args.action.codeHint?.delegator?.param),
|
|
1670
1674
|
httpMethod: getHttpMethod(args.actionName),
|
|
1671
|
-
|
|
1675
|
+
contentType: args.action?.codeHint?.delegator?.requestBodyType === 'Binary' ? 'octet/stream' : args.action?.codeHint?.delegator?.requestBodyType === 'FormData' ? 'multipart/form-data' : 'application/json',
|
|
1676
|
+
bodyModel: args.action?.codeHint?.delegator?.requestBodyType === 'Binary' ? 'BINARY' : args.action?.codeHint?.delegator?.requestBodyType === 'FormData' ? 'FORMDATA' : formatHintModel(args.action.codeHint?.delegator?.requestBody?.fields, undefined, { mode: 'model', hideComment: true }),
|
|
1672
1677
|
tokenDisplay: args.action.grant !== '*' ? 'inline' : 'none',
|
|
1673
1678
|
}),
|
|
1674
1679
|
cURL: (args) =>
|
|
@@ -1677,7 +1682,12 @@ window.codeSnippets = {
|
|
|
1677
1682
|
entityName: args.entityName,
|
|
1678
1683
|
queryString: genQueryString(args.action.codeHint?.delegator?.param),
|
|
1679
1684
|
httpMethod: getHttpMethod(args.actionName),
|
|
1685
|
+
contentType: args.action?.codeHint?.delegator?.requestBodyType === 'Binary' ? 'octet/stream' : args.action?.codeHint?.delegator?.requestBodyType === 'FormData' ? '' : 'application/json',
|
|
1686
|
+
contentTypeDisplay: args.action?.codeHint?.delegator?.requestBodyType === 'FormData' ? 'none' : 'inline',
|
|
1687
|
+
formDataDisplay: args.action?.codeHint?.delegator?.requestBodyType === 'FormData' ? 'inline' : 'none',
|
|
1688
|
+
binaryDisplay: args.action?.codeHint?.delegator?.requestBodyType === 'Binary' ? 'inline' : 'none',
|
|
1680
1689
|
bodyModel: formatHintModel(args.action.codeHint?.delegator?.requestBody?.fields, undefined, { mode: 'model', hideComment: true }),
|
|
1690
|
+
bodyDisplay: !args.action?.codeHint?.delegator?.requestBodyType || args.action?.codeHint?.delegator?.requestBodyType === 'JSON' ? 'inline' : 'none',
|
|
1681
1691
|
tokenDisplay: args.action.grant !== '*' ? 'inline' : 'none',
|
|
1682
1692
|
}),
|
|
1683
1693
|
Java: (args) =>
|
package/dist/gen/gen-api-docs.js
CHANGED
|
@@ -48,7 +48,7 @@ const entityFeatureWhitelist = ['vn_text'];
|
|
|
48
48
|
const vnTextWhitelist = ['fields', 'channels'];
|
|
49
49
|
const vnTextChannelWhitelist = ['fields', 'name'];
|
|
50
50
|
const actionCodeHintWhitelist = ['delegator'];
|
|
51
|
-
const actionCodeHintDelegatorWhitelist = ['param', 'requestBody', 'result'];
|
|
51
|
+
const actionCodeHintDelegatorWhitelist = ['param', 'requestBodyType', 'requestBody', 'result', 'isBinaryResponse'];
|
|
52
52
|
const fieldsOnlyWhitelist = ['fields'];
|
|
53
53
|
const viewWhitelist = ['grant', 'deny', 'description', 'parameters', 'emptyResult', 'codeHint'];
|
|
54
54
|
const viewCodeHintWhitelist = ['output'];
|
|
@@ -287,7 +287,7 @@ export default async function genDocs(args, projectName, project, alias, source)
|
|
|
287
287
|
info: {
|
|
288
288
|
name: source.name,
|
|
289
289
|
rootUrl: source.codeHint?.rootUrl ?? source.rootUrl,
|
|
290
|
-
description: source.description,
|
|
290
|
+
description: source.description ?? '',
|
|
291
291
|
security: source.security === undefined
|
|
292
292
|
? undefined
|
|
293
293
|
: {
|
package/dist/gen/gen-csharp.js
CHANGED
|
@@ -23,20 +23,10 @@ function singleLine(str) {
|
|
|
23
23
|
return '';
|
|
24
24
|
return str.replace(/\r/g, '').replace(/\n/g, '<br/>');
|
|
25
25
|
}
|
|
26
|
-
function toVietnameseNonTongue(str) {
|
|
27
|
-
const signText = 'ăâđêôơưàảãạáằẳẵặắầẩẫậấèẻẽẹéềểễệếìỉĩịíòỏõọóồổỗộốờởỡợớùủũụúừửữựứỳỷỹỵýĂÂĐÐÊÔƠƯÀẢÃẠÁẰẲẴẶẮẦẨẪẬẤÈẺẼẸÉỀỂỄỆẾÌỈĨỊÍÒỎÕỌÓỒỔỖỘỐỜỞỠỢỚÙỦŨỤÚỪỬỮỰỨỲỶỸỴÝ';
|
|
28
|
-
const unsignedText = 'aadeoouaaaaaaaaaaaaaaaeeeeeeeeeeiiiiiooooooooooooooouuuuuuuuuuyyyyyAADDEOOUAAAAAAAAAAAAAAAEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOUUUUUUUUUUYYYYY';
|
|
29
|
-
let returnValue = '';
|
|
30
|
-
for (let i = 0; i < str.length; i++) {
|
|
31
|
-
const index = signText.indexOf(str.charAt(i));
|
|
32
|
-
returnValue += index !== -1 ? unsignedText.charAt(index) : str.charAt(i);
|
|
33
|
-
}
|
|
34
|
-
return returnValue;
|
|
35
|
-
}
|
|
36
26
|
function toCSharpName(str) {
|
|
37
27
|
if (!str)
|
|
38
28
|
return '_';
|
|
39
|
-
const name = toVietnameseNonTongue(str).replace(/\W/g, '_');
|
|
29
|
+
const name = common.toVietnameseNonTongue(str).replace(/\W/g, '_');
|
|
40
30
|
const c = name.charAt(0);
|
|
41
31
|
return ('0' <= c && c <= '9' ? '_' : '') + c.toUpperCase() + name.substring(1);
|
|
42
32
|
}
|
|
@@ -23,9 +23,9 @@ export function genJavascriptDriverString(aliasProject, source) {
|
|
|
23
23
|
return '';
|
|
24
24
|
}
|
|
25
25
|
const entities = common.getEntities(source, aliasProject.allowRoles);
|
|
26
|
-
const extensionsImportLines = [];
|
|
27
|
-
const extensionsExportLines = [];
|
|
28
|
-
const extensionsCodeLines = [];
|
|
26
|
+
const extensionsImportLines = ['/* import all mushroom extensions */'];
|
|
27
|
+
const extensionsExportLines = ['/* export all mushroom extensions */'];
|
|
28
|
+
const extensionsCodeLines = ['/* using all mushroom extensions */'];
|
|
29
29
|
if (Array.isArray(aliasProject.features)) {
|
|
30
30
|
if (aliasProject.features.includes('auth')) {
|
|
31
31
|
extensionsImportLines.push('//import * as AuthExtension from "mushroomjs-auth";');
|
|
@@ -94,7 +94,7 @@ exports.extensions = extensions;
|
|
|
94
94
|
for (const viewName in entity.views) {
|
|
95
95
|
views[viewName] = {};
|
|
96
96
|
}
|
|
97
|
-
code += `defineAsyncResource({name:${JSON.stringify(entityName)},actions:${JSON.stringify(actions)},views:${JSON.stringify(views)}});
|
|
97
|
+
code += `defineAsyncResource({name:${JSON.stringify(entityName)},actions:${JSON.stringify(actions)},views:${JSON.stringify(views)}}, mushroom);
|
|
98
98
|
`;
|
|
99
99
|
}
|
|
100
100
|
code += `
|
|
@@ -17,24 +17,14 @@ function isAllowCache(actions, defaultValue) {
|
|
|
17
17
|
}
|
|
18
18
|
return result;
|
|
19
19
|
}
|
|
20
|
-
function toVietnameseNonTongue(str) {
|
|
21
|
-
const signText = 'ăâđêôơưàảãạáằẳẵặắầẩẫậấèẻẽẹéềểễệếìỉĩịíòỏõọóồổỗộốờởỡợớùủũụúừửữựứỳỷỹỵýĂÂĐÐÊÔƠƯÀẢÃẠÁẰẲẴẶẮẦẨẪẬẤÈẺẼẸÉỀỂỄỆẾÌỈĨỊÍÒỎÕỌÓỒỔỖỘỐỜỞỠỢỚÙỦŨỤÚỪỬỮỰỨỲỶỸỴÝ';
|
|
22
|
-
const unsignedText = 'aadeoouaaaaaaaaaaaaaaaeeeeeeeeeeiiiiiooooooooooooooouuuuuuuuuuyyyyyAADDEOOUAAAAAAAAAAAAAAAEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOUUUUUUUUUUYYYYY';
|
|
23
|
-
let returnValue = '';
|
|
24
|
-
for (let i = 0; i < str.length; i++) {
|
|
25
|
-
const index = signText.indexOf(str.charAt(i));
|
|
26
|
-
returnValue += index !== -1 ? unsignedText.charAt(index) : str.charAt(i);
|
|
27
|
-
}
|
|
28
|
-
return returnValue;
|
|
29
|
-
}
|
|
30
20
|
function toTypeScriptClassName(str) {
|
|
31
21
|
if (!str)
|
|
32
22
|
return '_';
|
|
33
|
-
const name = toVietnameseNonTongue(str).replace(/\W/g, '_');
|
|
23
|
+
const name = common.toVietnameseNonTongue(str).replace(/\W/g, '_');
|
|
34
24
|
const c = name.charAt(0);
|
|
35
25
|
return ('0' <= c && c <= '9' ? '_' : '') + c.toUpperCase() + name.substring(1);
|
|
36
26
|
}
|
|
37
|
-
function
|
|
27
|
+
function getTypescriptTypeFromMushroomType(type) {
|
|
38
28
|
switch (type) {
|
|
39
29
|
case 'string':
|
|
40
30
|
return 'string';
|
|
@@ -102,11 +92,11 @@ function generateTypescriptClass(objectDefination, className, options) {
|
|
|
102
92
|
childrenCode += generateTypescriptClass(field.values.items.fields ?? {}, fieldClassName, options);
|
|
103
93
|
}
|
|
104
94
|
else {
|
|
105
|
-
code += ` ${fieldName}${optionalMark}: Record<string, Array<${
|
|
95
|
+
code += ` ${fieldName}${optionalMark}: Record<string, Array<${getTypescriptTypeFromMushroomType(field.values.items?.type ?? 'string')}${itemNullType}>${valueNullType}>${nullType};\n`;
|
|
106
96
|
}
|
|
107
97
|
}
|
|
108
98
|
else {
|
|
109
|
-
code += ` ${fieldName}${optionalMark}: Record<string, ${
|
|
99
|
+
code += ` ${fieldName}${optionalMark}: Record<string, ${getTypescriptTypeFromMushroomType(field.values?.type ?? 'string')}${valueNullType}>${nullType};\n`;
|
|
110
100
|
}
|
|
111
101
|
}
|
|
112
102
|
else if (field.type == 'array') {
|
|
@@ -131,15 +121,15 @@ function generateTypescriptClass(objectDefination, className, options) {
|
|
|
131
121
|
childrenCode += generateTypescriptClass(field.items.values.fields ?? {}, fieldClassName, options);
|
|
132
122
|
}
|
|
133
123
|
else {
|
|
134
|
-
code += ` ${fieldName}${optionalMark}: Array<Record<string, ${
|
|
124
|
+
code += ` ${fieldName}${optionalMark}: Array<Record<string, ${getTypescriptTypeFromMushroomType(field.items.type ?? 'string')}${valueNullType}>${itemNullType}>${nullType};\n`;
|
|
135
125
|
}
|
|
136
126
|
}
|
|
137
127
|
else {
|
|
138
|
-
code += ` ${fieldName}${optionalMark}: Array<${
|
|
128
|
+
code += ` ${fieldName}${optionalMark}: Array<${getTypescriptTypeFromMushroomType(field.items?.type ?? 'string')}${itemNullType}>${nullType};\n`;
|
|
139
129
|
}
|
|
140
130
|
}
|
|
141
131
|
else {
|
|
142
|
-
code += ` ${fieldName}${optionalMark}: ${
|
|
132
|
+
code += ` ${fieldName}${optionalMark}: ${getTypescriptTypeFromMushroomType(field.type ?? 'string')}${nullType};\n`;
|
|
143
133
|
}
|
|
144
134
|
}
|
|
145
135
|
code += '}\n\n';
|
|
@@ -149,7 +139,7 @@ function generateTypescriptClassFromViewParameters(parameters) {
|
|
|
149
139
|
if (Array.isArray(parameters)) {
|
|
150
140
|
return ('{\n' +
|
|
151
141
|
parameters
|
|
152
|
-
.map((p) => `${generateDescription(p.description)} ${p.field}${p.validation?.required && p.defaultValue === undefined ? '' : '?'}: ${
|
|
142
|
+
.map((p) => `${generateDescription(p.description)} ${p.field}${p.validation?.required && p.defaultValue === undefined ? '' : '?'}: ${getTypescriptTypeFromMushroomType(p.type || 'string')}${p.isArray ? '[]' : ''}${p.validation?.required && p.defaultValue === undefined ? '' : ' | null'};`)
|
|
153
143
|
.join('\n') +
|
|
154
144
|
'\n}');
|
|
155
145
|
}
|
|
@@ -186,7 +176,7 @@ function generateTopCustomClass(config, entityName, methodName, grantRole, postf
|
|
|
186
176
|
}
|
|
187
177
|
}
|
|
188
178
|
else
|
|
189
|
-
inputClassName =
|
|
179
|
+
inputClassName = getTypescriptTypeFromMushroomType(type);
|
|
190
180
|
return isKeyValue
|
|
191
181
|
? isArray
|
|
192
182
|
? 'Record<string, ' + inputClassName + '[]>'
|
|
@@ -241,10 +231,10 @@ export function genTypescriptDriverString(aliasProject, source) {
|
|
|
241
231
|
return '';
|
|
242
232
|
}
|
|
243
233
|
const entities = common.getEntities(source, aliasProject.allowRoles);
|
|
244
|
-
const extensionsImportLines = [];
|
|
245
|
-
const extensionsExportLines = [];
|
|
246
|
-
const extensionsTypes = [];
|
|
247
|
-
const extensionsCodeLines = [];
|
|
234
|
+
const extensionsImportLines = ['/* import all mushroom extensions */'];
|
|
235
|
+
const extensionsExportLines = ['/* export all mushroom extensions */'];
|
|
236
|
+
const extensionsTypes = ['/* all mushroom extensions types */'];
|
|
237
|
+
const extensionsCodeLines = ['/* using all mushroom extensions */'];
|
|
248
238
|
if (Array.isArray(aliasProject.features)) {
|
|
249
239
|
if (aliasProject.features.includes('auth')) {
|
|
250
240
|
extensionsImportLines.push('import * as AuthExtension from "mushroomjs-auth";');
|
|
@@ -404,7 +394,7 @@ export interface CustomMethodBodyRequest<TBody> extends MushroomRequest {
|
|
|
404
394
|
}
|
|
405
395
|
iApiClassBody += `,
|
|
406
396
|
`;
|
|
407
|
-
code += `defineAsyncResource<${typescriptClassName}>(${JSON.stringify({ name: entityName, actions: actions, views: views })});
|
|
397
|
+
code += `defineAsyncResource<${typescriptClassName}>(${JSON.stringify({ name: entityName, actions: actions, views: views })}, mushroom);
|
|
408
398
|
|
|
409
399
|
`;
|
|
410
400
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mushroom-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
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": "^
|
|
36
|
+
"jsdom": "^29.0.2",
|
|
37
37
|
"json5": "^2.2.3",
|
|
38
|
-
"minify": "^
|
|
38
|
+
"minify": "^15.2.1",
|
|
39
39
|
"node-fetch": "^3.3.2",
|
|
40
40
|
"open": "^11.0.0",
|
|
41
41
|
"readline-sync": "^1.4.10",
|