mushroom-cli 1.2.0-alpha.10 → 1.2.0-alpha.11
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/common.js +11 -1
- package/docs/docs.v2.html +154 -125
- package/docs/docs.v2.js +104 -34
- package/gen/gen-api-docs.js +1 -1
- package/gen/gen-ts-driver.js +21 -25
- package/package.json +2 -2
package/docs/docs.v2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function toCSharpName(str) {
|
|
2
2
|
if (typeof str != "string" || str === "") return "";
|
|
3
3
|
const name = str.replace(/\W/g, "_");
|
|
4
|
-
return name.charAt(0).toUpperCase() + name.
|
|
4
|
+
return name.charAt(0).toUpperCase() + name.substring(1);
|
|
5
5
|
}
|
|
6
6
|
function encodeHtml(data) {
|
|
7
7
|
if (data === undefined || data === null)
|
|
@@ -34,7 +34,7 @@ function getApiDomain(url) {
|
|
|
34
34
|
}
|
|
35
35
|
function getApiPath(url) {
|
|
36
36
|
const m = url.match(/^(\w+:)?\/\/([\w-]+\.)+\w+(:\d+)?/);
|
|
37
|
-
return m ? url.
|
|
37
|
+
return m ? url.substring(m[0].length) : url;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function getPanelClass(actionName) {
|
|
@@ -75,7 +75,7 @@ function getHttpMethod(actionName) {
|
|
|
75
75
|
return "DELETE";
|
|
76
76
|
default:
|
|
77
77
|
if (actionName && actionName.indexOf("_raw_http_method_") !== -1)
|
|
78
|
-
return actionName.
|
|
78
|
+
return actionName.substring("_raw_http_method_".length);
|
|
79
79
|
return "UNKNOWN(" + actionName + ")";
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -94,7 +94,7 @@ function getApiUrl(actionName, rootUrl, entityName) {
|
|
|
94
94
|
return rootUrl + entityName + "s/{" + entityName + "Id}";
|
|
95
95
|
default:
|
|
96
96
|
if (actionName && actionName.indexOf("_raw_http_method_") !== -1)
|
|
97
|
-
return rootUrl + entityName + "s/" + actionName.
|
|
97
|
+
return rootUrl + entityName + "s/" + actionName.substring("_raw_http_method_".length);
|
|
98
98
|
return "UNKNOWN(" + actionName + ")";
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -481,10 +481,9 @@ function formatHintModel(obj, strIndent, options) {
|
|
|
481
481
|
|
|
482
482
|
function renderInfo() {
|
|
483
483
|
document.title = document.querySelector("#project-title").innerText = window.docs.info.name + " API document";
|
|
484
|
-
document.querySelector("#project-rootUrl").innerText = window.docs.info.rootUrl;
|
|
485
484
|
document.querySelector("#project-description").innerText = window.docs.info.description;
|
|
486
485
|
|
|
487
|
-
document.querySelector("#project-roles").innerHTML = window.docs.roles.map(role => renderTemplate("template-project-role", role)).join("");
|
|
486
|
+
document.querySelector("#project-roles").innerHTML = window.docs.roles.map(role => renderTemplate("template-project-role", role)).join("") ?? "";
|
|
488
487
|
|
|
489
488
|
if (window.docs.info.security?.crossDomain === false) {
|
|
490
489
|
document.querySelector("#project-security-crossDomain-false").style.display = "block";
|
|
@@ -493,6 +492,77 @@ function renderInfo() {
|
|
|
493
492
|
document.querySelector("#project-security-allowOrigins").style.display = "block";
|
|
494
493
|
document.querySelector("#project-security-allowOrigins ul").innerHTML = window.docs.info.security.allowOrigins.map(origin => renderTemplate("template-li-code", {value: origin})).join("");
|
|
495
494
|
}
|
|
495
|
+
|
|
496
|
+
const domRootUrls = document.querySelector("#project-rootUrls");
|
|
497
|
+
const rootUrls = Object.keys(localStorage)
|
|
498
|
+
.filter(key => localStorage.hasOwnProperty(key) && key.startsWith("rootUrl."))
|
|
499
|
+
.map(key => key.substring(8));
|
|
500
|
+
if (!rootUrls.includes(window.docs.info.rootUrl)) rootUrls.unshift(window.docs.info.rootUrl);
|
|
501
|
+
|
|
502
|
+
let selected = localStorage.selected_root_url;
|
|
503
|
+
if (!selected) selected = localStorage.selected_root_url = window.docs.info.rootUrl;
|
|
504
|
+
const onspanclick = function() {
|
|
505
|
+
this.parentNode.parentNode.querySelector(".selected").className = "";
|
|
506
|
+
selected = this.innerText;
|
|
507
|
+
this.className = "selected";
|
|
508
|
+
const old_root_url = localStorage.selected_root_url;
|
|
509
|
+
const new_root_url = this.innerText;
|
|
510
|
+
localStorage.selected_root_url = new_root_url;
|
|
511
|
+
document.querySelectorAll(".contain-root-url").forEach(dom => dom.innerHTML = dom.innerHTML.replace(old_root_url, new_root_url));
|
|
512
|
+
document.querySelectorAll(".root-url").forEach(dom => dom.innerText = new_root_url);
|
|
513
|
+
document.querySelectorAll(".domain").forEach(dom => dom.innerText = getApiDomain(new_root_url))
|
|
514
|
+
};
|
|
515
|
+
const onlabelclick = function() {
|
|
516
|
+
const span = this.parentNode.querySelector("span");
|
|
517
|
+
if (span.className == "selected") return;
|
|
518
|
+
|
|
519
|
+
const rootUrl = span.innerText;
|
|
520
|
+
const index = rootUrls.indexOf(rootUrl);
|
|
521
|
+
if (index !== -1) rootUrls.splice(index, 1);
|
|
522
|
+
|
|
523
|
+
localStorage.removeItem(`rootUrl.${rootUrl}`);
|
|
524
|
+
|
|
525
|
+
this.parentNode.remove();
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
const addRootUrlDom = (rootUrl, liAddNew) => {
|
|
529
|
+
const li = document.createElement("li");
|
|
530
|
+
if (rootUrl == window.docs.info.rootUrl) li.className = "origin";
|
|
531
|
+
const span = document.createElement("span");
|
|
532
|
+
span.innerText = rootUrl;
|
|
533
|
+
if (rootUrl == selected) span.className = "selected";
|
|
534
|
+
li.appendChild(span);
|
|
535
|
+
const label = document.createElement("label");
|
|
536
|
+
label.className = "delete";
|
|
537
|
+
label.title = "Xóa";
|
|
538
|
+
li.appendChild(label);
|
|
539
|
+
domRootUrls.insertBefore(li, liAddNew);
|
|
540
|
+
span.onclick = onspanclick;
|
|
541
|
+
label.onclick = onlabelclick;
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
const li = document.createElement("li");
|
|
545
|
+
const span = document.createElement("span");
|
|
546
|
+
span.innerText = "Thêm mới API root url";
|
|
547
|
+
span.className = "add-new";
|
|
548
|
+
li.appendChild(span);
|
|
549
|
+
domRootUrls.appendChild(li);
|
|
550
|
+
|
|
551
|
+
rootUrls.forEach(rootUrl => addRootUrlDom(rootUrl, li));
|
|
552
|
+
span.onclick = () => {
|
|
553
|
+
const newRootUrl = prompt("Nhập API root url mới:");
|
|
554
|
+
if (!newRootUrl) return;
|
|
555
|
+
if (rootUrls.includes(newRootUrl)) return;
|
|
556
|
+
|
|
557
|
+
if (!newRootUrl.match(/^(https?:)?\/\//i)) {
|
|
558
|
+
alert("API root url không hợp lệ!");
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
rootUrls.push(newRootUrl);
|
|
563
|
+
localStorage[`rootUrl.${newRootUrl}`] = "";
|
|
564
|
+
addRootUrlDom(newRootUrl, li);
|
|
565
|
+
};
|
|
496
566
|
}
|
|
497
567
|
|
|
498
568
|
function renderEnvironmentVariables() {
|
|
@@ -511,27 +581,27 @@ function renderEnvironmentVariables() {
|
|
|
511
581
|
function renderExtensionAuth() {
|
|
512
582
|
if (!window.docs.features?.includes("auth")) return;
|
|
513
583
|
document.querySelector("#extension-auth").innerHTML = renderTemplate("template-extension-DefaultAuth-module", {
|
|
514
|
-
rootUrl:
|
|
515
|
-
rootUrlPath: getApiPath(
|
|
516
|
-
domain: getApiDomain(
|
|
584
|
+
rootUrl: localStorage.selected_root_url,
|
|
585
|
+
rootUrlPath: getApiPath(localStorage.selected_root_url),
|
|
586
|
+
domain: getApiDomain(localStorage.selected_root_url)
|
|
517
587
|
});
|
|
518
588
|
}
|
|
519
589
|
|
|
520
590
|
function renderExtensionFile() {
|
|
521
591
|
if (!window.docs.features?.includes("file")) return;
|
|
522
592
|
document.querySelector("#extension-file").innerHTML = renderTemplate("template-extension-File-module", {
|
|
523
|
-
rootUrl:
|
|
524
|
-
rootUrlPath: getApiPath(
|
|
525
|
-
domain: getApiDomain(
|
|
593
|
+
rootUrl: localStorage.selected_root_url,
|
|
594
|
+
rootUrlPath: getApiPath(localStorage.selected_root_url),
|
|
595
|
+
domain: getApiDomain(localStorage.selected_root_url)
|
|
526
596
|
});
|
|
527
597
|
}
|
|
528
598
|
|
|
529
599
|
function renderExtensionMail() {
|
|
530
600
|
if (!window.docs.features?.includes("mail")) return;
|
|
531
601
|
document.querySelector("#extension-mailing").innerHTML = renderTemplate("template-extension-Mailing-module", {
|
|
532
|
-
rootUrl:
|
|
533
|
-
rootUrlPath: getApiPath(
|
|
534
|
-
domain: getApiDomain(
|
|
602
|
+
rootUrl: localStorage.selected_root_url,
|
|
603
|
+
rootUrlPath: getApiPath(localStorage.selected_root_url),
|
|
604
|
+
domain: getApiDomain(localStorage.selected_root_url)
|
|
535
605
|
});
|
|
536
606
|
}
|
|
537
607
|
|
|
@@ -557,7 +627,7 @@ function renderEntity(entityName) {
|
|
|
557
627
|
actionName,
|
|
558
628
|
className: getPanelClass(actionName),
|
|
559
629
|
actionHttpMethod: getHttpMethod(actionName),
|
|
560
|
-
actionApiUrl: getApiUrl(actionName,
|
|
630
|
+
actionApiUrl: getApiUrl(actionName, localStorage.selected_root_url, entity.name),
|
|
561
631
|
actionDescription: getDescriptionByActionName(actionName, entity.name)
|
|
562
632
|
})).join("");
|
|
563
633
|
initDom(dom);
|
|
@@ -568,7 +638,7 @@ function renderEntity(entityName) {
|
|
|
568
638
|
dom.innerHTML = Object.keys(entity.views).map(viewName => renderTemplate("template-project-entity-views", {
|
|
569
639
|
entityName: entity.name,
|
|
570
640
|
viewName,
|
|
571
|
-
actionApiUrl: getApiViewUrl(
|
|
641
|
+
actionApiUrl: getApiViewUrl(localStorage.selected_root_url, entity.name, viewName),
|
|
572
642
|
description: entity.views[viewName]?.[0]?.description ?? ""
|
|
573
643
|
})).join("");
|
|
574
644
|
initDom(dom);
|
|
@@ -661,8 +731,8 @@ function renderEntityActionRolePage(entityName, actionName, grant) {
|
|
|
661
731
|
entity,
|
|
662
732
|
entityName,
|
|
663
733
|
EntityName: toCSharpName(entityName),
|
|
664
|
-
domain: getApiDomain(
|
|
665
|
-
rootUrlPath: getApiPath(
|
|
734
|
+
domain: getApiDomain(localStorage.selected_root_url),
|
|
735
|
+
rootUrlPath: getApiPath(localStorage.selected_root_url),
|
|
666
736
|
};
|
|
667
737
|
const snippet = window.codeSnippets[codeSnippetName] ?? {};
|
|
668
738
|
const data = {
|
|
@@ -915,8 +985,8 @@ function renderEntityViewRolePage(entityName, viewName, grant) {
|
|
|
915
985
|
entity,
|
|
916
986
|
entityName,
|
|
917
987
|
EntityName: toCSharpName(entityName),
|
|
918
|
-
domain: getApiDomain(
|
|
919
|
-
rootUrlPath: getApiPath(
|
|
988
|
+
domain: getApiDomain(localStorage.selected_root_url),
|
|
989
|
+
rootUrlPath: getApiPath(localStorage.selected_root_url),
|
|
920
990
|
};
|
|
921
991
|
const snippet = window.codeSnippets.view;
|
|
922
992
|
const data = {
|
|
@@ -1000,7 +1070,7 @@ window.codeSnippets = {
|
|
|
1000
1070
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none',
|
|
1001
1071
|
}),
|
|
1002
1072
|
cURL: (args) => renderTemplate("template-codeSnippets-findMany-cURL", {
|
|
1003
|
-
rootUrl:
|
|
1073
|
+
rootUrl: localStorage.selected_root_url,
|
|
1004
1074
|
entityName: args.entityName,
|
|
1005
1075
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none',
|
|
1006
1076
|
fields: args.action.returnableFields?.map(fieldName => renderTemplate("template-fields-inline", {fieldName})).join(""),
|
|
@@ -1047,7 +1117,7 @@ window.codeSnippets = {
|
|
|
1047
1117
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1048
1118
|
}),
|
|
1049
1119
|
cURL: (args) => renderTemplate("template-codeSnippets-findById-cURL", {
|
|
1050
|
-
rootUrl:
|
|
1120
|
+
rootUrl: localStorage.selected_root_url,
|
|
1051
1121
|
entityName: args.entityName,
|
|
1052
1122
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none',
|
|
1053
1123
|
fields: args.action.returnableFields?.map(fieldName => renderTemplate("template-fields-inline", {fieldName})).join("")
|
|
@@ -1083,7 +1153,7 @@ window.codeSnippets = {
|
|
|
1083
1153
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1084
1154
|
}),
|
|
1085
1155
|
cURL: (args) => renderTemplate("template-codeSnippets-createOne-cURL", {
|
|
1086
|
-
rootUrl:
|
|
1156
|
+
rootUrl: localStorage.selected_root_url,
|
|
1087
1157
|
entityName: args.entityName,
|
|
1088
1158
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1089
1159
|
}),
|
|
@@ -1116,7 +1186,7 @@ window.codeSnippets = {
|
|
|
1116
1186
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1117
1187
|
}),
|
|
1118
1188
|
cURL: (args) => renderTemplate("template-codeSnippets-createMany-cURL", {
|
|
1119
|
-
rootUrl:
|
|
1189
|
+
rootUrl: localStorage.selected_root_url,
|
|
1120
1190
|
entityName: args.entityName,
|
|
1121
1191
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1122
1192
|
}),
|
|
@@ -1149,7 +1219,7 @@ window.codeSnippets = {
|
|
|
1149
1219
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1150
1220
|
}),
|
|
1151
1221
|
cURL: (args) => renderTemplate("template-codeSnippets-updateOne-cURL", {
|
|
1152
|
-
rootUrl:
|
|
1222
|
+
rootUrl: localStorage.selected_root_url,
|
|
1153
1223
|
entityName: args.entityName,
|
|
1154
1224
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1155
1225
|
}),
|
|
@@ -1182,7 +1252,7 @@ window.codeSnippets = {
|
|
|
1182
1252
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1183
1253
|
}),
|
|
1184
1254
|
cURL: (args) => renderTemplate("template-codeSnippets-updateMany-cURL", {
|
|
1185
|
-
rootUrl:
|
|
1255
|
+
rootUrl: localStorage.selected_root_url,
|
|
1186
1256
|
entityName: args.entityName,
|
|
1187
1257
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1188
1258
|
}),
|
|
@@ -1215,7 +1285,7 @@ window.codeSnippets = {
|
|
|
1215
1285
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1216
1286
|
}),
|
|
1217
1287
|
cURL: (args) => renderTemplate("template-codeSnippets-updatePartially-cURL", {
|
|
1218
|
-
rootUrl:
|
|
1288
|
+
rootUrl: localStorage.selected_root_url,
|
|
1219
1289
|
entityName: args.entityName,
|
|
1220
1290
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1221
1291
|
}),
|
|
@@ -1243,7 +1313,7 @@ window.codeSnippets = {
|
|
|
1243
1313
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1244
1314
|
}),
|
|
1245
1315
|
cURL: (args) => renderTemplate("template-codeSnippets-deleteOne-cURL", {
|
|
1246
|
-
rootUrl:
|
|
1316
|
+
rootUrl: localStorage.selected_root_url,
|
|
1247
1317
|
entityName: args.entityName,
|
|
1248
1318
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1249
1319
|
}),
|
|
@@ -1271,7 +1341,7 @@ window.codeSnippets = {
|
|
|
1271
1341
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1272
1342
|
}),
|
|
1273
1343
|
cURL: (args) => renderTemplate("template-codeSnippets-deleteMany-cURL", {
|
|
1274
|
-
rootUrl:
|
|
1344
|
+
rootUrl: localStorage.selected_root_url,
|
|
1275
1345
|
entityName: args.entityName,
|
|
1276
1346
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1277
1347
|
}),
|
|
@@ -1306,7 +1376,7 @@ window.codeSnippets = {
|
|
|
1306
1376
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1307
1377
|
}),
|
|
1308
1378
|
cURL: (args) => renderTemplate("template-codeSnippets-generalAction-cURL", {
|
|
1309
|
-
rootUrl:
|
|
1379
|
+
rootUrl: localStorage.selected_root_url,
|
|
1310
1380
|
entityName: args.entityName,
|
|
1311
1381
|
tokenDisplay: args.action.grant !== "*" ? 'inline' : 'none'
|
|
1312
1382
|
}),
|
|
@@ -1351,7 +1421,7 @@ window.codeSnippets = {
|
|
|
1351
1421
|
parameters: args.view.parameters ? "?" + args.view.parameters.map(p => `${encodeHtml(p.field)}=<span class="place-holder">value_of_${encodeHtml(p.field)}</span>`).join("&") : ""
|
|
1352
1422
|
}),
|
|
1353
1423
|
cURL: (args) => renderTemplate("template-codeSnippets-view-cURL", {
|
|
1354
|
-
rootUrl:
|
|
1424
|
+
rootUrl: localStorage.selected_root_url,
|
|
1355
1425
|
entityName: args.entityName,
|
|
1356
1426
|
tokenDisplay: args.view.grant !== "*" ? 'inline' : 'none',
|
|
1357
1427
|
parameters: args.view.parameters ? "?" + args.view.parameters.map(p => `${encodeHtml(p.field)}=<span class="place-holder">value_of_${encodeHtml(p.field)}</span>`).join("&") : ""
|
|
@@ -1421,7 +1491,7 @@ function gotoHash() {
|
|
|
1421
1491
|
const m = location.hash.match(/^#(\$[\w-]+|\w+)(\.((views\.)?\w+))?$/);
|
|
1422
1492
|
if (!m) return;
|
|
1423
1493
|
|
|
1424
|
-
const cardSelector = m[1].charAt(0) === "$" ? "#extension-" + m[1].
|
|
1494
|
+
const cardSelector = m[1].charAt(0) === "$" ? "#extension-" + m[1].substring(1) : "#entity-" + m[1];
|
|
1425
1495
|
let dom = document.querySelector(cardSelector);
|
|
1426
1496
|
if (!dom) return;
|
|
1427
1497
|
|
|
@@ -1441,7 +1511,7 @@ function gotoHash() {
|
|
|
1441
1511
|
if (!m[3]) return;
|
|
1442
1512
|
|
|
1443
1513
|
const panelSelector = m[1].charAt(0) === "$"
|
|
1444
|
-
? "#extension-" + m[1].
|
|
1514
|
+
? "#extension-" + m[1].substring(1) + "-" + m[3].replace(/[.]/g, "-")
|
|
1445
1515
|
: "#action-" + m[1] + "-" + m[3].replace(/[.]/g, "-");
|
|
1446
1516
|
dom = document.querySelector(panelSelector);
|
|
1447
1517
|
if (!dom) return;
|
package/gen/gen-api-docs.js
CHANGED
|
@@ -258,7 +258,7 @@ async function genDocs(args, projectName, project, alias, source) {
|
|
|
258
258
|
}
|
|
259
259
|
},
|
|
260
260
|
features: aliasProject.features,
|
|
261
|
-
roles: source.roles,
|
|
261
|
+
roles: common.filterRoles(source.roles ?? [], aliasProject.allowRoles),
|
|
262
262
|
environmentVariables: source.environmentVariables,
|
|
263
263
|
entities: entities
|
|
264
264
|
});
|
package/gen/gen-ts-driver.js
CHANGED
|
@@ -63,32 +63,33 @@ function getCSharpTypeFromMushroomType(type) {
|
|
|
63
63
|
return "UNKNOWN_TYPE_" + type;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function generateTypescriptClass(objectDefination,
|
|
67
|
-
|
|
68
|
-
let code =
|
|
66
|
+
function generateTypescriptClass(objectDefination, className, options) {
|
|
67
|
+
let childrenCode = '';
|
|
68
|
+
let code = `export interface ${className} {\n`;
|
|
69
69
|
for (let fieldName in objectDefination) {
|
|
70
70
|
const optionalMark = options?.checkRequired && objectDefination[fieldName].required ? "" : "?";
|
|
71
71
|
if (objectDefination[fieldName].type == "object") {
|
|
72
|
-
|
|
73
|
-
`;
|
|
72
|
+
const fieldClassName = className + "_" + toTypeScriptClassName(fieldName);
|
|
73
|
+
code += ` ${fieldName}${optionalMark}: ${fieldClassName},\n`;
|
|
74
|
+
childrenCode += generateTypescriptClass(objectDefination[fieldName].fields, fieldClassName);
|
|
74
75
|
}
|
|
75
76
|
else if (objectDefination[fieldName].type == "array") {
|
|
76
77
|
if (objectDefination[fieldName].items.type == "object") {
|
|
77
|
-
|
|
78
|
-
`;
|
|
78
|
+
const fieldClassName = className + "_" + toTypeScriptClassName(fieldName);
|
|
79
|
+
code += ` ${fieldName}${optionalMark}: ${fieldClassName}[],\n`;
|
|
80
|
+
childrenCode += generateTypescriptClass(objectDefination[fieldName].items.fields, fieldClassName);
|
|
79
81
|
}
|
|
80
82
|
else {
|
|
81
|
-
code +=
|
|
82
|
-
`;
|
|
83
|
+
code += ` ${fieldName}${optionalMark}: ${getCSharpTypeFromMushroomType(objectDefination[fieldName].items.type)}[],\n`;
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
else {
|
|
86
|
-
code +=
|
|
87
|
-
`;
|
|
87
|
+
code += ` ${fieldName}${optionalMark}: ${getCSharpTypeFromMushroomType(objectDefination[fieldName].type)},\n`;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
code +=
|
|
91
|
-
|
|
90
|
+
code += "}\n\n";
|
|
91
|
+
|
|
92
|
+
return code + childrenCode;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
function generateTypescriptClassFromViewParameters(parameters) {
|
|
@@ -143,9 +144,7 @@ export type IdValue = ${source.idType == "AutoIncInt" || source.idType == "AutoI
|
|
|
143
144
|
|
|
144
145
|
const entity = entities[entityName];
|
|
145
146
|
const typescriptClassName = toTypeScriptClassName(entityName);
|
|
146
|
-
code +=
|
|
147
|
-
`;
|
|
148
|
-
|
|
147
|
+
code += generateTypescriptClass(entity.fields, typescriptClassName);
|
|
149
148
|
|
|
150
149
|
const actions = {};
|
|
151
150
|
iApiClassBody += ` ${entityName}: MushroomResourceBase`;
|
|
@@ -238,8 +237,8 @@ ${customMethodCode}}
|
|
|
238
237
|
code += `export interface ${inputType} ${generateTypescriptClassFromViewParameters(view.parameters)};
|
|
239
238
|
`;
|
|
240
239
|
if (view.codeHint?.output)
|
|
241
|
-
code +=
|
|
242
|
-
|
|
240
|
+
code += generateTypescriptClass(view.codeHint.output.fields, outputType, {checkRequired: true});
|
|
241
|
+
|
|
243
242
|
return `MushroomViewFunction<${outputType}, ${inputType}>`;
|
|
244
243
|
});
|
|
245
244
|
viewCode += `
|
|
@@ -322,9 +321,7 @@ export declare type IdValue = ${source.idType == "AutoIncInt" || source.idType =
|
|
|
322
321
|
|
|
323
322
|
const entity = entities[entityName];
|
|
324
323
|
const typescriptClassName = toTypeScriptClassName(entityName);
|
|
325
|
-
code +=
|
|
326
|
-
`;
|
|
327
|
-
|
|
324
|
+
code += generateTypescriptClass(entity.fields, typescriptClassName);
|
|
328
325
|
|
|
329
326
|
const actions = {};
|
|
330
327
|
iApiClassBody += ` ${entityName}: MushroomResourceBase`;
|
|
@@ -414,11 +411,10 @@ ${customMethodCode}}
|
|
|
414
411
|
const viewParameterTypes = viewRoles.map(view => {
|
|
415
412
|
const inputType = `${typescriptClassName}$ViewsResource_${viewName}View_${view.grant === "*" ? "" : toTypeScriptClassName(view.grant)}Parameters`;
|
|
416
413
|
const outputType = view.codeHint?.output ? `${typescriptClassName}$ViewsResource_${viewName}View_${view.grant === "*" ? "" : toTypeScriptClassName(view.grant)}Result` : 'any';
|
|
417
|
-
code += `export interface ${inputType} ${generateTypescriptClassFromViewParameters(view.parameters)}
|
|
418
|
-
`;
|
|
414
|
+
code += `export interface ${inputType} ${generateTypescriptClassFromViewParameters(view.parameters)};\n`;
|
|
419
415
|
if (view.codeHint?.output)
|
|
420
|
-
code +=
|
|
421
|
-
|
|
416
|
+
code += generateTypescriptClass(view.codeHint.output.fields, outputType, {checkRequired: true});
|
|
417
|
+
|
|
422
418
|
return `MushroomViewFunction<${outputType}, ${inputType}>`;
|
|
423
419
|
});
|
|
424
420
|
viewCode += `
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mushroom-cli",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.11",
|
|
4
4
|
"description": "Mushroom CLI",
|
|
5
5
|
"main": "mr.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"jsdom": "^24.1.1",
|
|
22
22
|
"json5": "^2.2.3",
|
|
23
23
|
"minify": "7.2.2",
|
|
24
|
-
"node-fetch": "^2.
|
|
24
|
+
"node-fetch": "^2.7.0",
|
|
25
25
|
"open": "^8.4.2",
|
|
26
26
|
"readline-sync": "^1.4.10",
|
|
27
27
|
"targz": "^1.0.1"
|