@visactor/vbi 0.4.19 → 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 (52) hide show
  1. package/dist/builder/adapters/vquery-vseed/build-vquery.d.ts +2 -2
  2. package/dist/builder/adapters/vquery-vseed/build-vseed.d.ts +2 -2
  3. package/dist/builder/adapters/vquery-vseed/index.d.ts +3 -3
  4. package/dist/builder/builder.d.ts +6 -6
  5. package/dist/builder/features/chart-type/chart-type-builder.d.ts +20 -1
  6. package/dist/builder/features/chart-type/dimension-encoding.d.ts +4 -0
  7. package/dist/builder/features/chart-type/measure-encoding.d.ts +4 -0
  8. package/dist/builder/features/chart-type/reapply-dimension-encodings.d.ts +2 -0
  9. package/dist/builder/features/chart-type/reapply-measure-encodings.d.ts +2 -0
  10. package/dist/builder/features/dimensions/dim-builder.d.ts +3 -2
  11. package/dist/builder/features/dimensions/dim-node-builder.d.ts +32 -1
  12. package/dist/builder/features/havingFilter/having-builder.d.ts +2 -2
  13. package/dist/builder/features/measures/mea-builder.d.ts +3 -2
  14. package/dist/builder/features/measures/mea-node-builder.d.ts +33 -3
  15. package/dist/builder/features/whereFilter/where-builder.d.ts +2 -2
  16. package/dist/builder/features/whereFilter/where-node-builder.d.ts +11 -2
  17. package/dist/builder/index.d.ts +1 -1
  18. package/dist/builder/modules/build.d.ts +2 -2
  19. package/dist/builder/modules/index.d.ts +2 -2
  20. package/dist/builder/modules/is-empty.d.ts +1 -1
  21. package/dist/index.cjs +1497 -387
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +1489 -379
  24. package/dist/pipeline/vqueryDSL/aggregateMap.d.ts +23 -3
  25. package/dist/pipeline/vqueryDSL/buildOrderBy.d.ts +2 -0
  26. package/dist/pipeline/vqueryDSL/index.d.ts +2 -2
  27. package/dist/pipeline/vqueryDSL/resolveDatePredicate.d.ts +7 -0
  28. package/dist/pipeline/vqueryDSL/types.d.ts +6 -5
  29. package/dist/types/builder/VBIInterface.d.ts +5 -4
  30. package/dist/types/builder/adapter.d.ts +15 -13
  31. package/dist/types/builder/build-vseed.d.ts +3 -0
  32. package/dist/types/builder/context.d.ts +2 -2
  33. package/dist/types/builder/index.d.ts +4 -3
  34. package/dist/types/builder/observe.d.ts +2 -1
  35. package/dist/types/connector/query.d.ts +1 -0
  36. package/dist/types/dsl/dimensions/aggregate.d.ts +15 -0
  37. package/dist/types/dsl/dimensions/dimensions.d.ts +62 -0
  38. package/dist/types/dsl/encoding.d.ts +2 -2
  39. package/dist/types/dsl/havingFilter/having.d.ts +3 -3
  40. package/dist/types/dsl/index.d.ts +5 -3
  41. package/dist/types/dsl/measures/measures.d.ts +151 -4
  42. package/dist/types/dsl/sort.d.ts +13 -0
  43. package/dist/types/dsl/vbi/vbi.d.ts +90 -5
  44. package/dist/types/dsl/whereFilter/date.d.ts +95 -0
  45. package/dist/types/dsl/whereFilter/filters.d.ts +142 -5
  46. package/dist/utils/filter-guards.d.ts +2 -2
  47. package/dist/vbi/create-vbi.d.ts +6 -7
  48. package/dist/vbi/from/from-vbi-dsl-input.d.ts +3 -3
  49. package/dist/vbi/from/set-base-dsl-fields.d.ts +2 -2
  50. package/dist/vbi/generate-empty-dsl.d.ts +2 -2
  51. package/dist/vbi/normalize/types.d.ts +3 -3
  52. package/package.json +5 -5
@@ -0,0 +1,95 @@
1
+ import { z } from 'zod';
2
+ export type VBIWhereDateInput = string | Date;
3
+ export type VBIWhereDateUnit = 'year' | 'quarter' | 'month' | 'week' | 'day';
4
+ export type VBIWhereDateBounds = '[)' | '[]';
5
+ export type VBIWhereDatePeriod = {
6
+ unit: 'year';
7
+ year: number;
8
+ } | {
9
+ unit: 'quarter';
10
+ year: number;
11
+ quarter: 1 | 2 | 3 | 4;
12
+ } | {
13
+ unit: 'month';
14
+ year: number;
15
+ month: number;
16
+ } | {
17
+ unit: 'week';
18
+ year: number;
19
+ week: number;
20
+ } | {
21
+ unit: 'day';
22
+ date: VBIWhereDateInput;
23
+ };
24
+ export type VBIWhereDatePredicate = {
25
+ type: 'range';
26
+ start: VBIWhereDateInput;
27
+ end: VBIWhereDateInput;
28
+ bounds?: VBIWhereDateBounds;
29
+ } | {
30
+ type: 'relative';
31
+ mode: 'last' | 'next';
32
+ amount: number;
33
+ unit: VBIWhereDateUnit;
34
+ complete?: boolean;
35
+ } | {
36
+ type: 'current';
37
+ unit: VBIWhereDateUnit;
38
+ offset?: number;
39
+ } | ({
40
+ type: 'period';
41
+ } & VBIWhereDatePeriod);
42
+ export declare const zVBIWhereDatePredicate: z.ZodUnion<readonly [z.ZodObject<{
43
+ type: z.ZodLiteral<"range">;
44
+ start: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
45
+ end: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
46
+ bounds: z.ZodOptional<z.ZodEnum<{
47
+ "[)": "[)";
48
+ "[]": "[]";
49
+ }>>;
50
+ }, z.core.$strip>, z.ZodObject<{
51
+ type: z.ZodLiteral<"relative">;
52
+ mode: z.ZodEnum<{
53
+ last: "last";
54
+ next: "next";
55
+ }>;
56
+ amount: z.ZodNumber;
57
+ unit: z.ZodEnum<{
58
+ year: "year";
59
+ quarter: "quarter";
60
+ month: "month";
61
+ week: "week";
62
+ day: "day";
63
+ }>;
64
+ complete: z.ZodOptional<z.ZodBoolean>;
65
+ }, z.core.$strip>, z.ZodObject<{
66
+ type: z.ZodLiteral<"current">;
67
+ unit: z.ZodEnum<{
68
+ year: "year";
69
+ quarter: "quarter";
70
+ month: "month";
71
+ week: "week";
72
+ day: "day";
73
+ }>;
74
+ offset: z.ZodOptional<z.ZodNumber>;
75
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
76
+ type: z.ZodLiteral<"period">;
77
+ }, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
78
+ unit: z.ZodLiteral<"year">;
79
+ year: z.ZodNumber;
80
+ }, z.core.$strip>, z.ZodObject<{
81
+ unit: z.ZodLiteral<"quarter">;
82
+ year: z.ZodNumber;
83
+ quarter: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
84
+ }, z.core.$strip>, z.ZodObject<{
85
+ unit: z.ZodLiteral<"month">;
86
+ year: z.ZodNumber;
87
+ month: z.ZodNumber;
88
+ }, z.core.$strip>, z.ZodObject<{
89
+ unit: z.ZodLiteral<"week">;
90
+ year: z.ZodNumber;
91
+ week: z.ZodNumber;
92
+ }, z.core.$strip>, z.ZodObject<{
93
+ unit: z.ZodLiteral<"day">;
94
+ date: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
95
+ }, z.core.$strip>], "unit">>]>;
@@ -1,22 +1,159 @@
1
1
  import { z } from 'zod';
2
+ import type { VBIWhereDatePredicate } from './date';
3
+ export type { VBIWhereDateInput, VBIWhereDateUnit, VBIWhereDateBounds, VBIWhereDatePeriod, VBIWhereDatePredicate, } from './date';
4
+ export { zVBIWhereDatePredicate } from './date';
2
5
  declare const zWhereLogicalOperator: z.ZodEnum<{
3
6
  and: "and";
4
7
  or: "or";
5
8
  }>;
6
- export declare const zVBIFilter: z.ZodObject<{
9
+ export type VBIWhereScalarFilter = {
10
+ id: string;
11
+ field: string;
12
+ op: string;
13
+ value?: unknown;
14
+ };
15
+ export type VBIWhereDateFilter = {
16
+ id: string;
17
+ field: string;
18
+ op: 'date';
19
+ value: VBIWhereDatePredicate;
20
+ };
21
+ export type VBIWhereFilter = VBIWhereScalarFilter | VBIWhereDateFilter;
22
+ export declare const zVBIWhereDateFilter: z.ZodObject<{
23
+ id: z.ZodString;
24
+ field: z.ZodString;
25
+ op: z.ZodLiteral<"date">;
26
+ value: z.ZodUnion<readonly [z.ZodObject<{
27
+ type: z.ZodLiteral<"range">;
28
+ start: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
29
+ end: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
30
+ bounds: z.ZodOptional<z.ZodEnum<{
31
+ "[)": "[)";
32
+ "[]": "[]";
33
+ }>>;
34
+ }, z.core.$strip>, z.ZodObject<{
35
+ type: z.ZodLiteral<"relative">;
36
+ mode: z.ZodEnum<{
37
+ last: "last";
38
+ next: "next";
39
+ }>;
40
+ amount: z.ZodNumber;
41
+ unit: z.ZodEnum<{
42
+ year: "year";
43
+ quarter: "quarter";
44
+ month: "month";
45
+ week: "week";
46
+ day: "day";
47
+ }>;
48
+ complete: z.ZodOptional<z.ZodBoolean>;
49
+ }, z.core.$strip>, z.ZodObject<{
50
+ type: z.ZodLiteral<"current">;
51
+ unit: z.ZodEnum<{
52
+ year: "year";
53
+ quarter: "quarter";
54
+ month: "month";
55
+ week: "week";
56
+ day: "day";
57
+ }>;
58
+ offset: z.ZodOptional<z.ZodNumber>;
59
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
60
+ type: z.ZodLiteral<"period">;
61
+ }, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
62
+ unit: z.ZodLiteral<"year">;
63
+ year: z.ZodNumber;
64
+ }, z.core.$strip>, z.ZodObject<{
65
+ unit: z.ZodLiteral<"quarter">;
66
+ year: z.ZodNumber;
67
+ quarter: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
68
+ }, z.core.$strip>, z.ZodObject<{
69
+ unit: z.ZodLiteral<"month">;
70
+ year: z.ZodNumber;
71
+ month: z.ZodNumber;
72
+ }, z.core.$strip>, z.ZodObject<{
73
+ unit: z.ZodLiteral<"week">;
74
+ year: z.ZodNumber;
75
+ week: z.ZodNumber;
76
+ }, z.core.$strip>, z.ZodObject<{
77
+ unit: z.ZodLiteral<"day">;
78
+ date: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
79
+ }, z.core.$strip>], "unit">>]>;
80
+ }, z.core.$strip>;
81
+ export declare const zVBIWhereScalarFilter: z.ZodObject<{
7
82
  id: z.ZodString;
8
83
  field: z.ZodString;
9
- op: z.ZodOptional<z.ZodString>;
84
+ op: z.ZodString;
10
85
  value: z.ZodOptional<z.ZodAny>;
11
86
  }, z.core.$strip>;
12
- export type VBIFilter = z.infer<typeof zVBIFilter>;
87
+ export declare const zVBIWhereFilter: z.ZodUnion<readonly [z.ZodObject<{
88
+ id: z.ZodString;
89
+ field: z.ZodString;
90
+ op: z.ZodLiteral<"date">;
91
+ value: z.ZodUnion<readonly [z.ZodObject<{
92
+ type: z.ZodLiteral<"range">;
93
+ start: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
94
+ end: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
95
+ bounds: z.ZodOptional<z.ZodEnum<{
96
+ "[)": "[)";
97
+ "[]": "[]";
98
+ }>>;
99
+ }, z.core.$strip>, z.ZodObject<{
100
+ type: z.ZodLiteral<"relative">;
101
+ mode: z.ZodEnum<{
102
+ last: "last";
103
+ next: "next";
104
+ }>;
105
+ amount: z.ZodNumber;
106
+ unit: z.ZodEnum<{
107
+ year: "year";
108
+ quarter: "quarter";
109
+ month: "month";
110
+ week: "week";
111
+ day: "day";
112
+ }>;
113
+ complete: z.ZodOptional<z.ZodBoolean>;
114
+ }, z.core.$strip>, z.ZodObject<{
115
+ type: z.ZodLiteral<"current">;
116
+ unit: z.ZodEnum<{
117
+ year: "year";
118
+ quarter: "quarter";
119
+ month: "month";
120
+ week: "week";
121
+ day: "day";
122
+ }>;
123
+ offset: z.ZodOptional<z.ZodNumber>;
124
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
125
+ type: z.ZodLiteral<"period">;
126
+ }, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
127
+ unit: z.ZodLiteral<"year">;
128
+ year: z.ZodNumber;
129
+ }, z.core.$strip>, z.ZodObject<{
130
+ unit: z.ZodLiteral<"quarter">;
131
+ year: z.ZodNumber;
132
+ quarter: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
133
+ }, z.core.$strip>, z.ZodObject<{
134
+ unit: z.ZodLiteral<"month">;
135
+ year: z.ZodNumber;
136
+ month: z.ZodNumber;
137
+ }, z.core.$strip>, z.ZodObject<{
138
+ unit: z.ZodLiteral<"week">;
139
+ year: z.ZodNumber;
140
+ week: z.ZodNumber;
141
+ }, z.core.$strip>, z.ZodObject<{
142
+ unit: z.ZodLiteral<"day">;
143
+ date: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
144
+ }, z.core.$strip>], "unit">>]>;
145
+ }, z.core.$strip>, z.ZodObject<{
146
+ id: z.ZodString;
147
+ field: z.ZodString;
148
+ op: z.ZodString;
149
+ value: z.ZodOptional<z.ZodAny>;
150
+ }, z.core.$strip>]>;
13
151
  type VBIWhereBranch = {
14
152
  id: string;
15
153
  op: z.infer<typeof zWhereLogicalOperator>;
16
154
  conditions: VBIWhereClause[];
17
155
  };
18
156
  export type VBIWhereGroup = VBIWhereBranch;
19
- export type VBIWhereClause = VBIFilter | VBIWhereGroup;
157
+ export type VBIWhereClause = VBIWhereFilter | VBIWhereGroup;
20
158
  export declare const zVBIWhereGroup: z.ZodType<VBIWhereGroup>;
21
159
  export declare const zVBIWhereClause: z.ZodType<VBIWhereClause>;
22
- export {};
@@ -1,5 +1,5 @@
1
- import type { VBIFilter, VBIWhereClause, VBIWhereGroup, VBIHavingClause, VBIHavingFilter, VBIHavingGroup } from '../types/dsl';
2
- export declare function isVBIFilter(clause: VBIWhereClause): clause is VBIFilter;
1
+ import type { VBIWhereFilter, VBIWhereClause, VBIWhereGroup, VBIHavingClause, VBIHavingFilter, VBIHavingGroup } from '../types/dsl';
2
+ export declare function isVBIFilter(clause: VBIWhereClause): clause is VBIWhereFilter;
3
3
  export declare function isVBIWhereGroup(clause: VBIWhereClause): clause is VBIWhereGroup;
4
4
  export declare function isVBIHavingFilter(clause: VBIHavingClause): clause is VBIHavingFilter;
5
5
  export declare function isVBIHavingGroup(clause: VBIHavingClause): clause is VBIHavingGroup;
@@ -1,15 +1,14 @@
1
1
  import type { DefaultVBIQueryDSL, DefaultVBISeedDSL } from '../builder/adapters/vquery-vseed/types';
2
2
  import { connectorMap, getConnector, registerConnector } from '../builder/connector';
3
- import type { VBIBuilder } from '../builder/builder';
4
- import type { VBIDSLInput, VBIBuilderOptions } from '../types';
5
- import { generateEmptyDSL } from './generate-empty-dsl';
3
+ import type { VBIChartBuilder } from '../builder/builder';
4
+ import type { VBIChartDSLInput, VBIChartBuilderOptions } from '../types';
5
+ import { generateEmptyChartDSL } from './generate-empty-dsl';
6
6
  export interface VBIInstance<TQueryDSL = DefaultVBIQueryDSL, TSeedDSL = DefaultVBISeedDSL> {
7
7
  connectorMap: typeof connectorMap;
8
8
  registerConnector: typeof registerConnector;
9
9
  getConnector: typeof getConnector;
10
- generateEmptyDSL: typeof generateEmptyDSL;
11
- from: (vbi: VBIDSLInput, builderOptions?: VBIBuilderOptions<TQueryDSL, TSeedDSL>) => VBIBuilder<TQueryDSL, TSeedDSL>;
12
- create: (vbi: VBIDSLInput, builderOptions?: VBIBuilderOptions<TQueryDSL, TSeedDSL>) => VBIBuilder<TQueryDSL, TSeedDSL>;
10
+ generateEmptyChartDSL: typeof generateEmptyChartDSL;
11
+ createChart: (vbi: VBIChartDSLInput, builderOptions?: VBIChartBuilderOptions<TQueryDSL, TSeedDSL>) => VBIChartBuilder<TQueryDSL, TSeedDSL>;
13
12
  }
14
13
  export declare function createVBI(): VBIInstance<DefaultVBIQueryDSL, DefaultVBISeedDSL>;
15
- export declare function createVBI<TQueryDSL, TSeedDSL>(defaultBuilderOptions: VBIBuilderOptions<TQueryDSL, TSeedDSL>): VBIInstance<TQueryDSL, TSeedDSL>;
14
+ export declare function createVBI<TQueryDSL, TSeedDSL>(defaultBuilderOptions: VBIChartBuilderOptions<TQueryDSL, TSeedDSL>): VBIInstance<TQueryDSL, TSeedDSL>;
@@ -1,4 +1,4 @@
1
1
  import type { DefaultVBIQueryDSL, DefaultVBISeedDSL } from '../../builder/adapters/vquery-vseed/types';
2
- import type { VBIDSLInput, VBIBuilderOptions } from '../../types';
3
- import { VBIBuilder } from '../../builder';
4
- export declare const fromVBIDSLInput: <TQueryDSL = DefaultVBIQueryDSL, TSeedDSL = DefaultVBISeedDSL>(vbi: VBIDSLInput, options?: VBIBuilderOptions<TQueryDSL, TSeedDSL>) => VBIBuilder<TQueryDSL, TSeedDSL>;
2
+ import type { VBIChartDSLInput, VBIChartBuilderOptions } from '../../types';
3
+ import { VBIChartBuilder } from '../../builder/builder';
4
+ export declare const createChartBuilderFromVBIChartDSLInput: <TQueryDSL = DefaultVBIQueryDSL, TSeedDSL = DefaultVBISeedDSL>(vbi: VBIChartDSLInput, options?: VBIChartBuilderOptions<TQueryDSL, TSeedDSL>) => VBIChartBuilder<TQueryDSL, TSeedDSL>;
@@ -1,3 +1,3 @@
1
1
  import * as Y from 'yjs';
2
- import type { VBIDSLInput } from '../../types';
3
- export declare const setBaseDSLFields: (dsl: Y.Map<any>, vbi: VBIDSLInput) => void;
2
+ import type { VBIChartDSLInput } from '../../types';
3
+ export declare const setBaseDSLFields: (dsl: Y.Map<any>, vbi: VBIChartDSLInput) => void;
@@ -1,3 +1,3 @@
1
1
  import type { VBIConnectorId } from '../types/connector/connector';
2
- import type { VBIDSL } from '../types';
3
- export declare const generateEmptyDSL: (connectorId: VBIConnectorId) => VBIDSL;
2
+ import type { VBIChartDSL } from '../types';
3
+ export declare const generateEmptyChartDSL: (connectorId: VBIConnectorId) => VBIChartDSL;
@@ -1,5 +1,5 @@
1
1
  export interface FilterGroupInput {
2
- id?: string;
3
- op?: 'and' | 'or';
4
- conditions?: any[];
2
+ id: string;
3
+ op: 'and' | 'or';
4
+ conditions: any[];
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vbi",
3
- "version": "0.4.19",
3
+ "version": "0.4.20",
4
4
  "license": "MIT",
5
5
  "homepage": "https://visactor.github.io/VBI",
6
6
  "bugs": "https://github.com/VisActor/VBI/issues",
@@ -33,11 +33,11 @@
33
33
  "uuid": "13.0.0",
34
34
  "yjs": "13.6.28",
35
35
  "zod": "4.0.17",
36
- "@visactor/vseed": "0.4.19"
36
+ "@visactor/vseed": "0.4.20"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@visactor/vquery": "0.4.19",
40
- "@visactor/vseed": "0.4.19"
39
+ "@visactor/vquery": "0.4.20",
40
+ "@visactor/vseed": "0.4.20"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@eslint/js": "9.39.0",
@@ -51,7 +51,7 @@
51
51
  "ts-morph": "26.0.0",
52
52
  "typescript": "5.9.3",
53
53
  "typescript-eslint": "8.48.0",
54
- "@visactor/vquery": "0.4.19"
54
+ "@visactor/vquery": "0.4.20"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "rslib build",