@vaultgradient/pipequery-lang 1.12.2 → 1.13.0

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,142 +1,13 @@
1
- interface NumberLiteral {
2
- kind: 'NumberLiteral';
3
- value: number;
4
- }
5
- interface StringLiteral {
6
- kind: 'StringLiteral';
7
- value: string;
8
- }
9
- interface BooleanLiteral {
10
- kind: 'BooleanLiteral';
11
- value: boolean;
12
- }
13
- interface NullLiteral {
14
- kind: 'NullLiteral';
15
- }
16
- interface FieldAccess {
17
- kind: 'FieldAccess';
18
- path: string[];
19
- }
20
- interface BinaryExpr {
21
- kind: 'BinaryExpr';
22
- operator: '>' | '>=' | '<' | '<=' | '==' | '!=' | '&&' | '||' | '+' | '-' | '*' | '/' | '%';
23
- left: Expression;
24
- right: Expression;
25
- }
26
- interface UnaryExpr {
27
- kind: 'UnaryExpr';
28
- operator: '!' | '-';
29
- operand: Expression;
30
- }
31
- interface FunctionCall {
32
- kind: 'FunctionCall';
33
- name: string;
34
- args: Expression[];
35
- }
36
- interface AliasExpr {
37
- kind: 'AliasExpr';
38
- expression: Expression;
39
- alias: string;
40
- }
41
- type Expression = NumberLiteral | StringLiteral | BooleanLiteral | NullLiteral | FieldAccess | BinaryExpr | UnaryExpr | FunctionCall | AliasExpr;
42
- interface WhereOp {
43
- kind: 'WhereOp';
44
- condition: Expression;
45
- }
46
- interface SelectOp {
47
- kind: 'SelectOp';
48
- fields: Expression[];
49
- }
50
- interface SortOp {
51
- kind: 'SortOp';
52
- criteria: Array<{
53
- expression: Expression;
54
- direction: 'asc' | 'desc';
55
- }>;
56
- }
57
- interface GroupByOp {
58
- kind: 'GroupByOp';
59
- keys: Expression[];
60
- }
61
- interface JoinOp {
62
- kind: 'JoinOp';
63
- right: string;
64
- condition: Expression;
65
- }
66
- interface FirstOp {
67
- kind: 'FirstOp';
68
- count: number;
69
- }
70
- interface LastOp {
71
- kind: 'LastOp';
72
- count: number;
73
- }
74
- interface DistinctOp {
75
- kind: 'DistinctOp';
76
- fields?: Expression[];
77
- }
78
- interface FlattenOp {
79
- kind: 'FlattenOp';
80
- field?: Expression;
81
- }
82
- type AggregateFnName = 'sum' | 'avg' | 'min' | 'max' | 'count' | 'median' | 'stddev' | 'var' | 'percentile' | 'skew' | 'kurt' | 'vwap' | 'wavg' | 'drawdown' | 'pct' | 'sharpe' | 'calmar' | 'sortino' | 'info_ratio' | 'distinct_count' | 'sum_abs' | 'abs_sum' | 'first_value' | 'last_value';
83
- interface AggregateOp {
84
- kind: 'AggregateOp';
85
- function: AggregateFnName;
86
- field?: Expression;
87
- args?: Expression[];
88
- }
89
- interface RollupOp {
90
- kind: 'RollupOp';
91
- keys: Expression[];
92
- aggregates: Expression[];
93
- }
94
- interface PivotOp {
95
- kind: 'PivotOp';
96
- pivotField: Expression;
97
- aggregates: Expression[];
98
- }
99
- interface TransposeOp {
100
- kind: 'TransposeOp';
101
- headerField?: Expression;
102
- }
103
- interface MapOp {
104
- kind: 'MapOp';
105
- fields: Expression[];
106
- }
107
- interface ReduceOp {
108
- kind: 'ReduceOp';
109
- initial: Expression;
110
- accumulator: Expression;
111
- }
112
- type Operation = WhereOp | SelectOp | SortOp | GroupByOp | JoinOp | FirstOp | LastOp | DistinctOp | FlattenOp | AggregateOp | RollupOp | PivotOp | TransposeOp | MapOp | ReduceOp;
113
- interface Pipeline {
114
- kind: 'Pipeline';
115
- source: string;
116
- operations: Operation[];
117
- }
118
- declare class DataWeaveError extends Error {
119
- position: number;
120
- line: number;
121
- column: number;
122
- constructor(message: string, position: number, line: number, column: number);
123
- }
124
- declare class LexerError extends DataWeaveError {
125
- constructor(message: string, position: number, line: number, column: number);
126
- }
127
- declare class ParseError extends DataWeaveError {
128
- constructor(message: string, position: number, line: number, column: number);
129
- }
130
- declare class RuntimeError extends Error {
131
- constructor(message: string);
132
- }
133
- type DataContext = Record<string, unknown[]>;
134
- type RowData = Record<string, unknown>;
135
- interface CompiledQuery {
136
- (context: DataContext): unknown;
137
- source: string;
138
- ast: Pipeline;
139
- }
1
+ import { E as Expression, P as Pipeline, R as RowData, D as DataContext, C as CompiledQuery } from '../types-CukH_v-n.cjs';
2
+ export { a as DataWeaveError, L as LexerError, O as Operation, b as ParseError, c as RuntimeError } from '../types-CukH_v-n.cjs';
3
+
4
+ /** Prints a pipeline AST as a canonical pipequery string. */
5
+ declare function printQuery(ast: Pipeline): string;
6
+ /**
7
+ * Prints a single expression (an alias is allowed at the top level) as a canonical
8
+ * pipequery string. Useful for tooling that edits one clause at a time.
9
+ */
10
+ declare function printExpression(expr: Expression): string;
140
11
 
141
12
  interface LiveQueryOptions {
142
13
  /** Field name(s) used as the unique key for delta merges */
@@ -197,7 +68,12 @@ declare function liveQuery(data: RowData[] | DataContext, expression: string, op
197
68
 
198
69
  declare function compile(expression: string, useCache?: boolean): CompiledQuery;
199
70
  declare function query(context: DataContext | RowData[], expression: string): unknown;
71
+ /**
72
+ * Compile an AST directly, skipping the print and re-parse round trip.
73
+ * `.source` of the result is the canonical printed form of the AST.
74
+ */
75
+ declare function compileAst(ast: Pipeline): CompiledQuery;
200
76
  declare function parseQuery(expression: string): Pipeline;
201
77
  declare function clearCache(): void;
202
78
 
203
- export { type CompiledQuery, type DataContext, DataWeaveError, type Expression, LexerError, LiveQuery, type LiveQueryOptions, type LiveQueryStats, type LiveQuerySubscriber, type Operation, ParseError, type Pipeline, RuntimeError, clearCache, compile, liveQuery, parseQuery, query };
79
+ export { CompiledQuery, DataContext, Expression, LiveQuery, type LiveQueryOptions, type LiveQueryStats, type LiveQuerySubscriber, Pipeline, clearCache, compile, compileAst, liveQuery, parseQuery, printExpression, printQuery, query };
@@ -1,142 +1,13 @@
1
- interface NumberLiteral {
2
- kind: 'NumberLiteral';
3
- value: number;
4
- }
5
- interface StringLiteral {
6
- kind: 'StringLiteral';
7
- value: string;
8
- }
9
- interface BooleanLiteral {
10
- kind: 'BooleanLiteral';
11
- value: boolean;
12
- }
13
- interface NullLiteral {
14
- kind: 'NullLiteral';
15
- }
16
- interface FieldAccess {
17
- kind: 'FieldAccess';
18
- path: string[];
19
- }
20
- interface BinaryExpr {
21
- kind: 'BinaryExpr';
22
- operator: '>' | '>=' | '<' | '<=' | '==' | '!=' | '&&' | '||' | '+' | '-' | '*' | '/' | '%';
23
- left: Expression;
24
- right: Expression;
25
- }
26
- interface UnaryExpr {
27
- kind: 'UnaryExpr';
28
- operator: '!' | '-';
29
- operand: Expression;
30
- }
31
- interface FunctionCall {
32
- kind: 'FunctionCall';
33
- name: string;
34
- args: Expression[];
35
- }
36
- interface AliasExpr {
37
- kind: 'AliasExpr';
38
- expression: Expression;
39
- alias: string;
40
- }
41
- type Expression = NumberLiteral | StringLiteral | BooleanLiteral | NullLiteral | FieldAccess | BinaryExpr | UnaryExpr | FunctionCall | AliasExpr;
42
- interface WhereOp {
43
- kind: 'WhereOp';
44
- condition: Expression;
45
- }
46
- interface SelectOp {
47
- kind: 'SelectOp';
48
- fields: Expression[];
49
- }
50
- interface SortOp {
51
- kind: 'SortOp';
52
- criteria: Array<{
53
- expression: Expression;
54
- direction: 'asc' | 'desc';
55
- }>;
56
- }
57
- interface GroupByOp {
58
- kind: 'GroupByOp';
59
- keys: Expression[];
60
- }
61
- interface JoinOp {
62
- kind: 'JoinOp';
63
- right: string;
64
- condition: Expression;
65
- }
66
- interface FirstOp {
67
- kind: 'FirstOp';
68
- count: number;
69
- }
70
- interface LastOp {
71
- kind: 'LastOp';
72
- count: number;
73
- }
74
- interface DistinctOp {
75
- kind: 'DistinctOp';
76
- fields?: Expression[];
77
- }
78
- interface FlattenOp {
79
- kind: 'FlattenOp';
80
- field?: Expression;
81
- }
82
- type AggregateFnName = 'sum' | 'avg' | 'min' | 'max' | 'count' | 'median' | 'stddev' | 'var' | 'percentile' | 'skew' | 'kurt' | 'vwap' | 'wavg' | 'drawdown' | 'pct' | 'sharpe' | 'calmar' | 'sortino' | 'info_ratio' | 'distinct_count' | 'sum_abs' | 'abs_sum' | 'first_value' | 'last_value';
83
- interface AggregateOp {
84
- kind: 'AggregateOp';
85
- function: AggregateFnName;
86
- field?: Expression;
87
- args?: Expression[];
88
- }
89
- interface RollupOp {
90
- kind: 'RollupOp';
91
- keys: Expression[];
92
- aggregates: Expression[];
93
- }
94
- interface PivotOp {
95
- kind: 'PivotOp';
96
- pivotField: Expression;
97
- aggregates: Expression[];
98
- }
99
- interface TransposeOp {
100
- kind: 'TransposeOp';
101
- headerField?: Expression;
102
- }
103
- interface MapOp {
104
- kind: 'MapOp';
105
- fields: Expression[];
106
- }
107
- interface ReduceOp {
108
- kind: 'ReduceOp';
109
- initial: Expression;
110
- accumulator: Expression;
111
- }
112
- type Operation = WhereOp | SelectOp | SortOp | GroupByOp | JoinOp | FirstOp | LastOp | DistinctOp | FlattenOp | AggregateOp | RollupOp | PivotOp | TransposeOp | MapOp | ReduceOp;
113
- interface Pipeline {
114
- kind: 'Pipeline';
115
- source: string;
116
- operations: Operation[];
117
- }
118
- declare class DataWeaveError extends Error {
119
- position: number;
120
- line: number;
121
- column: number;
122
- constructor(message: string, position: number, line: number, column: number);
123
- }
124
- declare class LexerError extends DataWeaveError {
125
- constructor(message: string, position: number, line: number, column: number);
126
- }
127
- declare class ParseError extends DataWeaveError {
128
- constructor(message: string, position: number, line: number, column: number);
129
- }
130
- declare class RuntimeError extends Error {
131
- constructor(message: string);
132
- }
133
- type DataContext = Record<string, unknown[]>;
134
- type RowData = Record<string, unknown>;
135
- interface CompiledQuery {
136
- (context: DataContext): unknown;
137
- source: string;
138
- ast: Pipeline;
139
- }
1
+ import { E as Expression, P as Pipeline, R as RowData, D as DataContext, C as CompiledQuery } from '../types-CukH_v-n.js';
2
+ export { a as DataWeaveError, L as LexerError, O as Operation, b as ParseError, c as RuntimeError } from '../types-CukH_v-n.js';
3
+
4
+ /** Prints a pipeline AST as a canonical pipequery string. */
5
+ declare function printQuery(ast: Pipeline): string;
6
+ /**
7
+ * Prints a single expression (an alias is allowed at the top level) as a canonical
8
+ * pipequery string. Useful for tooling that edits one clause at a time.
9
+ */
10
+ declare function printExpression(expr: Expression): string;
140
11
 
141
12
  interface LiveQueryOptions {
142
13
  /** Field name(s) used as the unique key for delta merges */
@@ -197,7 +68,12 @@ declare function liveQuery(data: RowData[] | DataContext, expression: string, op
197
68
 
198
69
  declare function compile(expression: string, useCache?: boolean): CompiledQuery;
199
70
  declare function query(context: DataContext | RowData[], expression: string): unknown;
71
+ /**
72
+ * Compile an AST directly, skipping the print and re-parse round trip.
73
+ * `.source` of the result is the canonical printed form of the AST.
74
+ */
75
+ declare function compileAst(ast: Pipeline): CompiledQuery;
200
76
  declare function parseQuery(expression: string): Pipeline;
201
77
  declare function clearCache(): void;
202
78
 
203
- export { type CompiledQuery, type DataContext, DataWeaveError, type Expression, LexerError, LiveQuery, type LiveQueryOptions, type LiveQueryStats, type LiveQuerySubscriber, type Operation, ParseError, type Pipeline, RuntimeError, clearCache, compile, liveQuery, parseQuery, query };
79
+ export { CompiledQuery, DataContext, Expression, LiveQuery, type LiveQueryOptions, type LiveQueryStats, type LiveQuerySubscriber, Pipeline, clearCache, compile, compileAst, liveQuery, parseQuery, printExpression, printQuery, query };