semanticdb-core 1.0.19 → 1.0.21

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,4 +1,4 @@
1
- import { GroupbyItemType, LogicformType } from './logicform';
1
+ import { GroupbyItemType, LogicformType, PredItemType } from './logicform';
2
2
  import { QueryType } from './types/query';
3
3
  /**
4
4
  * 判断一个维度是否在查询中被使用
@@ -14,6 +14,7 @@ import { QueryType } from './types/query';
14
14
  */
15
15
  export declare const isDimensionInQuery: (query: QueryType, dimension: string, strictMode?: boolean) => boolean;
16
16
  export declare const isDimensionInGroupby: (groupby: GroupbyItemType[], dimension: string) => boolean;
17
+ export declare const isDimensionInPred: (predItem: PredItemType, dimension: string, strictMode?: boolean) => boolean;
17
18
  /**
18
19
  *
19
20
  * @param logicform
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getValueByChain = exports.getFlattenQuery = exports.isDimensionInLogicform = exports.isDimensionInGroupby = exports.isDimensionInQuery = void 0;
3
+ exports.getValueByChain = exports.getFlattenQuery = exports.isDimensionInLogicform = exports.isDimensionInPred = exports.isDimensionInGroupby = exports.isDimensionInQuery = void 0;
4
4
  /**
5
5
  * 判断一个维度是否在查询中被使用
6
6
  * @param query - 查询对象
@@ -19,7 +19,7 @@ const isDimensionInQuery = (query, dimension, strictMode = true) => {
19
19
  return dimension in flattenQuery;
20
20
  }
21
21
  for (const k of Object.keys(flattenQuery)) {
22
- if (k.startsWith(`${dimension}_`)) {
22
+ if (k.startsWith(`${dimension}_`) || k === dimension) {
23
23
  return true;
24
24
  }
25
25
  }
@@ -38,6 +38,15 @@ const isDimensionInGroupby = (groupby, dimension) => {
38
38
  return false;
39
39
  };
40
40
  exports.isDimensionInGroupby = isDimensionInGroupby;
41
+ const isDimensionInPred = (predItem, dimension, strictMode = true) => {
42
+ if (typeof predItem.pred !== 'string')
43
+ return false;
44
+ if (!strictMode && predItem.pred.startsWith(`${dimension}_`)) {
45
+ return true;
46
+ }
47
+ return predItem.pred === dimension;
48
+ };
49
+ exports.isDimensionInPred = isDimensionInPred;
41
50
  /**
42
51
  *
43
52
  * @param logicform
@@ -56,6 +65,9 @@ const isDimensionInLogicform = (logicform, dimension, strictMode = true) => {
56
65
  if ((0, exports.isDimensionInQuery)(predItem.query || {}, dimension, strictMode)) {
57
66
  return true;
58
67
  }
68
+ if ((0, exports.isDimensionInPred)(predItem, dimension, strictMode)) {
69
+ return true;
70
+ }
59
71
  }
60
72
  }
61
73
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semanticdb-core",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [