semanticdb-core 1.1.40 → 1.1.41
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.
|
@@ -111,7 +111,7 @@ const explainSchema = (logicform, schemas, locale = exports.DEFAULT_EXPLAIN_LOGI
|
|
|
111
111
|
exports.explainSchema = explainSchema;
|
|
112
112
|
const explainQuery = (logicform, _schemas, locale = exports.DEFAULT_EXPLAIN_LOGICFORM_LOCALE) => {
|
|
113
113
|
(0, exports.normalizeExplainLogicformLocale)(locale);
|
|
114
|
-
return explainFilterLikeQuery(logicform.query ? (0, logicform_utils_1.getFlattenQuery)(logicform.query) : undefined, '筛选', true);
|
|
114
|
+
return explainFilterLikeQuery(logicform.query ? (0, logicform_utils_1.getFlattenQuery)(logicform.query, _schemas) : undefined, '筛选', true);
|
|
115
115
|
};
|
|
116
116
|
exports.explainQuery = explainQuery;
|
|
117
117
|
const explainEntityID = (logicform, _schemas, locale = exports.DEFAULT_EXPLAIN_LOGICFORM_LOCALE) => {
|
|
@@ -55,7 +55,7 @@ export declare const isDimensionInLogicform: (logicform: LogicformType, dimensio
|
|
|
55
55
|
* }
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
|
-
export declare const getFlattenQuery: (query: QueryType) => QueryType;
|
|
58
|
+
export declare const getFlattenQuery: (query: QueryType, schemasDict?: Record<string, SchemaType>) => QueryType;
|
|
59
59
|
/**
|
|
60
60
|
* 根据链条字符串在查询对象中查找对应的值
|
|
61
61
|
* @param query - 查询对象
|
|
@@ -216,14 +216,14 @@ exports.isDimensionInLogicform = isDimensionInLogicform;
|
|
|
216
216
|
* }
|
|
217
217
|
* ```
|
|
218
218
|
*/
|
|
219
|
-
const getFlattenQuery = (query) => {
|
|
219
|
+
const getFlattenQuery = (query, schemasDict) => {
|
|
220
220
|
let flattenQuery = {};
|
|
221
221
|
for (const [k, v] of Object.entries(query)) {
|
|
222
222
|
if (Array.isArray(v) && (k === '$and' || k === '$or')) {
|
|
223
223
|
const tmp = [];
|
|
224
224
|
v.forEach((item) => {
|
|
225
225
|
if (typeof item === 'object' && item) {
|
|
226
|
-
tmp.push((0, exports.getFlattenQuery)(item));
|
|
226
|
+
tmp.push((0, exports.getFlattenQuery)(item, schemasDict));
|
|
227
227
|
}
|
|
228
228
|
});
|
|
229
229
|
flattenQuery[k] = tmp;
|
|
@@ -232,11 +232,16 @@ const getFlattenQuery = (query) => {
|
|
|
232
232
|
v &&
|
|
233
233
|
'schema' in v &&
|
|
234
234
|
'query' in v &&
|
|
235
|
-
!('groupby' in v)
|
|
236
|
-
!('entity_id' in v) // entity_id的话,也没必要收起来
|
|
235
|
+
!('groupby' in v) // 不是复合的logicform
|
|
237
236
|
) {
|
|
238
|
-
|
|
239
|
-
const
|
|
237
|
+
const subSchema = typeof v.schema === 'string' && schemasDict ? schemasDict[v.schema] : undefined;
|
|
238
|
+
const idProperty = subSchema ? (0, schema_utils_1.findPropertyByType)('ID', subSchema) : undefined;
|
|
239
|
+
if ('entity_id' in v && !idProperty) {
|
|
240
|
+
flattenQuery[k] = v;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
// 这里是一个logicform。传了schemas时,把entity_id临时映射成ID属性参与拍平。
|
|
244
|
+
const flattenSubQuery = (0, exports.getFlattenQuery)(Object.assign(Object.assign({}, (v.query || {})), ('entity_id' in v && idProperty ? { [idProperty.name]: v.entity_id } : {})), schemasDict);
|
|
240
245
|
for (const [sk, sv] of Object.entries(flattenSubQuery)) {
|
|
241
246
|
if (Array.isArray(sv) &&
|
|
242
247
|
sv.length &&
|