semanticdb-core 1.1.47 → 1.1.49
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.
|
@@ -205,6 +205,28 @@ const explainComparedValue = (key, value, schemas) => {
|
|
|
205
205
|
});
|
|
206
206
|
return segments.join(' 且 ');
|
|
207
207
|
};
|
|
208
|
+
const explainTopLevelLogicalQuery = (operator, operatorValue, includeValue, schemas) => {
|
|
209
|
+
if (!Array.isArray(operatorValue)) {
|
|
210
|
+
return `${operator} ${stringifyExplainValue(operatorValue, schemas)}`;
|
|
211
|
+
}
|
|
212
|
+
const explainedSegments = operatorValue
|
|
213
|
+
.map((item) => {
|
|
214
|
+
if (!isPlainObject(item)) {
|
|
215
|
+
return stringifyExplainValue(item, schemas);
|
|
216
|
+
}
|
|
217
|
+
const itemValues = explainFilterLikeQuery(item, '', includeValue, schemas).values;
|
|
218
|
+
if (itemValues.length === 0) {
|
|
219
|
+
return '';
|
|
220
|
+
}
|
|
221
|
+
return itemValues.join('、');
|
|
222
|
+
})
|
|
223
|
+
.filter((segment) => segment.length > 0)
|
|
224
|
+
.map((segment) => `(${segment})`);
|
|
225
|
+
if (explainedSegments.length === 0) {
|
|
226
|
+
return `${operator} []`;
|
|
227
|
+
}
|
|
228
|
+
return explainedSegments.join(` ${LOGICAL_OPERATOR_LABELS[operator]} `);
|
|
229
|
+
};
|
|
208
230
|
const getEntityIdFromValue = (value) => {
|
|
209
231
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
210
232
|
return undefined;
|
|
@@ -251,6 +273,9 @@ const explainFilterLikeQuery = (query, prefix = '筛选', includeValue = false,
|
|
|
251
273
|
const values = Object.entries(query)
|
|
252
274
|
.filter(([k]) => includeValue || k !== 'entity_id')
|
|
253
275
|
.map(([k, v]) => {
|
|
276
|
+
if (k === '$and' || k === '$or') {
|
|
277
|
+
return explainTopLevelLogicalQuery(k, v, includeValue, schemas);
|
|
278
|
+
}
|
|
254
279
|
const key = formatExplainKey(k);
|
|
255
280
|
if (includeValue) {
|
|
256
281
|
if (k === 'entity_id') {
|
|
@@ -21,4 +21,7 @@ export declare type QueryValueTypeWithCompareOperator = Partial<{
|
|
|
21
21
|
}> & {
|
|
22
22
|
schema?: never;
|
|
23
23
|
};
|
|
24
|
-
export declare type QueryType = Record<string, QueryValueType | QueryValueTypeWithCompareOperator | QueryType[] | undefined
|
|
24
|
+
export declare type QueryType = Record<string, QueryValueType | QueryValueTypeWithCompareOperator | QueryType[] | undefined> & Partial<{
|
|
25
|
+
$and: QueryType[];
|
|
26
|
+
$or: QueryType[];
|
|
27
|
+
}>;
|
|
@@ -141,7 +141,7 @@ try {
|
|
|
141
141
|
catch (e) {
|
|
142
142
|
// ignore
|
|
143
143
|
}
|
|
144
|
-
// 国外的缩略,分为:个位数、
|
|
144
|
+
// 国外的缩略,分为:个位数、K,M,B,四个等级
|
|
145
145
|
try {
|
|
146
146
|
numeral_1.default.register('format', 'engabbreviation', {
|
|
147
147
|
regexps: {
|
|
@@ -160,15 +160,15 @@ try {
|
|
|
160
160
|
}
|
|
161
161
|
else if (abs < million) {
|
|
162
162
|
adjValue = value / thousand;
|
|
163
|
-
unit = '
|
|
163
|
+
unit = 'K';
|
|
164
164
|
}
|
|
165
165
|
else if (abs < billion) {
|
|
166
166
|
adjValue = value / million;
|
|
167
|
-
unit = '
|
|
167
|
+
unit = 'M';
|
|
168
168
|
}
|
|
169
169
|
else {
|
|
170
170
|
adjValue = value / billion;
|
|
171
|
-
unit = '
|
|
171
|
+
unit = 'B';
|
|
172
172
|
}
|
|
173
173
|
return numeral_1.default._.numberToFormat(adjValue, format.substring(0, format.length - 1), roundingFunction) + unit;
|
|
174
174
|
},
|
|
@@ -178,15 +178,15 @@ try {
|
|
|
178
178
|
const billion = 1000000000.0; // 十亿
|
|
179
179
|
let scale = 1.0;
|
|
180
180
|
let numberString = string;
|
|
181
|
-
if (string.endsWith('k')) {
|
|
181
|
+
if (string.endsWith('k') || string.endsWith('K')) {
|
|
182
182
|
scale = thousand;
|
|
183
183
|
numberString = string.substring(0, string.length - 1);
|
|
184
184
|
}
|
|
185
|
-
else if (string.endsWith('m')) {
|
|
185
|
+
else if (string.endsWith('m') || string.endsWith('M')) {
|
|
186
186
|
scale = million;
|
|
187
187
|
numberString = string.substring(0, string.length - 1);
|
|
188
188
|
}
|
|
189
|
-
else if (string.endsWith('b')) {
|
|
189
|
+
else if (string.endsWith('b') || string.endsWith('B')) {
|
|
190
190
|
scale = billion;
|
|
191
191
|
numberString = string.substring(0, string.length - 1);
|
|
192
192
|
}
|