mushroom-cli 1.2.0-alpha.26 → 1.2.0-alpha.27
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 +8 -1
- package/dist/docs/docs.v2.html +3 -3
- package/dist/docs/docs.v2.js +31 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,6 +132,13 @@ npx mushroom-cli parameters --no-check-update
|
|
|
132
132
|
|
|
133
133
|
## Version
|
|
134
134
|
|
|
135
|
+
### 1.2.0-alpha.27
|
|
136
|
+
|
|
137
|
+
Improvement:
|
|
138
|
+
|
|
139
|
+
- gen api docs
|
|
140
|
+
- add validation of fields in custom methods and parameters in views
|
|
141
|
+
|
|
135
142
|
### 1.2.0-alpha.25
|
|
136
143
|
|
|
137
144
|
Improvement:
|
|
@@ -139,7 +146,7 @@ Improvement:
|
|
|
139
146
|
- gen c#-mongo
|
|
140
147
|
- support System.Text.Json on resources
|
|
141
148
|
- gen api docs
|
|
142
|
-
-
|
|
149
|
+
- improve copy function
|
|
143
150
|
- allow collapse object fields
|
|
144
151
|
- display the description of entities
|
|
145
152
|
|
package/dist/docs/docs.v2.html
CHANGED
|
@@ -109,8 +109,8 @@
|
|
|
109
109
|
|
|
110
110
|
.actions .panel-heading .copy, .entity h2 .copy {
|
|
111
111
|
display: none;
|
|
112
|
-
width:
|
|
113
|
-
height:
|
|
112
|
+
width: 15px;
|
|
113
|
+
height: 15px;
|
|
114
114
|
opacity: 0.8;
|
|
115
115
|
background-size: contain;
|
|
116
116
|
background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIHZpZXdCb3g9IjAgMCA1MCA1MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cmVjdCB4PSIxMCIgeT0iNSIgd2lkdGg9IjI1IiBoZWlnaHQ9IjMwIiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjUiIGZpbGw9Im5vbmUiIC8+CiAgPHJlY3QgeD0iMTgiIHk9IjEzIiB3aWR0aD0iMjUiIGhlaWdodD0iMzAiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iNSIgZmlsbD0ibm9uZSIgLz4KPC9zdmc+);
|
|
@@ -5145,7 +5145,7 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
|
|
|
5145
5145
|
</div>
|
|
5146
5146
|
<div class="mushroom-docs-template" id="template-view-parameters">
|
|
5147
5147
|
<li>
|
|
5148
|
-
<b>{{field}}</b>: {{type}}, {{required}}{{defaultValue}}, {{description}}
|
|
5148
|
+
<b>{{field}}</b>: {{type}}, {{required}}{{defaultValue}}{{validation}}, {{description}}
|
|
5149
5149
|
</li>
|
|
5150
5150
|
</div>
|
|
5151
5151
|
<div class="mushroom-docs-template" id="template-view">
|
package/dist/docs/docs.v2.js
CHANGED
|
@@ -146,6 +146,29 @@ function explainRoles(strRoles) {
|
|
|
146
146
|
})
|
|
147
147
|
.join(' hoặc ');
|
|
148
148
|
}
|
|
149
|
+
|
|
150
|
+
function getValidationStringDocs(config, dontEncode) {
|
|
151
|
+
if (!config) return '';
|
|
152
|
+
|
|
153
|
+
const encode = dontEncode ? (s) => s : encodeHtml;
|
|
154
|
+
|
|
155
|
+
let validation = '';
|
|
156
|
+
|
|
157
|
+
if ('validValues' in config && Array.isArray(config.validValues))
|
|
158
|
+
validation += ', enum(' + encode(config.validValues.join(', ')) + ')';
|
|
159
|
+
if ('invalidValues' in config && Array.isArray(config.invalidValues))
|
|
160
|
+
validation += ', not allow(' + encode(config.invalidValues.join(', ')) + ')';
|
|
161
|
+
if ('pattern' in config) validation += ', pattern: /' + encode(config.pattern) + '/';
|
|
162
|
+
if ('length' in config) validation += ', length: ' + encode(config.length);
|
|
163
|
+
if ('minLength' in config) validation += ', minLength: ' + encode(config.minLength);
|
|
164
|
+
if ('maxLength' in config) validation += ', maxLength: ' + encode(config.maxLength);
|
|
165
|
+
if ('min' in config) validation += ', min: ' + encode(config.min);
|
|
166
|
+
if ('max' in config) validation += ', max: ' + encode(config.max);
|
|
167
|
+
if ('gt' in config) validation += ', gt: ' + encode(config.gt);
|
|
168
|
+
if ('lt' in config) validation += ', lt: ' + encode(config.lt);
|
|
169
|
+
return validation;
|
|
170
|
+
}
|
|
171
|
+
|
|
149
172
|
function getModelOutput(arrFields, fields, options) {
|
|
150
173
|
if (!fields || !arrFields) return '';
|
|
151
174
|
|
|
@@ -205,37 +228,12 @@ function formatModel(obj, strIndent, options) {
|
|
|
205
228
|
'</a>';
|
|
206
229
|
}
|
|
207
230
|
|
|
208
|
-
|
|
209
|
-
if ('validValues' in child.validation)
|
|
210
|
-
validation += ', enum(' + encodeHtml(child.validation.validValues.join(', ')) + ')';
|
|
211
|
-
if ('invalidValues' in child.validation)
|
|
212
|
-
validation += ', not allow(' + encodeHtml(child.validation.invalidValues.join(', ')) + ')';
|
|
213
|
-
if ('pattern' in child.validation) validation += ', pattern: /' + encodeHtml(child.validation.pattern) + '/';
|
|
214
|
-
if ('length' in child.validation) validation += ', length: ' + child.validation.length;
|
|
215
|
-
if ('minLength' in child.validation) validation += ', minLength: ' + child.validation.minLength;
|
|
216
|
-
if ('maxLength' in child.validation) validation += ', maxLength: ' + child.validation.maxLength;
|
|
217
|
-
if ('min' in child.validation) validation += ', min: ' + encodeHtml(child.validation.min);
|
|
218
|
-
if ('max' in child.validation) validation += ', max: ' + encodeHtml(child.validation.max);
|
|
219
|
-
if ('gt' in child.validation) validation += ', gt: ' + encodeHtml(child.validation.gt);
|
|
220
|
-
if ('lt' in child.validation) validation += ', lt: ' + encodeHtml(child.validation.lt);
|
|
221
|
-
}
|
|
231
|
+
validation += getValidationStringDocs(child.validation);
|
|
222
232
|
|
|
223
233
|
if (child.type === 'array' && child.items && child.items.type != 'object' && child.items.validation) {
|
|
224
234
|
validation +=
|
|
225
235
|
', array items: ' + (!options.optionalToAll && child.items.validation.required ? 'required' : 'optional');
|
|
226
|
-
|
|
227
|
-
validation += ', enum(' + encodeHtml(child.items.validation.validValues.join(', ')) + ')';
|
|
228
|
-
if ('invalidValues' in child.items.validation)
|
|
229
|
-
validation += ', not allow(' + encodeHtml(child.items.validation.invalidValues.join(', ')) + ')';
|
|
230
|
-
if ('pattern' in child.items.validation)
|
|
231
|
-
validation += ', pattern: /' + encodeHtml(child.items.validation.pattern) + '/';
|
|
232
|
-
if ('length' in child.items.validation) validation += ', length: ' + child.items.validation.length;
|
|
233
|
-
if ('minLength' in child.items.validation) validation += ', minLength: ' + child.items.validation.minLength;
|
|
234
|
-
if ('maxLength' in child.items.validation) validation += ', maxLength: ' + child.items.validation.maxLength;
|
|
235
|
-
if ('min' in child.items.validation) validation += ', min: ' + encodeHtml(child.items.validation.min);
|
|
236
|
-
if ('max' in child.items.validation) validation += ', max: ' + encodeHtml(child.items.validation.max);
|
|
237
|
-
if ('gt' in child.items.validation) validation += ', gt: ' + encodeHtml(child.items.validation.gt);
|
|
238
|
-
if ('lt' in child.items.validation) validation += ', lt: ' + encodeHtml(child.items.validation.lt);
|
|
236
|
+
validation += getValidationStringDocs(child.items.validation);
|
|
239
237
|
}
|
|
240
238
|
|
|
241
239
|
let defaultValueDocs = '';
|
|
@@ -301,7 +299,7 @@ function formatModel(obj, strIndent, options) {
|
|
|
301
299
|
} else {
|
|
302
300
|
const fieldIdx = 'f_' + __field_idx.toString(36);
|
|
303
301
|
__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
|
+
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)" title="Thu nhỏ">' + encodeHtml(m) + '</span>' : encodeHtml(m)) + ': ' + encodeHtml(child.type);
|
|
305
303
|
if (child.type === 'array') result += child.items.type === 'object' ? ' of object' : ' of ' + child.items.type;
|
|
306
304
|
if (child.type === 'object') result += ' ' + comment + '<span id="' + fieldIdx + '">' + formatModel(child.fields, strIndent + ' ', options) + '</span>';
|
|
307
305
|
else if (child.type === 'array' && child.items.type === 'object')
|
|
@@ -319,6 +317,7 @@ function formatModel(obj, strIndent, options) {
|
|
|
319
317
|
function collapseThisField(dom) {
|
|
320
318
|
dom.classList.toggle('collapsed');
|
|
321
319
|
document.getElementById(dom.dataset.fieldIdx).classList.toggle('collapsed');
|
|
320
|
+
dom.title = dom.classList.contains('collapsed') ? 'Mở rộng' : 'Thu nhỏ';
|
|
322
321
|
}
|
|
323
322
|
function toCachePolicyString(cachePolicy) {
|
|
324
323
|
if (cachePolicy === undefined || cachePolicy === null || cachePolicy === 'unset') return 'Không thiết lập cấu hình';
|
|
@@ -384,14 +383,11 @@ function formatHintModel(obj, strIndent, options) {
|
|
|
384
383
|
'</a>';
|
|
385
384
|
}
|
|
386
385
|
|
|
387
|
-
|
|
388
|
-
validation += ', enum(' + encodeHtml(child.validValues.join(', ')) + ')';
|
|
389
|
-
}
|
|
386
|
+
validation += getValidationStringDocs(child);
|
|
390
387
|
|
|
391
388
|
if (child.type === 'array' && child.items && child.items.type != 'object') {
|
|
392
389
|
validation += ', array items: ' + (!options.optionalToAll && child.items.required ? 'required' : 'optional');
|
|
393
|
-
|
|
394
|
-
validation += ', enum(' + encodeHtml(child.items.validValues.join(', ')) + ')';
|
|
390
|
+
validation += getValidationStringDocs(child.items);
|
|
395
391
|
}
|
|
396
392
|
|
|
397
393
|
var comment = options.hideComment ? '' : `<span class="code-comment">// ${validation} ${typeof child.description === 'string' && child.description !== '' ? '- ' + encodeHtml(child.description).replace(/\n/g, ' ') : ''}</span>`;
|
|
@@ -1029,6 +1025,7 @@ function renderGeneralAction(args) {
|
|
|
1029
1025
|
type: (field.type === 'array' ? 'array of ' : '') + (field.items?.type ?? 'string'),
|
|
1030
1026
|
description: field.description ?? '',
|
|
1031
1027
|
required: field.required ? 'required' : 'optional',
|
|
1028
|
+
validation: getValidationStringDocs(p, true),
|
|
1032
1029
|
})
|
|
1033
1030
|
}).join('');
|
|
1034
1031
|
} else {
|
|
@@ -1154,6 +1151,7 @@ function renderEntityViewRolePage(entityName, viewName, grant) {
|
|
|
1154
1151
|
description: p.description ?? '',
|
|
1155
1152
|
defaultValue: p.defaultValue ? `, default (${p.defaultValue})` : '',
|
|
1156
1153
|
required: p.required ? 'required' : 'optional',
|
|
1154
|
+
validation: getValidationStringDocs(p.validation, true),
|
|
1157
1155
|
}),
|
|
1158
1156
|
)
|
|
1159
1157
|
.join('');
|