semanticdb-core 1.1.33 → 1.1.35
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/dist/result/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export interface LogicformResultType {
|
|
|
8
8
|
schemas?: Record<string, SchemaType>;
|
|
9
9
|
columnProperties?: PropertyType[];
|
|
10
10
|
sqls?: string[];
|
|
11
|
+
total?: number;
|
|
11
12
|
}
|
|
12
13
|
export declare const logicformResultToMarkdown: (ret: LogicformResultType, number_only?: boolean) => string;
|
package/dist/result/index.js
CHANGED
|
@@ -8,12 +8,15 @@ const json2md_1 = __importDefault(require("json2md"));
|
|
|
8
8
|
const property_utils_1 = require("../schema/property.utils");
|
|
9
9
|
const logicform_utils_1 = require("../logicform/logicform.utils");
|
|
10
10
|
const logicformResultToMarkdown = (ret, number_only) => {
|
|
11
|
-
const { schemas, result, logicform, columnProperties,
|
|
11
|
+
const { schemas, result, logicform, columnProperties, total } = ret;
|
|
12
12
|
if (!result || !logicform || !columnProperties || !schemas)
|
|
13
13
|
return '没有数据';
|
|
14
14
|
if (result.length === 0)
|
|
15
15
|
return '没有数据';
|
|
16
16
|
let markdownText = '';
|
|
17
|
+
if (logicform.groupby && total !== undefined && total !== null) {
|
|
18
|
+
markdownText += `总记录数: ${total}\n`;
|
|
19
|
+
}
|
|
17
20
|
if (!logicform.groupby && !(0, logicform_utils_1.isSimpleQuery)(logicform)) {
|
|
18
21
|
markdownText = columnProperties
|
|
19
22
|
.map((p) => (number_only ? '' : (p.name + ': ')) +
|
|
@@ -235,6 +235,10 @@ const getFormatter = (property) => {
|
|
|
235
235
|
return null;
|
|
236
236
|
};
|
|
237
237
|
exports.getFormatter = getFormatter;
|
|
238
|
+
const formatWithNumeralSafely = (value, format) => {
|
|
239
|
+
const formattedValue = (0, numeral_1.default)(value).format(format);
|
|
240
|
+
return formattedValue === 'NaN' ? `${value}` : formattedValue;
|
|
241
|
+
};
|
|
238
242
|
/**
|
|
239
243
|
*
|
|
240
244
|
* @param schema
|
|
@@ -264,19 +268,19 @@ const formatWithProperty = (schema, property, value, withUnit = false) => {
|
|
|
264
268
|
finalValue = value;
|
|
265
269
|
}
|
|
266
270
|
else if (formatter) {
|
|
267
|
-
finalValue = (
|
|
271
|
+
finalValue = formatWithNumeralSafely(value, formatter.formatter);
|
|
268
272
|
}
|
|
269
273
|
else if (property.type === 'percentage') {
|
|
270
|
-
finalValue = (
|
|
274
|
+
finalValue = formatWithNumeralSafely(value, '0.00%');
|
|
271
275
|
}
|
|
272
276
|
else if (property.type === 'int') {
|
|
273
|
-
finalValue = (
|
|
277
|
+
finalValue = formatWithNumeralSafely(value, '0,0');
|
|
274
278
|
}
|
|
275
279
|
else if (property.type === 'currency') {
|
|
276
|
-
finalValue = (
|
|
280
|
+
finalValue = formatWithNumeralSafely(value, '0,0.00');
|
|
277
281
|
}
|
|
278
282
|
else if (property.primal_type === 'number') {
|
|
279
|
-
finalValue = (
|
|
283
|
+
finalValue = formatWithNumeralSafely(value, '0,0.0');
|
|
280
284
|
}
|
|
281
285
|
if (withUnit && property.type !== 'percentage') {
|
|
282
286
|
let unit = '';
|