semanticdb-core 1.1.47 → 1.1.48
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
|
+
}>;
|