semanticdb-core 1.0.31 → 1.0.33

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.
@@ -122,11 +122,14 @@ function getMinGran(date, flag = false) {
122
122
  if (date.$options === 'DTD') {
123
123
  return 'day';
124
124
  }
125
+ const checkLTEValid = (lte, tw) => {
126
+ return (0, moment_1.default)(lte).isSame((0, moment_1.default)(lte).endOf(tw));
127
+ };
125
128
  for (const tw of exports.grans) {
126
- if (tw && tw in date.$options) {
129
+ if (tw && tw in date.$options && checkLTEValid(date.$lte, tw)) {
127
130
  return tw;
128
131
  }
129
- if (tw === 'isoWeek' && 'week' in date.$options) {
132
+ if (tw === 'isoWeek' && 'week' in date.$options && checkLTEValid(date.$lte, tw)) {
130
133
  return tw;
131
134
  }
132
135
  }
@@ -98,14 +98,8 @@ const isDimensionInPred = (predItem, dimension, strictMode = true) => {
98
98
  return predItem.pred === dimension;
99
99
  };
100
100
  exports.isDimensionInPred = isDimensionInPred;
101
- /**
102
- *
103
- * @param logicform
104
- * @param dimension
105
- * @param strictMode 是否严格模式,严格模式下,只有完全匹配才返回true,非严格模式下,只要包含就返回true
106
- * @returns
107
- */
108
- const isDimensionInLogicform = (logicform, dimension, strictMode = true) => {
101
+ // 下面isDimensionInLogicform的帮助函数
102
+ const isDimensionInLogicformIgnoreLevel = (logicform, dimension, strictMode = true) => {
109
103
  if ((0, exports.isDimensionInQuery)(logicform.query || {}, dimension, strictMode))
110
104
  return true;
111
105
  if (logicform.groupby && (0, exports.isDimensionInGroupby)(logicform.groupby, dimension)) {
@@ -123,6 +117,29 @@ const isDimensionInLogicform = (logicform, dimension, strictMode = true) => {
123
117
  }
124
118
  return false;
125
119
  };
120
+ /**
121
+ *
122
+ * @param logicform
123
+ * @param dimension
124
+ * @param strictMode 是否严格模式,严格模式下,只有完全匹配才返回true,非严格模式下,只要包含就返回true
125
+ * @returns
126
+ */
127
+ const isDimensionInLogicform = (logicform, dimension, strictMode = true) => {
128
+ const dimInLFIgnoreLevel = isDimensionInLogicformIgnoreLevel(logicform, dimension, strictMode);
129
+ if (!dimInLFIgnoreLevel)
130
+ return dimInLFIgnoreLevel;
131
+ if (typeof dimension === 'string' || !dimension.level)
132
+ return dimInLFIgnoreLevel;
133
+ if (!logicform.groupby)
134
+ return dimInLFIgnoreLevel;
135
+ // 如果在query和groupby里面都有,那么要拿联合最小粒度。
136
+ if (!logicform.groupby.find((gi) => gi._id === dimension._id))
137
+ return dimInLFIgnoreLevel;
138
+ if (!(0, exports.isDimensionInQuery)(logicform.query || {}, dimension, strictMode))
139
+ return dimInLFIgnoreLevel;
140
+ const dimInGroupby = (0, exports.isDimensionInGroupby)(logicform.groupby, dimension);
141
+ return dimInGroupby;
142
+ };
126
143
  exports.isDimensionInLogicform = isDimensionInLogicform;
127
144
  /**
128
145
  * 将嵌套的查询对象扁平化
@@ -21,7 +21,7 @@ export interface SchemaTypeDraft {
21
21
  drilldown_blacklist?: string[];
22
22
  };
23
23
  drilldown?: GroupbyItemType[];
24
- projections?: string[];
24
+ projections?: any[];
25
25
  etl?: any;
26
26
  }
27
27
  export interface SchemaType extends SchemaTypeDraft {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semanticdb-core",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [