@visactor/vbi 0.4.17 → 0.4.20

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.
Files changed (60) hide show
  1. package/dist/builder/adapters/index.d.ts +1 -0
  2. package/dist/builder/adapters/vquery-vseed/build-vquery.d.ts +3 -0
  3. package/dist/builder/adapters/vquery-vseed/build-vseed.d.ts +3 -0
  4. package/dist/builder/adapters/vquery-vseed/index.d.ts +7 -0
  5. package/dist/builder/adapters/vquery-vseed/types.d.ts +4 -0
  6. package/dist/builder/{vbi-builder.d.ts → builder.d.ts} +8 -8
  7. package/dist/builder/features/chart-type/chart-type-builder.d.ts +20 -1
  8. package/dist/builder/features/chart-type/dimension-encoding.d.ts +4 -0
  9. package/dist/builder/features/chart-type/measure-encoding.d.ts +4 -0
  10. package/dist/builder/features/chart-type/reapply-dimension-encodings.d.ts +2 -0
  11. package/dist/builder/features/chart-type/reapply-measure-encodings.d.ts +2 -0
  12. package/dist/builder/features/dimensions/dim-builder.d.ts +3 -2
  13. package/dist/builder/features/dimensions/dim-node-builder.d.ts +32 -1
  14. package/dist/builder/features/havingFilter/having-builder.d.ts +2 -2
  15. package/dist/builder/features/havingFilter/having-node-builder.d.ts +10 -1
  16. package/dist/builder/features/measures/mea-builder.d.ts +3 -2
  17. package/dist/builder/features/measures/mea-node-builder.d.ts +33 -3
  18. package/dist/builder/features/whereFilter/where-builder.d.ts +2 -2
  19. package/dist/builder/features/whereFilter/where-node-builder.d.ts +11 -2
  20. package/dist/builder/index.d.ts +2 -1
  21. package/dist/builder/modules/build.d.ts +2 -2
  22. package/dist/builder/modules/index.d.ts +2 -5
  23. package/dist/builder/modules/is-empty.d.ts +1 -1
  24. package/dist/index.cjs +1578 -386
  25. package/dist/index.d.ts +6 -3
  26. package/dist/index.js +1567 -384
  27. package/dist/pipeline/vqueryDSL/aggregateMap.d.ts +50 -0
  28. package/dist/pipeline/vqueryDSL/buildOrderBy.d.ts +2 -0
  29. package/dist/pipeline/vqueryDSL/index.d.ts +2 -3
  30. package/dist/pipeline/vqueryDSL/resolveDatePredicate.d.ts +7 -0
  31. package/dist/pipeline/vqueryDSL/types.d.ts +6 -6
  32. package/dist/types/builder/VBIInterface.d.ts +7 -7
  33. package/dist/types/builder/adapter.d.ts +23 -0
  34. package/dist/types/builder/build-vseed.d.ts +3 -0
  35. package/dist/types/builder/context.d.ts +2 -2
  36. package/dist/types/builder/index.d.ts +4 -2
  37. package/dist/types/builder/observe.d.ts +2 -1
  38. package/dist/types/connector/query.d.ts +1 -0
  39. package/dist/types/dsl/dimensions/aggregate.d.ts +15 -0
  40. package/dist/types/dsl/dimensions/dimensions.d.ts +62 -0
  41. package/dist/types/dsl/encoding.d.ts +2 -2
  42. package/dist/types/dsl/havingFilter/having.d.ts +20 -1
  43. package/dist/types/dsl/index.d.ts +6 -4
  44. package/dist/types/dsl/measures/aggregate.d.ts +14 -2
  45. package/dist/types/dsl/measures/measures.d.ts +177 -8
  46. package/dist/types/dsl/sort.d.ts +13 -0
  47. package/dist/types/dsl/vbi/vbi.d.ts +103 -7
  48. package/dist/types/dsl/whereFilter/date.d.ts +95 -0
  49. package/dist/types/dsl/whereFilter/filters.d.ts +142 -5
  50. package/dist/utils/filter-guards.d.ts +2 -2
  51. package/dist/vbi/create-vbi.d.ts +14 -14
  52. package/dist/vbi/from/from-vbi-dsl-input.d.ts +4 -3
  53. package/dist/vbi/from/set-base-dsl-fields.d.ts +2 -2
  54. package/dist/vbi/generate-empty-dsl.d.ts +2 -2
  55. package/dist/vbi/normalize/types.d.ts +3 -3
  56. package/dist/vbi.d.ts +1 -14
  57. package/package.json +5 -5
  58. package/dist/builder/modules/build-vquery.d.ts +0 -4
  59. package/dist/builder/modules/build-vseed.d.ts +0 -8
  60. package/dist/builder/modules/create-builder-features.d.ts +0 -14
@@ -0,0 +1 @@
1
+ export * from './vquery-vseed';
@@ -0,0 +1,3 @@
1
+ import type { VBIChartQueryBuilder } from '../../../types';
2
+ import type { DefaultVBIQueryDSL } from './types';
3
+ export declare const buildVQueryDSL: VBIChartQueryBuilder<DefaultVBIQueryDSL>;
@@ -0,0 +1,3 @@
1
+ import type { VBIChartSeedBuilder } from '../../../types';
2
+ import type { DefaultVBIQueryDSL, DefaultVBISeedDSL } from './types';
3
+ export declare const buildVSeedDSL: VBIChartSeedBuilder<DefaultVBIQueryDSL, DefaultVBISeedDSL>;
@@ -0,0 +1,7 @@
1
+ import type { VBIChartBuilderAdapters } from '../../../types';
2
+ import type { DefaultVBIQueryDSL, DefaultVBISeedDSL } from './types';
3
+ export type { DefaultVBIQueryDSL, DefaultVBISeedDSL } from './types';
4
+ export { buildVQueryDSL } from './build-vquery';
5
+ export { buildVSeedDSL } from './build-vseed';
6
+ export declare const defaultVBIChartBuilderAdapters: VBIChartBuilderAdapters<DefaultVBIQueryDSL, DefaultVBISeedDSL>;
7
+ export declare const resolveVBIChartBuilderAdapters: <TQueryDSL = DefaultVBIQueryDSL, TSeedDSL = DefaultVBISeedDSL>(adapters?: Partial<VBIChartBuilderAdapters<TQueryDSL, TSeedDSL>>) => VBIChartBuilderAdapters<TQueryDSL, TSeedDSL>;
@@ -0,0 +1,4 @@
1
+ import type { VSeedDSL } from '@visactor/vseed';
2
+ import type { VQueryDSL } from '@visactor/vquery';
3
+ export type DefaultVBIQueryDSL = VQueryDSL;
4
+ export type DefaultVBISeedDSL = VSeedDSL;
@@ -1,11 +1,11 @@
1
1
  import * as Y from 'yjs';
2
- import type { VSeedDSL } from '@visactor/vseed';
3
- import type { VQueryDSL } from '@visactor/vquery';
2
+ import type { DefaultVBIQueryDSL, DefaultVBISeedDSL } from './adapters/vquery-vseed';
4
3
  import { DimensionsBuilder, MeasuresBuilder, HavingFilterBuilder, WhereFilterBuilder, ChartTypeBuilder, ThemeBuilder, LocaleBuilder, LimitBuilder, UndoManager } from './features';
5
- import type { VBIDSL, VBIBuilderInterface } from '../types';
6
- export declare class VBIBuilder implements VBIBuilderInterface {
4
+ import type { BuildVSeedOptions, VBIChartDSL, VBIChartBuilderAdapters, VBIChartBuilderInterface, VBIChartBuilderOptions } from '../types';
5
+ export declare class VBIChartBuilder<TQueryDSL = DefaultVBIQueryDSL, TSeedDSL = DefaultVBISeedDSL> implements VBIChartBuilderInterface<TQueryDSL, TSeedDSL> {
7
6
  doc: Y.Doc;
8
7
  dsl: Y.Map<any>;
8
+ adapters: VBIChartBuilderAdapters<TQueryDSL, TSeedDSL>;
9
9
  chartType: ChartTypeBuilder;
10
10
  measures: MeasuresBuilder;
11
11
  dimensions: DimensionsBuilder;
@@ -15,12 +15,12 @@ export declare class VBIBuilder implements VBIBuilderInterface {
15
15
  locale: LocaleBuilder;
16
16
  limit: LimitBuilder;
17
17
  undoManager: UndoManager;
18
- constructor(doc: Y.Doc);
18
+ constructor(doc: Y.Doc, options?: VBIChartBuilderOptions<TQueryDSL, TSeedDSL>);
19
19
  applyUpdate: (update: Uint8Array, transactionOrigin?: any) => void;
20
20
  encodeStateAsUpdate: (targetStateVector?: Uint8Array) => Uint8Array<ArrayBufferLike>;
21
- buildVSeed: () => Promise<VSeedDSL>;
22
- buildVQuery: () => VQueryDSL;
23
- build: () => VBIDSL;
21
+ buildVSeed: (options?: BuildVSeedOptions) => Promise<TSeedDSL>;
22
+ buildVQuery: () => TQueryDSL;
23
+ build: () => VBIChartDSL;
24
24
  isEmpty: () => boolean;
25
25
  getSchema: () => Promise<{
26
26
  name: string;
@@ -4,11 +4,12 @@ import * as Y from 'yjs';
4
4
  * @description 图表类型构建器,用于切换和获取图表类型。支持表格、柱状图、折线图、饼图、散点图等多种图表类型
5
5
  */
6
6
  export declare class ChartTypeBuilder {
7
+ private doc;
7
8
  private dsl;
8
9
  /**
9
10
  * @description 构造函数
10
11
  */
11
- constructor(_doc: Y.Doc, dsl: Y.Map<any>);
12
+ constructor(doc: Y.Doc, dsl: Y.Map<any>);
12
13
  /**
13
14
  * @description 监听图表类型变化
14
15
  * @param callback - 回调函数
@@ -28,6 +29,24 @@ export declare class ChartTypeBuilder {
28
29
  * @description 获取当前图表类型
29
30
  */
30
31
  getChartType(): string;
32
+ /**
33
+ * @description 获取当前图表类型支持的维度编码
34
+ */
35
+ getSupportedDimensionEncodings(): import("./dimension-encoding").SupportedDimensionEncoding[];
36
+ /**
37
+ * @description 根据当前图表类型,按维度顺序返回推荐的维度编码
38
+ * @param dimensionCount - 维度数量,默认使用当前 DSL 中的维度数量
39
+ */
40
+ getRecommendedDimensionEncodings(dimensionCount?: number): import("./dimension-encoding").SupportedDimensionEncoding[];
41
+ /**
42
+ * @description 获取当前图表类型支持的指标编码
43
+ */
44
+ getSupportedMeasureEncodings(): import("./measure-encoding").SupportedMeasureEncoding[];
45
+ /**
46
+ * @description 根据当前图表类型,按指标顺序返回推荐的指标编码
47
+ * @param measureCount - 指标数量,默认使用当前 DSL 中的指标数量
48
+ */
49
+ getRecommendedMeasureEncodings(measureCount?: number): import("./measure-encoding").SupportedMeasureEncoding[];
31
50
  /**
32
51
  * @description 导出为 JSON
33
52
  */
@@ -0,0 +1,4 @@
1
+ import type { VBIDimension } from '../../../types';
2
+ export type SupportedDimensionEncoding = NonNullable<VBIDimension['encoding']>;
3
+ export declare const getSupportedDimensionEncodingsForChartType: (chartType: string) => SupportedDimensionEncoding[];
4
+ export declare const getRecommendedDimensionEncodingsForChartType: (chartType: string, dimensionCount: number) => SupportedDimensionEncoding[];
@@ -0,0 +1,4 @@
1
+ import type { VBIMeasure } from '../../../types';
2
+ export type SupportedMeasureEncoding = NonNullable<VBIMeasure['encoding']>;
3
+ export declare const getSupportedMeasureEncodingsForChartType: (chartType: string) => SupportedMeasureEncoding[];
4
+ export declare const getRecommendedMeasureEncodingsForChartType: (chartType: string, measureCount: number) => SupportedMeasureEncoding[];
@@ -0,0 +1,2 @@
1
+ import * as Y from 'yjs';
2
+ export declare const reapplyDimensionEncodings: (dsl: Y.Map<any>, chartType: string) => void;
@@ -0,0 +1,2 @@
1
+ import * as Y from 'yjs';
2
+ export declare const reapplyMeasureEncodings: (dsl: Y.Map<any>, chartType: string) => void;
@@ -1,10 +1,11 @@
1
1
  import * as Y from 'yjs';
2
- import type { ObserveCallback, VBIDimension, VBIDimensionGroup, VBIDimensionTree } from '../../../types';
2
+ import type { ObserveDeepCallback, VBIDimension, VBIDimensionGroup, VBIDimensionTree } from '../../../types';
3
3
  import { DimensionNodeBuilder } from './dim-node-builder';
4
4
  /**
5
5
  * @description 维度构建器,用于添加、修改、删除维度配置。维度是数据的分类字段,如:时间、地区、产品类别
6
6
  */
7
7
  export declare class DimensionsBuilder {
8
+ private doc;
8
9
  private dsl;
9
10
  constructor(doc: Y.Doc, dsl: Y.Map<any>);
10
11
  /**
@@ -42,7 +43,7 @@ export declare class DimensionsBuilder {
42
43
  * @param callback - 回调函数
43
44
  * @returns 取消监听的函数
44
45
  */
45
- observe(callback: ObserveCallback): () => void;
46
+ observe(callback: ObserveDeepCallback): () => void;
46
47
  static isDimensionNode(node: VBIDimensionTree[0]): node is VBIDimension;
47
48
  static isDimensionGroup(node: VBIDimensionTree[0]): node is VBIDimensionGroup;
48
49
  }
@@ -1,5 +1,5 @@
1
1
  import * as Y from 'yjs';
2
- import { VBIDimension } from '../../../types';
2
+ import type { VBIDimension, VBISort } from '../../../types';
3
3
  /**
4
4
  * @description 维度节点构建器,用于配置单个维度
5
5
  */
@@ -14,11 +14,42 @@ export declare class DimensionNodeBuilder {
14
14
  * @description 获取字段名
15
15
  */
16
16
  getField(): string;
17
+ /**
18
+ * @description 获取图表编码位置
19
+ */
20
+ getEncoding(): VBIDimension['encoding'] | undefined;
21
+ /**
22
+ * @description 获取排序配置
23
+ */
24
+ getSort(): VBISort | undefined;
17
25
  /**
18
26
  * @description 设置显示名称
19
27
  * @param alias - 显示名称
20
28
  */
21
29
  setAlias(alias: string): this;
30
+ /**
31
+ * @description 设置图表编码位置
32
+ * @param encoding - 维度编码位置
33
+ */
34
+ setEncoding(encoding: NonNullable<VBIDimension['encoding']>): this;
35
+ /**
36
+ * @description 设置排序配置
37
+ * @param sort - 排序配置
38
+ */
39
+ setSort(sort: VBISort): this;
40
+ /**
41
+ * @description 设置日期聚合函数
42
+ * @param aggregate - 日期聚合配置
43
+ */
44
+ setAggregate(aggregate: NonNullable<VBIDimension['aggregate']>): this;
45
+ /**
46
+ * @description 清除日期聚合函数
47
+ */
48
+ clearAggregate(): this;
49
+ /**
50
+ * @description 清除排序配置
51
+ */
52
+ clearSort(): this;
22
53
  /**
23
54
  * @description 导出为 JSON
24
55
  */
@@ -1,5 +1,5 @@
1
1
  import * as Y from 'yjs';
2
- import type { VBIHavingGroup, ObserveCallback } from '../../../types';
2
+ import type { VBIHavingGroup, ObserveDeepCallback } from '../../../types';
3
3
  import { HavingFilterNodeBuilder } from './having-node-builder';
4
4
  import { HavingGroupBuilder } from './having-group-builder';
5
5
  /**
@@ -56,7 +56,7 @@ export declare class HavingFilterBuilder {
56
56
  * @param callback - 回调函数
57
57
  * @returns 取消监听的函数
58
58
  */
59
- observe(callback: ObserveCallback): () => void;
59
+ observe(callback: ObserveDeepCallback): () => void;
60
60
  /**
61
61
  * @description 判断是否为分组节点
62
62
  */
@@ -1,5 +1,5 @@
1
1
  import * as Y from 'yjs';
2
- import { VBIHavingFilter } from '../../../types';
2
+ import { VBIHavingFilter, VBIHavingAggregate } from '../../../types';
3
3
  /**
4
4
  * @description Having 过滤节点构建器,用于配置单个 Having 过滤条件
5
5
  */
@@ -18,6 +18,10 @@ export declare class HavingFilterNodeBuilder {
18
18
  * @description 获取过滤操作符
19
19
  */
20
20
  getOperator(): string | undefined;
21
+ /**
22
+ * @description 获取聚合配置
23
+ */
24
+ getAggregate(): VBIHavingAggregate | undefined;
21
25
  /**
22
26
  * @description 设置过滤条件的值
23
27
  * @param value - 过滤值
@@ -28,6 +32,11 @@ export declare class HavingFilterNodeBuilder {
28
32
  * @param operator - 操作符
29
33
  */
30
34
  setOperator(operator: string): this;
35
+ /**
36
+ * @description 设置聚合配置
37
+ * @param aggregate - 聚合配置
38
+ */
39
+ setAggregate(aggregate: VBIHavingAggregate): this;
31
40
  /**
32
41
  * @description 导出为 JSON
33
42
  */
@@ -1,10 +1,11 @@
1
1
  import * as Y from 'yjs';
2
- import type { ObserveCallback, VBIMeasure, VBIMeasureGroup, VBIMeasureTree } from '../../../types';
2
+ import type { ObserveDeepCallback, VBIMeasure, VBIMeasureGroup, VBIMeasureTree } from '../../../types';
3
3
  import { MeasureNodeBuilder } from './mea-node-builder';
4
4
  /**
5
5
  * @description 度量构建器,用于添加、修改、删除度量配置。度量是数据的数值字段,如:销售额、利润、数量
6
6
  */
7
7
  export declare class MeasuresBuilder {
8
+ private doc;
8
9
  private dsl;
9
10
  constructor(doc: Y.Doc, dsl: Y.Map<any>);
10
11
  /**
@@ -46,7 +47,7 @@ export declare class MeasuresBuilder {
46
47
  * @param callback - 回调函数
47
48
  * @returns 取消监听的函数
48
49
  */
49
- observe(callback: ObserveCallback): () => void;
50
+ observe(callback: ObserveDeepCallback): () => void;
50
51
  static isMeasureNode(node: VBIMeasureTree[0]): node is VBIMeasure;
51
52
  static isMeasureGroup(node: VBIMeasureTree[0]): node is VBIMeasureGroup;
52
53
  }
@@ -1,5 +1,5 @@
1
1
  import * as Y from 'yjs';
2
- import { VBIMeasure } from '../../../types';
2
+ import type { VBIMeasure, VBIMeasureFormat, VBISort } from '../../../types';
3
3
  /**
4
4
  * @description 度量节点构建器,用于配置单个度量
5
5
  */
@@ -14,6 +14,14 @@ export declare class MeasureNodeBuilder {
14
14
  * @description 获取字段名
15
15
  */
16
16
  getField(): string;
17
+ /**
18
+ * @description 获取图表编码位置
19
+ */
20
+ getEncoding(): VBIMeasure['encoding'] | undefined;
21
+ /**
22
+ * @description 获取排序配置
23
+ */
24
+ getSort(): VBISort | undefined;
17
25
  /**
18
26
  * @description 设置显示名称
19
27
  * @param alias - 显示名称
@@ -21,14 +29,36 @@ export declare class MeasureNodeBuilder {
21
29
  setAlias(alias: string): this;
22
30
  /**
23
31
  * @description 设置图表编码位置
24
- * @param encoding - 编码位置(yAxis/xAxis/color/size)
32
+ * @param encoding - 指标编码位置
25
33
  */
26
- setEncoding(encoding: VBIMeasure['encoding']): this;
34
+ setEncoding(encoding: NonNullable<VBIMeasure['encoding']>): this;
35
+ /**
36
+ * @description 设置排序配置
37
+ * @param sort - 排序配置
38
+ */
39
+ setSort(sort: VBISort): this;
27
40
  /**
28
41
  * @description 设置聚合函数
29
42
  * @param aggregate - 聚合配置
30
43
  */
31
44
  setAggregate(aggregate: VBIMeasure['aggregate']): this;
45
+ /**
46
+ * @description 设置数值格式
47
+ * @param format - 格式配置
48
+ */
49
+ setFormat(format: VBIMeasureFormat): this;
50
+ /**
51
+ * @description 获取数值格式
52
+ */
53
+ getFormat(): VBIMeasureFormat | undefined;
54
+ /**
55
+ * @description 清除数值格式配置
56
+ */
57
+ clearFormat(): this;
58
+ /**
59
+ * @description 清除排序配置
60
+ */
61
+ clearSort(): this;
32
62
  /**
33
63
  * @description 导出为 JSON
34
64
  */
@@ -1,5 +1,5 @@
1
1
  import * as Y from 'yjs';
2
- import type { VBIWhereGroup, ObserveCallback } from '../../../types';
2
+ import type { VBIWhereGroup, ObserveDeepCallback } from '../../../types';
3
3
  import { WhereFilterNodeBuilder } from './where-node-builder';
4
4
  import { WhereGroupBuilder } from './where-group-builder';
5
5
  /**
@@ -56,7 +56,7 @@ export declare class WhereFilterBuilder {
56
56
  * @param callback - 回调函数
57
57
  * @returns 取消监听的函数
58
58
  */
59
- observe(callback: ObserveCallback): () => void;
59
+ observe(callback: ObserveDeepCallback): () => void;
60
60
  /**
61
61
  * @description 判断是否为分组节点
62
62
  */
@@ -1,5 +1,5 @@
1
1
  import * as Y from 'yjs';
2
- import { VBIFilter } from '../../../types';
2
+ import type { VBIWhereDatePredicate, VBIWhereFilter } from '../../../types';
3
3
  /**
4
4
  * @description Where 过滤节点构建器,用于配置单个 Where 过滤条件
5
5
  */
@@ -33,8 +33,17 @@ export declare class WhereFilterNodeBuilder {
33
33
  * @param value - 过滤值
34
34
  */
35
35
  setValue(value: unknown): this;
36
+ /**
37
+ * @description 设置日期过滤条件
38
+ * @param predicate - 日期谓词
39
+ */
40
+ setDate(predicate: VBIWhereDatePredicate): this;
41
+ /**
42
+ * @description 获取日期过滤条件,非日期过滤返回 undefined
43
+ */
44
+ getDate(): VBIWhereDatePredicate | undefined;
36
45
  /**
37
46
  * @description 导出为 JSON
38
47
  */
39
- toJSON(): VBIFilter;
48
+ toJSON(): VBIWhereFilter;
40
49
  }
@@ -1,3 +1,4 @@
1
- export { VBIBuilder } from './vbi-builder';
1
+ export { VBIChartBuilder } from './builder';
2
2
  export { VBI } from '../vbi';
3
+ export * from './adapters';
3
4
  export { MeasuresBuilder, DimensionsBuilder, ChartTypeBuilder, HavingFilterBuilder, WhereFilterBuilder, ThemeBuilder, LocaleBuilder, LimitBuilder, UndoManager, } from './features';
@@ -1,3 +1,3 @@
1
1
  import * as Y from 'yjs';
2
- import type { VBIDSL } from '../../types';
3
- export declare const buildVBIDSL: (dsl: Y.Map<any>) => VBIDSL;
2
+ import type { VBIChartDSL } from '../../types';
3
+ export declare const buildVBIChartDSL: (dsl: Y.Map<any>) => VBIChartDSL;
@@ -1,8 +1,5 @@
1
1
  export { applyUpdateToDoc } from './apply-update';
2
2
  export { encodeDocStateAsUpdate } from './encode-state-as-update';
3
- export { buildVBIDSL } from './build';
4
- export { buildVQueryDSL } from './build-vquery';
5
- export { buildVSeedDSL } from './build-vseed';
6
- export { isEmptyVBIDSL } from './is-empty';
3
+ export { buildVBIChartDSL } from './build';
4
+ export { isEmptyVBIChartDSL } from './is-empty';
7
5
  export { getBuilderSchema } from './get-schema';
8
- export { createBuilderFeatures } from './create-builder-features';
@@ -1,2 +1,2 @@
1
1
  import * as Y from 'yjs';
2
- export declare const isEmptyVBIDSL: (dsl: Y.Map<any>) => boolean;
2
+ export declare const isEmptyVBIChartDSL: (dsl: Y.Map<any>) => boolean;