semanticdb-core 1.0.33 → 1.0.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.
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getDimensionsInLogicform = exports.getValueByChain = exports.getFlattenQuery = exports.isDimensionInLogicform = exports.isDimensionInPred = exports.isDimensionInGroupby = exports.isDimensionInQuery = void 0;
|
|
4
7
|
const date_1 = require("../common/date");
|
|
5
8
|
const schema_utils_1 = require("../schema/schema.utils");
|
|
9
|
+
const underscore_1 = __importDefault(require("underscore"));
|
|
6
10
|
const tws = (0, date_1.getSupportedTimeWindows)();
|
|
7
11
|
/**
|
|
8
12
|
* 判断一个维度是否在查询中被使用
|
|
@@ -95,6 +99,11 @@ const isDimensionInPred = (predItem, dimension, strictMode = true) => {
|
|
|
95
99
|
if (!strictMode && predItem.pred.startsWith(`${dimension}_`)) {
|
|
96
100
|
return true;
|
|
97
101
|
}
|
|
102
|
+
if (typeof dimension === 'object' &&
|
|
103
|
+
predItem.operator === '$count' &&
|
|
104
|
+
predItem.pred.startsWith('$')) {
|
|
105
|
+
return predItem.pred === `$${dimension.level}`;
|
|
106
|
+
}
|
|
98
107
|
return predItem.pred === dimension;
|
|
99
108
|
};
|
|
100
109
|
exports.isDimensionInPred = isDimensionInPred;
|
|
@@ -125,6 +134,24 @@ const isDimensionInLogicformIgnoreLevel = (logicform, dimension, strictMode = tr
|
|
|
125
134
|
* @returns
|
|
126
135
|
*/
|
|
127
136
|
const isDimensionInLogicform = (logicform, dimension, strictMode = true) => {
|
|
137
|
+
// 对于时间level,有一个在preds里面和count的。 特殊做一下
|
|
138
|
+
if (typeof dimension === 'object' &&
|
|
139
|
+
dimension.level &&
|
|
140
|
+
tws.includes(dimension.level) &&
|
|
141
|
+
logicform.preds) {
|
|
142
|
+
const twPreds = logicform.preds.filter((pred) => pred.operator === '$count' &&
|
|
143
|
+
pred.pred &&
|
|
144
|
+
typeof pred.pred === 'string' &&
|
|
145
|
+
pred.pred.startsWith('$'));
|
|
146
|
+
if (twPreds.length > 0) {
|
|
147
|
+
const minTWGranInLogicform = underscore_1.default.min(twPreds, (i) => tws.indexOf(i.pred.slice(1)));
|
|
148
|
+
// 如果粒度没到,那么就返回false
|
|
149
|
+
if (minTWGranInLogicform && typeof minTWGranInLogicform === 'object') {
|
|
150
|
+
return (tws.indexOf(minTWGranInLogicform.pred.slice(1)) >=
|
|
151
|
+
tws.indexOf(dimension.level));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
128
155
|
const dimInLFIgnoreLevel = isDimensionInLogicformIgnoreLevel(logicform, dimension, strictMode);
|
|
129
156
|
if (!dimInLFIgnoreLevel)
|
|
130
157
|
return dimInLFIgnoreLevel;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semanticdb-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.35",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@types/lodash": "^4.17.16",
|
|
29
29
|
"@types/node": "^22.13.10",
|
|
30
30
|
"@types/numeral": "^2.0.5",
|
|
31
|
+
"@types/underscore": "^1.13.0",
|
|
31
32
|
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
32
33
|
"@typescript-eslint/parser": "^8.26.1",
|
|
33
34
|
"eslint": "^9.22.0",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"json2md": "^2.0.3",
|
|
44
45
|
"moment": "^2.30.1",
|
|
45
|
-
"numeral": "^2.0.6"
|
|
46
|
+
"numeral": "^2.0.6",
|
|
47
|
+
"underscore": "^1.13.7"
|
|
46
48
|
}
|
|
47
49
|
}
|