mushroom-cli 1.2.0-alpha.24 → 1.2.0-alpha.26

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 CHANGED
@@ -132,6 +132,22 @@ npx mushroom-cli parameters --no-check-update
132
132
 
133
133
  ## Version
134
134
 
135
+ ### 1.2.0-alpha.25
136
+
137
+ Improvement:
138
+
139
+ - gen c#-mongo
140
+ - support System.Text.Json on resources
141
+ - gen api docs
142
+ - impove copy function
143
+ - allow collapse object fields
144
+ - display the description of entities
145
+
146
+ Fixed bug:
147
+
148
+ - gen api docs
149
+ - correct route for role \*
150
+
135
151
  ### 1.2.0-alpha.24
136
152
 
137
153
  Improvement:
@@ -74,6 +74,25 @@
74
74
  display: none;
75
75
  }
76
76
 
77
+
78
+ .entity > .description {
79
+ display: none;
80
+ }
81
+ .entity h2:hover, .extension h2:hover {
82
+ background-color: #f5f5f5;
83
+ margin-left: calc(0px - var(--padding));
84
+ margin-right: calc(0px - var(--padding));
85
+ padding-left: var(--padding);
86
+ padding-right: var(--padding);
87
+ }
88
+ .entity h2 .description {
89
+ float: right;
90
+ font-size: 15px;
91
+ }
92
+ .entity .project-entity-actions, .extension .actions {
93
+ margin-top: var(--margin);
94
+ }
95
+
77
96
  .actions {
78
97
  padding-left: var(--padding);
79
98
  display: none;
@@ -88,6 +107,25 @@
88
107
  z-index: 100;
89
108
  }
90
109
 
110
+ .actions .panel-heading .copy, .entity h2 .copy {
111
+ display: none;
112
+ width: 16px;
113
+ height: 16px;
114
+ opacity: 0.8;
115
+ background-size: contain;
116
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIHZpZXdCb3g9IjAgMCA1MCA1MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cmVjdCB4PSIxMCIgeT0iNSIgd2lkdGg9IjI1IiBoZWlnaHQ9IjMwIiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjUiIGZpbGw9Im5vbmUiIC8+CiAgPHJlY3QgeD0iMTgiIHk9IjEzIiB3aWR0aD0iMjUiIGhlaWdodD0iMzAiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iNSIgZmlsbD0ibm9uZSIgLz4KPC9zdmc+);
117
+ }
118
+ .entity h2 .copy {
119
+ filter: invert(1);
120
+ vertical-align: super;
121
+ }
122
+ .actions .panel-heading:hover .copy, .entity h2:hover .copy {
123
+ display: inline-block;
124
+ opacity: 1;
125
+ }
126
+ .actions .panel-heading .copy:hover, .entity h2 .copy:hover {
127
+ transform: scale(1.1);
128
+ }
91
129
  .actions .panel-heading .description {
92
130
  float: right;
93
131
  }
@@ -133,6 +171,26 @@
133
171
  font-weight: bold;
134
172
  }
135
173
 
174
+ pre .collapsable-field {
175
+ cursor: pointer;
176
+ }
177
+ pre .collapsable-field:hover {
178
+ text-decoration: underline;
179
+ }
180
+ pre .collapsable-field.collapsed {
181
+ display: inline-block;
182
+ }
183
+ pre .collapsable-field.collapsed::before {
184
+ content: ">";
185
+ text-decoration: none;
186
+ display: inline-block;
187
+ margin-right: 1px;
188
+ margin-left: -9px;
189
+ }
190
+ pre .collapsed {
191
+ display: none;
192
+ }
193
+
136
194
  pre[data-language] {
137
195
  position: relative;
138
196
  }
@@ -167,11 +225,23 @@
167
225
  h2 {
168
226
  font-size: 26px;
169
227
  }
228
+ .entity > .description {
229
+ display: block;
230
+ }
231
+ .entity h2 .description {
232
+ display: none;
233
+ }
170
234
  .actions .panel-heading .description {
171
235
  float: none;
172
236
  display: block;
173
237
  opacity: 0.8;
174
238
  }
239
+ .nav.nav-tabs {
240
+ top: 121px;
241
+ }
242
+ .tab-pages .nav-tabs {
243
+ top: 164px;
244
+ }
175
245
  }
176
246
 
177
247
  #project-rootUrls li label {
@@ -479,7 +549,8 @@
479
549
  <div class="panel panel-info" id="extension-auth-login">
480
550
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$auth.login">
481
551
  <span>POST</span>
482
- <span class="root-url">{{rootUrl}}</span>auth/login
552
+ <span class="url"><span class="root-url">{{rootUrl}}</span>auth/login</span>
553
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
483
554
  <span class="description">Đăng nhập</span>
484
555
  </div>
485
556
  <div class="panel-body">
@@ -685,7 +756,8 @@ API.getAuthentication().loginAsync("your account", "your password", loginResult
685
756
  <div class="panel panel-primary" id="extension-auth-logout">
686
757
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$auth.logout">
687
758
  <span>GET</span>
688
- <span class="root-url">{{rootUrl}}</span>auth/logout
759
+ <span class="url"><span class="root-url">{{rootUrl}}</span>auth/logout</span>
760
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
689
761
  <span class="description">Đăng xuất</span>
690
762
  </div>
691
763
  <div class="panel-body">
@@ -849,7 +921,8 @@ API.getAuthentication().logoutAsync(logoutMode, () -> {
849
921
  <div class="panel panel-primary" id="extension-auth-status">
850
922
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$auth.status">
851
923
  <span>GET</span>
852
- <span class="root-url">{{rootUrl}}</span>auth/status
924
+ <span class="url"><span class="root-url">{{rootUrl}}</span>auth/status
925
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
853
926
  <span class="description">Truy vấn trạng thái token</span>
854
927
  </div>
855
928
  <div class="panel-body">
@@ -995,7 +1068,8 @@ API.getAuthentication().statusAsync(loginStatus -> {
995
1068
  <div class="panel panel-primary" id="extension-auth-me">
996
1069
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$auth.me">
997
1070
  <span>GET</span>
998
- <span class="root-url">{{rootUrl}}</span>auth/me
1071
+ <span class="url"><span class="root-url">{{rootUrl}}</span>auth/me</span>
1072
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
999
1073
  <span class="description">Lấy về thông tin người dùng hiện tại</span>
1000
1074
  </div>
1001
1075
  <div class="panel-body">
@@ -1144,7 +1218,8 @@ API.getAuthentication().meAsync(user -> {
1144
1218
  <div class="panel panel-info" id="extension-auth-register">
1145
1219
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$auth.register">
1146
1220
  <span>POST</span>
1147
- <span class="root-url">{{rootUrl}}</span>auth/register
1221
+ <span class="url"><span class="root-url">{{rootUrl}}</span>auth/register</span>
1222
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
1148
1223
  <span class="description">Đăng ký tài khoản</span>
1149
1224
  </div>
1150
1225
  <div class="panel-body">
@@ -1324,7 +1399,8 @@ API.getAuthentication().registerAsync("your account", "your password", registerR
1324
1399
  <div class="panel panel-info" id="extension-auth-activate">
1325
1400
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$auth.activate">
1326
1401
  <span>POST</span>
1327
- <span class="root-url">{{rootUrl}}</span>auth/activate
1402
+ <span class="url"><span class="root-url">{{rootUrl}}</span>auth/activate</span>
1403
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
1328
1404
  <span class="description">Kích hoạt tài khoản</span>
1329
1405
  </div>
1330
1406
  <div class="panel-body">
@@ -1483,7 +1559,8 @@ API.getAuthentication().activateAsync("your account", "activation code", id -> {
1483
1559
  <div class="panel panel-info" id="extension-auth-recover_password">
1484
1560
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$auth.recover_password">
1485
1561
  <span>POST</span>
1486
- <span class="root-url">{{rootUrl}}</span>auth/recover-password
1562
+ <span class="url"><span class="root-url">{{rootUrl}}</span>auth/recover-password</span>
1563
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
1487
1564
  <span class="description">Lấy lại mật khẩu</span>
1488
1565
  </div>
1489
1566
  <div class="panel-body">
@@ -1636,7 +1713,8 @@ API.getAuthentication().recoverPasswordAsync("your account", id -> {
1636
1713
  <div class="panel panel-info" id="extension-auth-reset_password">
1637
1714
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$auth.reset_password">
1638
1715
  <span>POST</span>
1639
- <span class="root-url">{{rootUrl}}</span>auth/reset-password
1716
+ <span class="url"><span class="root-url">{{rootUrl}}</span>auth/reset-password</span>
1717
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
1640
1718
  <span class="description">Khôi phục mật khẩu / Đổi mật khẩu</span>
1641
1719
  </div>
1642
1720
  <div class="panel-body">
@@ -1905,7 +1983,8 @@ API.getAuthentication().changePasswordAsync("your account", "your old password",
1905
1983
  <div class="panel panel-info" id="extension-file-upload">
1906
1984
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$file.upload">
1907
1985
  <span>POST</span>
1908
- <span class="root-url">{{rootUrl}}</span>file/upload
1986
+ <span class="url"><span class="root-url">{{rootUrl}}</span>file/upload</span>
1987
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
1909
1988
  <span class="description">Upload file</span>
1910
1989
  </div>
1911
1990
  <div class="panel-body">
@@ -2093,7 +2172,8 @@ API.fileExtension().uploadAsync(file, uploadResult -> {
2093
2172
  <div class="panel panel-primary" id="extension-file-download">
2094
2173
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$file.download">
2095
2174
  <span>GET</span>
2096
- <span class="root-url">{{rootUrl}}</span>file/download
2175
+ <span class="url"><span class="root-url">{{rootUrl}}</span>file/download</span>
2176
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
2097
2177
  <span class="description">Download file</span>
2098
2178
  </div>
2099
2179
  <div class="panel-body">
@@ -2141,7 +2221,8 @@ Content-Range: byte {realStartIndex}-{realEndIndex}/{totalLength}
2141
2221
  <div class="panel panel-primary" id="extension-file-thumb">
2142
2222
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$file.thumb">
2143
2223
  <span>GET</span>
2144
- <span class="root-url">{{rootUrl}}</span>file/thumb
2224
+ <span class="url"><span class="root-url">{{rootUrl}}</span>file/thumb</span>
2225
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
2145
2226
  <span class="description">Download image thumbnail</span>
2146
2227
  </div>
2147
2228
  <div class="panel-body">
@@ -2339,7 +2420,8 @@ Tạo hiệu ứng đen trắng: &lt;img src="<span class="root-url">{{rootUrl}}
2339
2420
  <div class="panel panel-primary" id="extension-file-zip">
2340
2421
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$file.zip">
2341
2422
  <span>GET</span>
2342
- <span class="root-url">{{rootUrl}}</span>file/zip
2423
+ <span class="url"><span class="root-url">{{rootUrl}}</span>file/zip</span>
2424
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
2343
2425
  <span class="description">Download zip file</span>
2344
2426
  </div>
2345
2427
  <div class="panel-body">
@@ -2381,7 +2463,8 @@ Content-Disposition: attachment; filename="{name}"</pre>
2381
2463
  <div class="panel panel-info" id="extension-mailing-sent">
2382
2464
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$mailing.sent">
2383
2465
  <span>POST</span>
2384
- <span class="root-url">{{rootUrl}}</span>mailing/sent
2466
+ <span class="url"><span class="root-url">{{rootUrl}}</span>mailing/sent</span>
2467
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
2385
2468
  <span class="description">Tạo lệnh gửi mail</span>
2386
2469
  </div>
2387
2470
  <div class="panel-body">
@@ -2506,7 +2589,8 @@ try {
2506
2589
  <div class="panel panel-primary" id="extension-mailing-get">
2507
2590
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$mailing.get">
2508
2591
  <span>GET</span>
2509
- <span class="root-url">{{rootUrl}}</span>mailing/get
2592
+ <span class="url"><span class="root-url">{{rootUrl}}</span>mailing/get</span>
2593
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
2510
2594
  <span class="description">Lấy thông tin lệnh gửi mail</span>
2511
2595
  </div>
2512
2596
  <div class="panel-body">
@@ -2589,7 +2673,8 @@ catch (error) {
2589
2673
  <div class="panel panel-danger" id="extension-mailing-discard">
2590
2674
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$mailing.discard">
2591
2675
  <span>DELETE</span>
2592
- <span class="root-url">{{rootUrl}}</span>mailing/discard
2676
+ <span class="url"><span class="root-url">{{rootUrl}}</span>mailing/discard</span>
2677
+ <span class="copy" title="Copy" data-copy=".url" onclick="doCopy.call(this, event)"></span>
2593
2678
  <span class="description">Hủy lệnh gửi mail</span>
2594
2679
  </div>
2595
2680
  <div class="panel-body">
@@ -2694,7 +2779,12 @@ catch (error) {
2694
2779
 
2695
2780
  <div class="mushroom-docs-template" id="template-project-entity">
2696
2781
  <div class="entity" id="entity-{{name}}">
2697
- <h2 data-hash="{{name}}" onclick="renderEntity.call(this, '{{name}}'); toggleParentClass.call(this)" data-toggled-class="expand">{{name}}</h2>
2782
+ <h2 data-hash="{{name}}" onclick="renderEntity.call(this, '{{name}}'); toggleParentClass.call(this)" data-toggled-class="expand">
2783
+ <span class="entity-name">{{name}}</span>
2784
+ <span class="copy" title="Copy" data-copy=".entity-name" onclick="doCopy.call(this, event)"></span>
2785
+ <div class="description">{{description}}</div>
2786
+ </h2>
2787
+ <div class="description">{{description}}</div>
2698
2788
  <div class="project-entity-actions"></div>
2699
2789
  <div class="project-entity-views"></div>
2700
2790
  </div>
@@ -2705,6 +2795,7 @@ catch (error) {
2705
2795
  <div class="panel-heading" onclick="renderEntityAction.call(this, '{{entityName}}', '{{actionName}}'); toggleParentClass.call(this)" data-toggled-class="show" data-hash="{{entityName}}.{{actionName}}">
2706
2796
  {{actionHttpMethod}}
2707
2797
  <span class="contain-root-url">{{actionApiUrl}}</span>
2798
+ <span class="copy" title="Copy" data-copy=".contain-root-url" onclick="doCopy.call(this, event)"></span>
2708
2799
  <span class="description">{{actionDescription}}</span>
2709
2800
  </div>
2710
2801
  <div class="panel-body">
@@ -2759,9 +2850,9 @@ catch (e) {
2759
2850
  Tùy biến tham số
2760
2851
  <pre data-language="javascript">try {
2761
2852
  const response = await mushroom.{{entityName}}.listAsync({
2762
- fields: "<span class="separated-items">{{fields:html}}</span>",
2763
- filters: ["your filter 1", "your filter 2"], // <i>or</i> "your filters" ,<span style="display: {{allowSortingsDisplay}}">
2764
- sort: "<span class="separated-items">{{sortFields:html}}</span>",</span>
2853
+ fields: "<span class="separated-items">{{fields:html}}</span>", <span class="code-comment">// nên sử dụng builder dạng Project.include('a', 'b').build()</span>
2854
+ filters: ["your filter 1", "your filter 2"], <span class="code-comment">// nên sử dụng builder dạng Filter.eq('a', 1).gte('b', 2).build()</span><span style="display: {{allowSortingsDisplay}}">
2855
+ sort: "<span class="separated-items">{{sortFields:html}}</span>", <span class="code-comment">// nên sử dụng builder dạng Sort.ascending('a').thenByAscending('b').build()</span></span>
2765
2856
  <span style="display: {{limitDisplay}}"> limit: 25,
2766
2857
  </span><span style="display: {{offsetDisplay}}"> offset: 0,
2767
2858
  </span><span style="display: {{pageDisplay}}"> page: 1,
@@ -4179,8 +4270,7 @@ catch (Exception ex)
4179
4270
  <div class="http-snippet">
4180
4271
  Xóa nhật một {{entityName}}
4181
4272
  <pre data-language="http">DELETE {{rootUrlPath}}{{entityName}}s/<span class="place-holder">id</span> HTTP/1.1
4182
- Host: <span class="domain">{{domain}}</span>
4183
- Content-Type: application/json<span style="display: {{tokenDisplay}}">
4273
+ Host: <span class="domain">{{domain}}</span><span style="display: {{tokenDisplay}}">
4184
4274
  Token: your token</span></pre>
4185
4275
  </div>
4186
4276
  </script>
@@ -4188,8 +4278,7 @@ Token: your token</span></pre>
4188
4278
  <div class="curl-snippet">
4189
4279
  cURL
4190
4280
  <pre data-language="cURL">curl -X DELETE \
4191
- '<span class="root-url">{{rootUrl}}</span>{{entityName}}s/<span class="place-holder">id</span>' \
4192
- -H 'Content-Type: application/json' \ <span style="display: {{tokenDisplay}}">
4281
+ '<span class="root-url">{{rootUrl}}</span>{{entityName}}s/<span class="place-holder">id</span>' \<span style="display: {{tokenDisplay}}">
4193
4282
  -H 'Token: {<span>{</span>TOKEN}}' \</span></pre>
4194
4283
  Shell
4195
4284
  <pre data-language="cURL">curl --request DELETE \
@@ -182,6 +182,7 @@ function getModelOutput(arrFields, fields, options) {
182
182
 
183
183
  return formatModel(obj, '', options).trim();
184
184
  }
185
+ let __field_idx = 0;
185
186
  function formatModel(obj, strIndent, options) {
186
187
  if (!obj) return '';
187
188
 
@@ -298,11 +299,13 @@ function formatModel(obj, strIndent, options) {
298
299
  else result += '], ' + comment;
299
300
  } else result += `\r\n${nextIndent}"${m}": undefined, ${comment}`;
300
301
  } else {
301
- result += '\r\n' + strIndent + encodeHtml(m) + ': ' + encodeHtml(child.type);
302
+ const fieldIdx = 'f_' + __field_idx.toString(36);
303
+ __field_idx++;
304
+ result += '\r\n' + strIndent + (child.type === 'object' || child.type === 'array' && child.items.type === 'object' ? '<span class="collapsable-field" data-field-idx="' + fieldIdx + '" onclick="collapseThisField(this)">' + encodeHtml(m) + '</span>' : encodeHtml(m)) + ': ' + encodeHtml(child.type);
302
305
  if (child.type === 'array') result += child.items.type === 'object' ? ' of object' : ' of ' + child.items.type;
303
- if (child.type === 'object') result += ' ' + comment + formatModel(child.fields, strIndent + ' ', options);
306
+ if (child.type === 'object') result += ' ' + comment + '<span id="' + fieldIdx + '">' + formatModel(child.fields, strIndent + ' ', options) + '</span>';
304
307
  else if (child.type === 'array' && child.items.type === 'object')
305
- result += ' ' + comment + formatModel(child.items.fields, strIndent + ' ', options);
308
+ result += ' ' + comment + '<span id="' + fieldIdx + '">' + formatModel(child.items.fields, strIndent + ' ', options) + '</span>';
306
309
  else result += ', ' + comment;
307
310
  }
308
311
  }
@@ -313,6 +316,10 @@ function formatModel(obj, strIndent, options) {
313
316
 
314
317
  return result;
315
318
  }
319
+ function collapseThisField(dom) {
320
+ dom.classList.toggle('collapsed');
321
+ document.getElementById(dom.dataset.fieldIdx).classList.toggle('collapsed');
322
+ }
316
323
  function toCachePolicyString(cachePolicy) {
317
324
  if (cachePolicy === undefined || cachePolicy === null || cachePolicy === 'unset') return 'Không thiết lập cấu hình';
318
325
  if (cachePolicy === 'required') return 'Bắt buộc phải cache';
@@ -490,7 +497,8 @@ function renderInfo() {
490
497
  let selected = localStorage.selected_root_url;
491
498
  if (!selected) selected = localStorage.selected_root_url = window.docs.info.rootUrl;
492
499
  const onspanclick = function () {
493
- this.parentNode.parentNode.querySelector('.selected').className = '';
500
+ const domSelected = this.parentNode.parentNode.querySelector('.selected');
501
+ if (domSelected) domSelected.className = '';
494
502
  selected = this.innerText;
495
503
  this.className = 'selected';
496
504
  const old_root_url = localStorage.selected_root_url;
@@ -1840,7 +1848,7 @@ function activeFirstChild() {
1840
1848
  function gotoHash() {
1841
1849
  if (!location.hash) return;
1842
1850
 
1843
- const m = location.hash.match(/^#(\$[\w-]+|\w+)(\.((views\.)?\w+)(\/[\/\w\+\|]+)?)?$/);
1851
+ const m = location.hash.match(/^#(\$[\w-]+|\w+)(\.((views\.)?\w+)(\/\*?[\/\w\+\|]*)?)?$/);
1844
1852
  if (!m) return;
1845
1853
 
1846
1854
  const cardSelector = m[1].charAt(0) === '$' ? '#extension-' + m[1].substring(1) : '#entity-' + m[1];
@@ -1896,6 +1904,40 @@ function gotoHash() {
1896
1904
  }
1897
1905
  }
1898
1906
 
1907
+ function doCopy(e) {
1908
+ if (!this.dataset.copy) return;
1909
+
1910
+ e.stopPropagation();
1911
+ if (location.protocol !== 'https:' && location.protocol !== 'file:') {
1912
+ alert('Can not copy, please use https protocol!');
1913
+ return;
1914
+ }
1915
+
1916
+ const copyDom = this.parentNode.querySelector(this.dataset.copy);
1917
+
1918
+ if (window.ClipboardItem) {
1919
+ const content = copyDom.innerText;
1920
+ const blob = new Blob([content], { type: 'text/plain' });
1921
+ const text = new ClipboardItem({ 'text/plain': blob });
1922
+ navigator.clipboard.write([text]);
1923
+ } else {
1924
+ if (document.body.createTextRange) {
1925
+ const range = document.body.createTextRange();
1926
+ range.moveToElementText(copyDom);
1927
+ range.select();
1928
+ } else if (window.getSelection) {
1929
+ const selection = window.getSelection();
1930
+ const range = document.createRange();
1931
+ range.selectNodeContents(copyDom);
1932
+ selection.removeAllRanges();
1933
+ selection.addRange(range);
1934
+ }
1935
+ document.execCommand('copy');
1936
+ }
1937
+
1938
+ copied();
1939
+ }
1940
+
1899
1941
  function copied() {
1900
1942
  const dom = document.querySelector('#copied');
1901
1943
  if (!dom) return;
@@ -213,6 +213,8 @@ function generateCSharpClassMongoDb(source, className, fields, isRoot, descripti
213
213
  content += ` [MongoDB.Bson.Serialization.Attributes.BsonElement("${isRoot && fieldName === 'id' ? '_id' : fieldName}")]
214
214
  [MongoDB.Bson.Serialization.Attributes.BsonIgnoreIfNull]
215
215
  [Newtonsoft.Json.JsonProperty(PropertyName = "${fieldName}", NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore${type === 'System.DateTime' ? ', DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore' : ''})]
216
+ [System.Text.Json.Serialization.JsonPropertyName("${fieldName}")]
217
+ [System.Text.Json.Serialization.JsonIgnore(Condition = ${type === 'System.DateTime' ? 'System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault' : 'System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull'})]
216
218
  `;
217
219
  if ((field.type === 'AutoId' || field.type === 'IdRef') && source.idType === 'ObjectId') {
218
220
  content += ' [MongoDB.Bson.Serialization.Attributes.BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]\n';
@@ -558,6 +560,8 @@ function generateCSharpClassMongoDbToFolder(source, className, fields, isRoot, d
558
560
  content += ` [MongoDB.Bson.Serialization.Attributes.BsonElement("${isRoot && fieldName === 'id' ? '_id' : fieldName}")]
559
561
  [MongoDB.Bson.Serialization.Attributes.BsonIgnoreIfNull]
560
562
  [Newtonsoft.Json.JsonProperty(PropertyName = "${fieldName}", NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore${type === 'System.DateTime' ? ', DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore' : ''})]
563
+ [System.Text.Json.Serialization.JsonPropertyName("${fieldName}")]
564
+ [System.Text.Json.Serialization.JsonIgnore(Condition = ${type === 'System.DateTime' ? 'System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault' : 'System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull'})]
561
565
  `;
562
566
  if ((field.type === 'AutoId' || field.type === 'IdRef') && source.idType === 'ObjectId') {
563
567
  content += ' [MongoDB.Bson.Serialization.Attributes.BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]\n';
@@ -838,6 +842,8 @@ namespace ${namespace}
838
842
  private void RegisterCustomVnTextBuilderMethod(System.Func<System.Collections.Generic.IEnumerable<string>, System.Collections.Generic.IEnumerable<string>> fn) { }
839
843
  private void RegisterEvent(System.Func<object, Mushroom.ActionArguments, System.Threading.Tasks.Task> fn) { }
840
844
  private void RegisterEvent(System.Action<object, Mushroom.ActionArguments> fn) { }
845
+ private void RegisterRespondingEvent(System.Func<object, Mushroom.ActionArguments, Mushroom.ActionResult, System.Threading.Tasks.Task> fn) { }
846
+ private void RegisterRespondingEvent(System.Action<object, Mushroom.ActionArguments, Mushroom.ActionResult> fn) { }
841
847
  private void RegisterJob<T>() where T : Mushroom.Job.JobBase { }
842
848
  private void Help()
843
849
  {
@@ -900,6 +906,8 @@ function generateCSharpClassDriver(source, className, fields, description, out)
900
906
  /// ${singleLine(field.description)}
901
907
  /// </summary>
902
908
  [Newtonsoft.Json.JsonProperty(PropertyName ="${fieldName}", NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore${type === 'System.Datetime' ? ', DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore' : ''})]
909
+ [System.Text.Json.Serialization.JsonPropertyName("${fieldName}")]
910
+ [System.Text.Json.Serialization.JsonIgnore(Condition = ${type === 'System.DateTime' ? 'System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault' : 'System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull'})]
903
911
  public ${type} ${propertyName} { get; set; }
904
912
 
905
913
  `;
@@ -1135,7 +1143,9 @@ export function genCSharpDriver(args, projectName, project, alias, source) {
1135
1143
  let type = getCSharpTypeFromMushroomType(source, p.type, p.validation && p.validation.required);
1136
1144
  if (p.isArray)
1137
1145
  type = `System.Collections.Generic.List<${type}>`;
1138
- viewExtraClass += ` [Newtonsoft.Json.JsonProperty(PropertyName = "${p.field}")]
1146
+ viewExtraClass += ` [Newtonsoft.Json.JsonProperty(PropertyName = "${p.field}", NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore${type === 'System.Datetime' ? ', DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore' : ''})]
1147
+ [System.Text.Json.Serialization.JsonPropertyName("${p.field}")]
1148
+ [System.Text.Json.Serialization.JsonIgnore(Condition = ${type === 'System.DateTime' ? 'System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault' : 'System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull'})]
1139
1149
  public ${type} ${toCSharpName(p.field)} { get; set; }
1140
1150
 
1141
1151
  `;
@@ -1,6 +1,6 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import targz from 'targz';
3
+ import { compress } from 'targz';
4
4
  import * as common from '../common.js';
5
5
  import * as javascriptDriverGenerator from './gen-js-driver.js';
6
6
  import * as typescriptDriverGenerator from './gen-ts-driver.js';
@@ -21,7 +21,7 @@ function compressAsync(src, dest, folderName) {
21
21
  },
22
22
  };
23
23
  }
24
- targz.compress(options, function (err) {
24
+ compress(options, function (err) {
25
25
  if (err) {
26
26
  reject(err);
27
27
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mushroom-cli",
3
- "version": "1.2.0-alpha.24",
3
+ "version": "1.2.0-alpha.26",
4
4
  "description": "Mushroom CLI",
5
5
  "main": "dist/mr.js",
6
6
  "type": "module",
@@ -33,30 +33,30 @@
33
33
  "author": "suco2007",
34
34
  "license": "ISC",
35
35
  "dependencies": {
36
- "jsdom": "^25.0.1",
36
+ "jsdom": "^26.1.0",
37
37
  "json5": "^2.2.3",
38
- "minify": "^11.4.1",
38
+ "minify": "^14.0.0",
39
39
  "node-fetch": "^3.3.2",
40
- "open": "^10.1.0",
40
+ "open": "^10.1.2",
41
41
  "readline-sync": "^1.4.10",
42
42
  "targz": "^1.0.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@eslint/js": "^9.11.1",
45
+ "@eslint/js": "^9.28.0",
46
46
  "@types/jsdom": "^21.1.7",
47
47
  "@types/minify": "^9.1.4",
48
- "@types/node": "^22.7.4",
49
- "@types/node-fetch": "^2.6.11",
48
+ "@types/node": "^22.15.29",
49
+ "@types/node-fetch": "^2.6.12",
50
50
  "@types/readline-sync": "^1.4.8",
51
- "@types/targz": "^1.0.4",
51
+ "@types/targz": "^1.0.5",
52
52
  "copyfiles": "^2.4.1",
53
- "eslint": "^9.11.1",
54
- "husky": "^9.1.6",
55
- "lint-staged": "^15.2.10",
53
+ "eslint": "^9.28.0",
54
+ "husky": "^9.1.7",
55
+ "lint-staged": "^16.1.0",
56
56
  "only-allow": "^1.2.1",
57
- "prettier": "^3.3.3",
58
- "typescript": "^5.6.2",
59
- "typescript-eslint": "^8.8.0"
57
+ "prettier": "^3.5.3",
58
+ "typescript": "^5.8.3",
59
+ "typescript-eslint": "^8.33.0"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">=14.0.0"