@vaultgradient/pipequery-lang 1.2.2
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/README.md +301 -0
- package/dist/engine/index.cjs +2102 -0
- package/dist/engine/index.d.cts +203 -0
- package/dist/engine/index.d.ts +203 -0
- package/dist/engine/index.js +2102 -0
- package/dist/highlighting/index.cjs +562 -0
- package/dist/highlighting/index.d.cts +136 -0
- package/dist/highlighting/index.d.ts +136 -0
- package/dist/highlighting/index.js +562 -0
- package/dist/react/index.cjs +1374 -0
- package/dist/react/index.d.cts +120 -0
- package/dist/react/index.d.ts +120 -0
- package/dist/react/index.js +1374 -0
- package/package.json +137 -0
|
@@ -0,0 +1,203 @@
|
|
|
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
|
+
}
|
|
140
|
+
|
|
141
|
+
interface LiveQueryOptions {
|
|
142
|
+
/** Field name(s) used as the unique key for delta merges */
|
|
143
|
+
key: string | string[];
|
|
144
|
+
/** Which source in a DataContext receives patches (defaults to '_data' for raw arrays) */
|
|
145
|
+
source?: string;
|
|
146
|
+
/** Minimum ms between executions. 0 = next microtask (default: 0) */
|
|
147
|
+
throttle?: number;
|
|
148
|
+
}
|
|
149
|
+
interface LiveQueryStats {
|
|
150
|
+
patchMs: number;
|
|
151
|
+
executionMs: number;
|
|
152
|
+
totalMs: number;
|
|
153
|
+
rowCount: number;
|
|
154
|
+
resultCount: number;
|
|
155
|
+
patchCount: number;
|
|
156
|
+
tick: number;
|
|
157
|
+
}
|
|
158
|
+
type LiveQuerySubscriber = (result: unknown, stats: LiveQueryStats) => void;
|
|
159
|
+
type RemovalKey = string | string[];
|
|
160
|
+
declare class LiveQuery {
|
|
161
|
+
private _index;
|
|
162
|
+
private _keyFields;
|
|
163
|
+
private _sourceName;
|
|
164
|
+
private _context;
|
|
165
|
+
private _compiled;
|
|
166
|
+
private _throttle;
|
|
167
|
+
private _pendingTimer;
|
|
168
|
+
private _executing;
|
|
169
|
+
private _dirtyDuringExec;
|
|
170
|
+
private _result;
|
|
171
|
+
private _stats;
|
|
172
|
+
private _subscribers;
|
|
173
|
+
private _batchDepth;
|
|
174
|
+
private _batchDirty;
|
|
175
|
+
private _disposed;
|
|
176
|
+
constructor(data: RowData[] | DataContext, expression: string, options: LiveQueryOptions);
|
|
177
|
+
get result(): unknown;
|
|
178
|
+
get stats(): LiveQueryStats;
|
|
179
|
+
get size(): number;
|
|
180
|
+
subscribe(fn: LiveQuerySubscriber): () => void;
|
|
181
|
+
patch(changed: RowData[], removals?: RemovalKey[]): void;
|
|
182
|
+
reset(data: RowData[]): void;
|
|
183
|
+
setQuery(expression: string): void;
|
|
184
|
+
beginBatch(): void;
|
|
185
|
+
endBatch(): void;
|
|
186
|
+
dispose(): void;
|
|
187
|
+
private _rowKey;
|
|
188
|
+
private _removalKey;
|
|
189
|
+
private _buildIndex;
|
|
190
|
+
private _scheduleExecution;
|
|
191
|
+
private _onTimer;
|
|
192
|
+
private _executeSync;
|
|
193
|
+
private _notify;
|
|
194
|
+
private _guardDisposed;
|
|
195
|
+
}
|
|
196
|
+
declare function liveQuery(data: RowData[] | DataContext, expression: string, options: LiveQueryOptions): LiveQuery;
|
|
197
|
+
|
|
198
|
+
declare function compile(expression: string, useCache?: boolean): CompiledQuery;
|
|
199
|
+
declare function query(context: DataContext | RowData[], expression: string): unknown;
|
|
200
|
+
declare function parseQuery(expression: string): Pipeline;
|
|
201
|
+
declare function clearCache(): void;
|
|
202
|
+
|
|
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 };
|
|
@@ -0,0 +1,203 @@
|
|
|
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
|
+
}
|
|
140
|
+
|
|
141
|
+
interface LiveQueryOptions {
|
|
142
|
+
/** Field name(s) used as the unique key for delta merges */
|
|
143
|
+
key: string | string[];
|
|
144
|
+
/** Which source in a DataContext receives patches (defaults to '_data' for raw arrays) */
|
|
145
|
+
source?: string;
|
|
146
|
+
/** Minimum ms between executions. 0 = next microtask (default: 0) */
|
|
147
|
+
throttle?: number;
|
|
148
|
+
}
|
|
149
|
+
interface LiveQueryStats {
|
|
150
|
+
patchMs: number;
|
|
151
|
+
executionMs: number;
|
|
152
|
+
totalMs: number;
|
|
153
|
+
rowCount: number;
|
|
154
|
+
resultCount: number;
|
|
155
|
+
patchCount: number;
|
|
156
|
+
tick: number;
|
|
157
|
+
}
|
|
158
|
+
type LiveQuerySubscriber = (result: unknown, stats: LiveQueryStats) => void;
|
|
159
|
+
type RemovalKey = string | string[];
|
|
160
|
+
declare class LiveQuery {
|
|
161
|
+
private _index;
|
|
162
|
+
private _keyFields;
|
|
163
|
+
private _sourceName;
|
|
164
|
+
private _context;
|
|
165
|
+
private _compiled;
|
|
166
|
+
private _throttle;
|
|
167
|
+
private _pendingTimer;
|
|
168
|
+
private _executing;
|
|
169
|
+
private _dirtyDuringExec;
|
|
170
|
+
private _result;
|
|
171
|
+
private _stats;
|
|
172
|
+
private _subscribers;
|
|
173
|
+
private _batchDepth;
|
|
174
|
+
private _batchDirty;
|
|
175
|
+
private _disposed;
|
|
176
|
+
constructor(data: RowData[] | DataContext, expression: string, options: LiveQueryOptions);
|
|
177
|
+
get result(): unknown;
|
|
178
|
+
get stats(): LiveQueryStats;
|
|
179
|
+
get size(): number;
|
|
180
|
+
subscribe(fn: LiveQuerySubscriber): () => void;
|
|
181
|
+
patch(changed: RowData[], removals?: RemovalKey[]): void;
|
|
182
|
+
reset(data: RowData[]): void;
|
|
183
|
+
setQuery(expression: string): void;
|
|
184
|
+
beginBatch(): void;
|
|
185
|
+
endBatch(): void;
|
|
186
|
+
dispose(): void;
|
|
187
|
+
private _rowKey;
|
|
188
|
+
private _removalKey;
|
|
189
|
+
private _buildIndex;
|
|
190
|
+
private _scheduleExecution;
|
|
191
|
+
private _onTimer;
|
|
192
|
+
private _executeSync;
|
|
193
|
+
private _notify;
|
|
194
|
+
private _guardDisposed;
|
|
195
|
+
}
|
|
196
|
+
declare function liveQuery(data: RowData[] | DataContext, expression: string, options: LiveQueryOptions): LiveQuery;
|
|
197
|
+
|
|
198
|
+
declare function compile(expression: string, useCache?: boolean): CompiledQuery;
|
|
199
|
+
declare function query(context: DataContext | RowData[], expression: string): unknown;
|
|
200
|
+
declare function parseQuery(expression: string): Pipeline;
|
|
201
|
+
declare function clearCache(): void;
|
|
202
|
+
|
|
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 };
|