@visactor/vbi 0.0.0 → 0.4.13
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.
- package/LICENSE +21 -0
- package/dist/builder/sub-builders/havingFilters/having-builder.d.ts +33 -20
- package/dist/builder/sub-builders/havingFilters/having-group-builder.d.ts +48 -0
- package/dist/builder/sub-builders/havingFilters/having-node-builder.d.ts +8 -0
- package/dist/builder/sub-builders/havingFilters/index.d.ts +1 -0
- package/dist/builder/sub-builders/index.d.ts +1 -1
- package/dist/builder/sub-builders/whereFilters/index.d.ts +1 -0
- package/dist/builder/sub-builders/whereFilters/where-builder.d.ts +30 -17
- package/dist/builder/sub-builders/whereFilters/where-group-builder.d.ts +48 -0
- package/dist/builder/sub-builders/whereFilters/where-node-builder.d.ts +8 -0
- package/dist/index.cjs +424 -129
- package/dist/index.js +406 -120
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/vqueryDSL/buildGroupBy.d.ts +2 -0
- package/dist/pipeline/vqueryDSL/buildHaving.d.ts +2 -0
- package/dist/pipeline/vqueryDSL/buildLimit.d.ts +2 -0
- package/dist/pipeline/vqueryDSL/buildSelect.d.ts +2 -0
- package/dist/pipeline/vqueryDSL/buildWhere.d.ts +2 -0
- package/dist/pipeline/vqueryDSL/index.d.ts +4 -1
- package/dist/pipeline/vqueryDSL/types.d.ts +7 -0
- package/dist/types/dsl/havingFilters/having.d.ts +12 -7
- package/dist/types/dsl/index.d.ts +4 -2
- package/dist/types/dsl/vbi/vbi.d.ts +2 -10
- package/dist/types/dsl/whereFilters/filters.d.ts +12 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/utils/id.d.ts +3 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +38 -23
- package/dist/pipeline/vqueryDSL/buildVQuery.d.ts +0 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 VisActor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as Y from 'yjs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VBIHavingClause, ObserveCallback } from '../../../types';
|
|
3
3
|
import { HavingFiltersNodeBuilder } from './having-node-builder';
|
|
4
|
-
import
|
|
4
|
+
import { HavingGroupBuilder } from './having-group-builder';
|
|
5
5
|
/**
|
|
6
6
|
* @description Having 过滤构建器,用于添加、修改、删除分组后过滤条件。Having 过滤在数据聚合后生效,用于筛选分组结果
|
|
7
7
|
*/
|
|
8
8
|
export declare class HavingFiltersBuilder {
|
|
9
9
|
private dsl;
|
|
10
|
-
|
|
10
|
+
private doc;
|
|
11
|
+
constructor(doc: Y.Doc, dsl: Y.Map<any>);
|
|
11
12
|
/**
|
|
12
13
|
* @description 添加一个 Having 过滤条件
|
|
13
14
|
* @param field - 字段名
|
|
@@ -15,25 +16,33 @@ export declare class HavingFiltersBuilder {
|
|
|
15
16
|
*/
|
|
16
17
|
add(field: string, callback: (node: HavingFiltersNodeBuilder) => void): HavingFiltersBuilder;
|
|
17
18
|
/**
|
|
18
|
-
* @description
|
|
19
|
-
* @param
|
|
19
|
+
* @description 添加一个 Having 分组
|
|
20
|
+
* @param op - 逻辑操作符
|
|
20
21
|
* @param callback - 回调函数
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
addGroup(op: 'and' | 'or', callback: (group: HavingGroupBuilder) => void): HavingFiltersBuilder;
|
|
23
24
|
/**
|
|
24
|
-
* @description
|
|
25
|
-
* @param
|
|
25
|
+
* @description 更新指定 ID 的过滤条件
|
|
26
|
+
* @param id - 过滤条件 ID
|
|
27
|
+
* @param callback - 回调函数
|
|
26
28
|
*/
|
|
27
|
-
|
|
29
|
+
update(id: string, callback: (node: HavingFiltersNodeBuilder) => void): HavingFiltersBuilder;
|
|
28
30
|
/**
|
|
29
|
-
* @description
|
|
30
|
-
* @param
|
|
31
|
+
* @description 更新指定 ID 的分组
|
|
32
|
+
* @param id - 分组 ID
|
|
33
|
+
* @param callback - 回调函数
|
|
34
|
+
*/
|
|
35
|
+
updateGroup(id: string, callback: (group: HavingGroupBuilder) => void): HavingFiltersBuilder;
|
|
36
|
+
/**
|
|
37
|
+
* @description 删除指定 ID 的条件或指定索引的项
|
|
38
|
+
* @param idOrIndex - ID 或索引
|
|
31
39
|
*/
|
|
32
|
-
|
|
40
|
+
remove(idOrIndex: string | number): HavingFiltersBuilder;
|
|
33
41
|
/**
|
|
34
|
-
* @description
|
|
42
|
+
* @description 根据 ID 查找条件(过滤或分组)
|
|
43
|
+
* @param id - ID
|
|
35
44
|
*/
|
|
36
|
-
|
|
45
|
+
find(id: string): HavingFiltersNodeBuilder | HavingGroupBuilder | undefined;
|
|
37
46
|
/**
|
|
38
47
|
* @description 清空所有 Having 过滤条件
|
|
39
48
|
*/
|
|
@@ -41,15 +50,19 @@ export declare class HavingFiltersBuilder {
|
|
|
41
50
|
/**
|
|
42
51
|
* @description 导出所有 Having 过滤条件为 JSON 数组
|
|
43
52
|
*/
|
|
44
|
-
toJson():
|
|
45
|
-
/**
|
|
46
|
-
* @description 监听过滤条件变化
|
|
47
|
-
* @param callback - 回调函数
|
|
48
|
-
*/
|
|
53
|
+
toJson(): VBIHavingClause[];
|
|
49
54
|
/**
|
|
50
55
|
* @description 监听过滤条件变化,返回取消监听的函数
|
|
51
56
|
* @param callback - 回调函数
|
|
52
57
|
* @returns 取消监听的函数
|
|
53
58
|
*/
|
|
54
|
-
observe(callback:
|
|
59
|
+
observe(callback: ObserveCallback): () => void;
|
|
60
|
+
/**
|
|
61
|
+
* @description 判断是否为分组节点
|
|
62
|
+
*/
|
|
63
|
+
static isGroup(yMap: Y.Map<any>): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @description 判断是否为叶子节点
|
|
66
|
+
*/
|
|
67
|
+
static isNode(yMap: Y.Map<any>): boolean;
|
|
55
68
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import type { VBIHavingGroup } from '../../../types';
|
|
3
|
+
import { HavingFiltersNodeBuilder } from './having-node-builder';
|
|
4
|
+
/**
|
|
5
|
+
* @description Having 分组构建器,用于配置一组条件的逻辑关系(AND/OR)
|
|
6
|
+
*/
|
|
7
|
+
export declare class HavingGroupBuilder {
|
|
8
|
+
private yMap;
|
|
9
|
+
constructor(yMap: Y.Map<any>);
|
|
10
|
+
/**
|
|
11
|
+
* @description 获取分组 ID
|
|
12
|
+
*/
|
|
13
|
+
getId(): string;
|
|
14
|
+
/**
|
|
15
|
+
* @description 获取逻辑操作符
|
|
16
|
+
*/
|
|
17
|
+
getOperator(): 'and' | 'or';
|
|
18
|
+
/**
|
|
19
|
+
* @description 设置逻辑操作符
|
|
20
|
+
* @param op - 逻辑操作符
|
|
21
|
+
*/
|
|
22
|
+
setOperator(op: 'and' | 'or'): this;
|
|
23
|
+
/**
|
|
24
|
+
* @description 添加一个 Having 过滤条件到分组
|
|
25
|
+
* @param field - 字段名
|
|
26
|
+
* @param callback - 回调函数
|
|
27
|
+
*/
|
|
28
|
+
add(field: string, callback: (node: HavingFiltersNodeBuilder) => void): this;
|
|
29
|
+
/**
|
|
30
|
+
* @description 添加一个嵌套分组到当前分组
|
|
31
|
+
* @param op - 逻辑操作符
|
|
32
|
+
* @param callback - 回调函数
|
|
33
|
+
*/
|
|
34
|
+
addGroup(op: 'and' | 'or', callback: (group: HavingGroupBuilder) => void): this;
|
|
35
|
+
/**
|
|
36
|
+
* @description 删除指定 ID 的条件或指定索引的项
|
|
37
|
+
* @param idOrIndex - ID 或索引
|
|
38
|
+
*/
|
|
39
|
+
remove(idOrIndex: string | number): this;
|
|
40
|
+
/**
|
|
41
|
+
* @description 清空分组内所有条件
|
|
42
|
+
*/
|
|
43
|
+
clear(): this;
|
|
44
|
+
/**
|
|
45
|
+
* @description 导出为 JSON
|
|
46
|
+
*/
|
|
47
|
+
toJson(): VBIHavingGroup;
|
|
48
|
+
}
|
|
@@ -6,10 +6,18 @@ import { VBIHavingFilter } from '../../../types';
|
|
|
6
6
|
export declare class HavingFiltersNodeBuilder {
|
|
7
7
|
private yMap;
|
|
8
8
|
constructor(yMap: Y.Map<any>);
|
|
9
|
+
/**
|
|
10
|
+
* @description 获取节点 ID
|
|
11
|
+
*/
|
|
12
|
+
getId(): string;
|
|
9
13
|
/**
|
|
10
14
|
* @description 获取字段名
|
|
11
15
|
*/
|
|
12
16
|
getField(): string;
|
|
17
|
+
/**
|
|
18
|
+
* @description 获取过滤操作符
|
|
19
|
+
*/
|
|
20
|
+
getOperator(): string | undefined;
|
|
13
21
|
/**
|
|
14
22
|
* @description 设置过滤条件的值
|
|
15
23
|
* @param value - 过滤值
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { MeasuresBuilder } from './measures';
|
|
2
2
|
export { DimensionsBuilder } from './dimensions';
|
|
3
3
|
export { ChartTypeBuilder } from './chart-type';
|
|
4
|
-
export { WhereFiltersBuilder } from './whereFilters';
|
|
4
|
+
export { WhereFiltersBuilder, WhereGroupBuilder } from './whereFilters';
|
|
5
5
|
export { HavingFiltersBuilder } from './havingFilters';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Y from 'yjs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VBIWhereClause, ObserveCallback } from '../../../types';
|
|
3
3
|
import { WhereFilterNodeBuilder } from './where-node-builder';
|
|
4
|
+
import { WhereGroupBuilder } from './where-group-builder';
|
|
4
5
|
/**
|
|
5
6
|
* @description Where 过滤构建器,用于添加、修改、删除行级过滤条件。Where 过滤在数据查询前生效,用于筛选原始数据
|
|
6
7
|
*/
|
|
@@ -15,25 +16,33 @@ export declare class WhereFiltersBuilder {
|
|
|
15
16
|
*/
|
|
16
17
|
add(field: string, callback: (node: WhereFilterNodeBuilder) => void): WhereFiltersBuilder;
|
|
17
18
|
/**
|
|
18
|
-
* @description
|
|
19
|
-
* @param
|
|
19
|
+
* @description 添加一个 Where 分组
|
|
20
|
+
* @param op - 逻辑操作符
|
|
20
21
|
* @param callback - 回调函数
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
addGroup(op: 'and' | 'or', callback: (group: WhereGroupBuilder) => void): WhereFiltersBuilder;
|
|
23
24
|
/**
|
|
24
|
-
* @description
|
|
25
|
-
* @param
|
|
25
|
+
* @description 更新指定 ID 的过滤条件
|
|
26
|
+
* @param id - 过滤条件 ID
|
|
27
|
+
* @param callback - 回调函数
|
|
26
28
|
*/
|
|
27
|
-
|
|
29
|
+
update(id: string, callback: (node: WhereFilterNodeBuilder) => void): WhereFiltersBuilder;
|
|
28
30
|
/**
|
|
29
|
-
* @description
|
|
30
|
-
* @param
|
|
31
|
+
* @description 更新指定 ID 的分组
|
|
32
|
+
* @param id - 分组 ID
|
|
33
|
+
* @param callback - 回调函数
|
|
34
|
+
*/
|
|
35
|
+
updateGroup(id: string, callback: (group: WhereGroupBuilder) => void): WhereFiltersBuilder;
|
|
36
|
+
/**
|
|
37
|
+
* @description 删除指定 ID 的条件或指定索引的项
|
|
38
|
+
* @param idOrIndex - ID 或索引
|
|
31
39
|
*/
|
|
32
|
-
|
|
40
|
+
remove(idOrIndex: string | number): WhereFiltersBuilder;
|
|
33
41
|
/**
|
|
34
|
-
* @description
|
|
42
|
+
* @description 根据 ID 查找条件(过滤或分组)
|
|
43
|
+
* @param id - ID
|
|
35
44
|
*/
|
|
36
|
-
|
|
45
|
+
find(id: string): WhereFilterNodeBuilder | WhereGroupBuilder | undefined;
|
|
37
46
|
/**
|
|
38
47
|
* @description 清空所有 Where 过滤条件
|
|
39
48
|
*/
|
|
@@ -41,15 +50,19 @@ export declare class WhereFiltersBuilder {
|
|
|
41
50
|
/**
|
|
42
51
|
* @description 导出所有 Where 过滤条件为 JSON 数组
|
|
43
52
|
*/
|
|
44
|
-
toJson():
|
|
45
|
-
/**
|
|
46
|
-
* @description 监听过滤条件变化
|
|
47
|
-
* @param callback - 回调函数
|
|
48
|
-
*/
|
|
53
|
+
toJson(): VBIWhereClause[];
|
|
49
54
|
/**
|
|
50
55
|
* @description 监听过滤条件变化,返回取消监听的函数
|
|
51
56
|
* @param callback - 回调函数
|
|
52
57
|
* @returns 取消监听的函数
|
|
53
58
|
*/
|
|
54
59
|
observe(callback: ObserveCallback): () => void;
|
|
60
|
+
/**
|
|
61
|
+
* @description 判断是否为分组节点
|
|
62
|
+
*/
|
|
63
|
+
static isGroup(yMap: Y.Map<any>): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @description 判断是否为叶子节点
|
|
66
|
+
*/
|
|
67
|
+
static isNode(yMap: Y.Map<any>): boolean;
|
|
55
68
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import type { VBIWhereGroup } from '../../../types';
|
|
3
|
+
import { WhereFilterNodeBuilder } from './where-node-builder';
|
|
4
|
+
/**
|
|
5
|
+
* @description Where 分组构建器,用于配置一组条件的逻辑关系(AND/OR)
|
|
6
|
+
*/
|
|
7
|
+
export declare class WhereGroupBuilder {
|
|
8
|
+
private yMap;
|
|
9
|
+
constructor(yMap: Y.Map<any>);
|
|
10
|
+
/**
|
|
11
|
+
* @description 获取分组 ID
|
|
12
|
+
*/
|
|
13
|
+
getId(): string;
|
|
14
|
+
/**
|
|
15
|
+
* @description 获取逻辑操作符
|
|
16
|
+
*/
|
|
17
|
+
getOperator(): 'and' | 'or';
|
|
18
|
+
/**
|
|
19
|
+
* @description 设置逻辑操作符
|
|
20
|
+
* @param op - 逻辑操作符
|
|
21
|
+
*/
|
|
22
|
+
setOperator(op: 'and' | 'or'): this;
|
|
23
|
+
/**
|
|
24
|
+
* @description 添加一个 Where 过滤条件到分组
|
|
25
|
+
* @param field - 字段名
|
|
26
|
+
* @param callback - 回调函数
|
|
27
|
+
*/
|
|
28
|
+
add(field: string, callback: (node: WhereFilterNodeBuilder) => void): this;
|
|
29
|
+
/**
|
|
30
|
+
* @description 添加一个嵌套分组到当前分组
|
|
31
|
+
* @param op - 逻辑操作符
|
|
32
|
+
* @param callback - 回调函数
|
|
33
|
+
*/
|
|
34
|
+
addGroup(op: 'and' | 'or', callback: (group: WhereGroupBuilder) => void): this;
|
|
35
|
+
/**
|
|
36
|
+
* @description 删除指定 ID 的条件或指定索引的项
|
|
37
|
+
* @param idOrIndex - ID 或索引
|
|
38
|
+
*/
|
|
39
|
+
remove(idOrIndex: string | number): this;
|
|
40
|
+
/**
|
|
41
|
+
* @description 清空分组内所有条件
|
|
42
|
+
*/
|
|
43
|
+
clear(): this;
|
|
44
|
+
/**
|
|
45
|
+
* @description 导出为 JSON
|
|
46
|
+
*/
|
|
47
|
+
toJson(): VBIWhereGroup;
|
|
48
|
+
}
|
|
@@ -6,10 +6,18 @@ import { VBIFilter } from '../../../types';
|
|
|
6
6
|
export declare class WhereFilterNodeBuilder {
|
|
7
7
|
private yMap;
|
|
8
8
|
constructor(yMap: Y.Map<any>);
|
|
9
|
+
/**
|
|
10
|
+
* @description 获取节点 ID
|
|
11
|
+
*/
|
|
12
|
+
getId(): string;
|
|
9
13
|
/**
|
|
10
14
|
* @description 获取字段名
|
|
11
15
|
*/
|
|
12
16
|
getField(): string;
|
|
17
|
+
/**
|
|
18
|
+
* @description 获取过滤操作符
|
|
19
|
+
*/
|
|
20
|
+
getOperator(): string | undefined;
|
|
13
21
|
/**
|
|
14
22
|
* @description 设置过滤操作符
|
|
15
23
|
* @param operator - 操作符
|