@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.
@@ -0,0 +1,562 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/highlighting/shared.ts
2
+ var OPERATION_NAMES = [
3
+ "where",
4
+ "select",
5
+ "sort",
6
+ "groupBy",
7
+ "join",
8
+ "first",
9
+ "last",
10
+ "distinct",
11
+ "map",
12
+ "reduce",
13
+ "rollup",
14
+ "pivot",
15
+ "flatten",
16
+ "transpose"
17
+ ];
18
+ var KEYWORDS = [
19
+ "as",
20
+ "asc",
21
+ "desc",
22
+ "true",
23
+ "false",
24
+ "null"
25
+ ];
26
+ var AGGREGATE_FUNCTIONS = [
27
+ "sum",
28
+ "avg",
29
+ "min",
30
+ "max",
31
+ "count",
32
+ "median",
33
+ "stddev",
34
+ "var",
35
+ "percentile",
36
+ "skew",
37
+ "kurt",
38
+ "vwap",
39
+ "wavg",
40
+ "drawdown",
41
+ "pct",
42
+ "sharpe",
43
+ "calmar",
44
+ "sortino",
45
+ "info_ratio",
46
+ "distinct_count",
47
+ "sum_abs",
48
+ "abs_sum",
49
+ "first_value",
50
+ "last_value"
51
+ ];
52
+ var BUILTIN_FUNCTIONS = [
53
+ "if",
54
+ "coalesce",
55
+ "lower",
56
+ "upper",
57
+ "len",
58
+ "abs",
59
+ "round",
60
+ "concat",
61
+ "contains",
62
+ "startsWith",
63
+ "endsWith",
64
+ "trim",
65
+ "substring",
66
+ "replace"
67
+ ];
68
+ var WINDOW_FUNCTIONS = [
69
+ "running_sum",
70
+ "running_avg",
71
+ "running_count",
72
+ "running_min",
73
+ "running_max",
74
+ "row_number",
75
+ "lag",
76
+ "lead"
77
+ ];
78
+ var ALL_FUNCTIONS = [
79
+ ...AGGREGATE_FUNCTIONS,
80
+ ...BUILTIN_FUNCTIONS,
81
+ ...WINDOW_FUNCTIONS
82
+ ];
83
+ var ALL_KEYWORDS = [
84
+ ...OPERATION_NAMES,
85
+ ...KEYWORDS
86
+ ];
87
+ var COLORS = {
88
+ keyword: "#c792ea",
89
+ string: "#c3e88d",
90
+ number: "#f78c6c",
91
+ operator: "#89ddff",
92
+ field: "#82aaff",
93
+ function: "#ffcb6b",
94
+ comment: "#546e7a"
95
+ };
96
+
97
+ // src/highlighting/codemirror/index.ts
98
+ var _language = require('@codemirror/language');
99
+
100
+ // src/highlighting/codemirror/language.ts
101
+ var keywordSet = new Set(ALL_KEYWORDS);
102
+ var functionSet = new Set(ALL_FUNCTIONS);
103
+ var pipeQueryStreamParser = {
104
+ name: "pipequery",
105
+ startState() {
106
+ return { inString: "", afterPipe: false };
107
+ },
108
+ token(stream, state) {
109
+ if (state.inString) {
110
+ const quote = state.inString;
111
+ while (!stream.eol()) {
112
+ const ch2 = stream.next();
113
+ if (ch2 === "\\" && !stream.eol()) {
114
+ stream.next();
115
+ } else if (ch2 === quote) {
116
+ state.inString = "";
117
+ return "string";
118
+ }
119
+ }
120
+ return "string";
121
+ }
122
+ if (stream.eatSpace()) return null;
123
+ if (stream.match("//")) {
124
+ stream.skipToEnd();
125
+ return "comment";
126
+ }
127
+ if (stream.match(">=") || stream.match("<=") || stream.match("==") || stream.match("!=") || stream.match("&&") || stream.match("||")) {
128
+ state.afterPipe = false;
129
+ return "operator";
130
+ }
131
+ const ch = stream.peek();
132
+ if (ch === "|") {
133
+ stream.next();
134
+ state.afterPipe = true;
135
+ return "operator";
136
+ }
137
+ if (ch === ">" || ch === "<" || ch === "!" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%") {
138
+ stream.next();
139
+ state.afterPipe = false;
140
+ return "operator";
141
+ }
142
+ if (ch === "(" || ch === ")" || ch === "," || ch === ".") {
143
+ stream.next();
144
+ if (ch !== "(") state.afterPipe = false;
145
+ return "punctuation";
146
+ }
147
+ if (ch && ch >= "0" && ch <= "9") {
148
+ stream.match(/^\d+(\.\d+)?/);
149
+ state.afterPipe = false;
150
+ return "number";
151
+ }
152
+ if (ch === '"' || ch === "'") {
153
+ state.inString = ch;
154
+ stream.next();
155
+ return "string";
156
+ }
157
+ if (stream.match(/^[a-zA-Z_]\w*/)) {
158
+ const word = stream.current();
159
+ if (keywordSet.has(word)) {
160
+ state.afterPipe = false;
161
+ return "keyword";
162
+ }
163
+ if (functionSet.has(word)) {
164
+ state.afterPipe = false;
165
+ return "function";
166
+ }
167
+ state.afterPipe = false;
168
+ return "variableName";
169
+ }
170
+ stream.next();
171
+ state.afterPipe = false;
172
+ return null;
173
+ }
174
+ };
175
+
176
+ // src/highlighting/codemirror/highlight.ts
177
+
178
+ var _highlight = require('@lezer/highlight');
179
+ var pipeQueryHighlightStyle = _language.HighlightStyle.define([
180
+ { tag: _highlight.tags.keyword, color: COLORS.keyword, fontWeight: "600" },
181
+ { tag: _highlight.tags.function(_highlight.tags.variableName), color: COLORS.function },
182
+ { tag: _highlight.tags.variableName, color: COLORS.field },
183
+ { tag: _highlight.tags.string, color: COLORS.string },
184
+ { tag: _highlight.tags.number, color: COLORS.number },
185
+ { tag: _highlight.tags.operator, color: COLORS.operator },
186
+ { tag: _highlight.tags.punctuation, color: COLORS.operator },
187
+ { tag: _highlight.tags.lineComment, color: COLORS.comment, fontStyle: "italic" }
188
+ ]);
189
+ var pipeQueryHighlightExtension = _language.syntaxHighlighting.call(void 0, pipeQueryHighlightStyle);
190
+
191
+ // src/highlighting/codemirror/completion.ts
192
+ var _autocomplete = require('@codemirror/autocomplete');
193
+ var OP_HINTS = {
194
+ where: "Filter rows matching a condition",
195
+ select: "Pick or compute columns",
196
+ sort: "Order rows by fields",
197
+ groupBy: "Group rows by key fields",
198
+ join: "Join with another data source",
199
+ first: "Take first N rows",
200
+ last: "Take last N rows",
201
+ distinct: "Remove duplicate rows",
202
+ map: "Add computed columns",
203
+ reduce: "Fold rows into a single value",
204
+ rollup: "Group + aggregate in one step",
205
+ pivot: "Pivot rows into columns",
206
+ flatten: "Expand nested arrays",
207
+ transpose: "Swap rows and columns"
208
+ };
209
+ var FN_HINTS = {
210
+ // Aggregate
211
+ sum: "Total of values",
212
+ avg: "Arithmetic mean",
213
+ min: "Minimum value",
214
+ max: "Maximum value",
215
+ count: "Row count",
216
+ median: "50th percentile",
217
+ stddev: "Standard deviation",
218
+ var: "Variance",
219
+ percentile: "p-th percentile",
220
+ skew: "Skewness",
221
+ kurt: "Excess kurtosis",
222
+ vwap: "Volume-weighted avg price",
223
+ wavg: "Weighted average",
224
+ drawdown: "Max peak-to-trough decline",
225
+ pct: "Percentage of total",
226
+ sharpe: "Sharpe ratio",
227
+ calmar: "Calmar ratio",
228
+ sortino: "Sortino ratio",
229
+ info_ratio: "Information ratio",
230
+ distinct_count: "Count of unique values",
231
+ sum_abs: "Sum of absolute values",
232
+ abs_sum: "Abs of sum",
233
+ first_value: "First value in group",
234
+ last_value: "Last value in group",
235
+ // Built-in
236
+ if: "Conditional expression",
237
+ coalesce: "First non-null value",
238
+ lower: "Lowercase string",
239
+ upper: "Uppercase string",
240
+ len: "String length",
241
+ abs: "Absolute value",
242
+ round: "Round to N decimals",
243
+ concat: "Concatenate strings",
244
+ contains: "Check if string contains substring",
245
+ startsWith: "Check if string starts with prefix",
246
+ endsWith: "Check if string ends with suffix",
247
+ trim: "Remove leading/trailing whitespace",
248
+ substring: "Extract part of a string",
249
+ replace: "Replace all occurrences in string",
250
+ // Window
251
+ running_sum: "Cumulative sum",
252
+ running_avg: "Cumulative average",
253
+ running_count: "Cumulative count",
254
+ running_min: "Running minimum",
255
+ running_max: "Running maximum",
256
+ row_number: "Row number (1-based)",
257
+ lag: "Previous row value",
258
+ lead: "Next row value"
259
+ };
260
+ var KW_HINTS = {
261
+ as: "Alias a column",
262
+ asc: "Ascending order",
263
+ desc: "Descending order",
264
+ true: "Boolean true",
265
+ false: "Boolean false",
266
+ null: "Null value"
267
+ };
268
+ var OP_COMPLETIONS = OPERATION_NAMES.map((name) => ({
269
+ label: name,
270
+ type: "keyword",
271
+ detail: "operation",
272
+ info: OP_HINTS[name],
273
+ boost: 2
274
+ }));
275
+ var FN_COMPLETIONS = ALL_FUNCTIONS.map((name) => ({
276
+ label: name,
277
+ type: "function",
278
+ detail: AGGREGATE_FUNCTIONS.includes(name) ? "aggregate" : WINDOW_FUNCTIONS.includes(name) ? "window" : "built-in",
279
+ info: FN_HINTS[name],
280
+ apply: `${name}(`
281
+ }));
282
+ var AGG_COMPLETIONS = FN_COMPLETIONS.filter(
283
+ (c) => AGGREGATE_FUNCTIONS.includes(c.label)
284
+ );
285
+ var KW_COMPLETIONS = KEYWORDS.map((name) => ({
286
+ label: name,
287
+ type: "keyword",
288
+ detail: "keyword",
289
+ info: KW_HINTS[name]
290
+ }));
291
+ var SORT_KW = [
292
+ { label: "asc", type: "keyword", detail: "ascending order" },
293
+ { label: "desc", type: "keyword", detail: "descending order" }
294
+ ];
295
+ function detectContext(text) {
296
+ let depth = 0;
297
+ let i = text.length - 1;
298
+ while (i >= 0 && /[\w.]/.test(text[i])) i--;
299
+ while (i >= 0 && /\s/.test(text[i])) i--;
300
+ if (i < 0) return { kind: "startOfQuery" };
301
+ const ch = text[i];
302
+ if (ch === "|") return { kind: "afterPipe" };
303
+ for (let j = text.length - 1; j >= 0; j--) {
304
+ const c = text[j];
305
+ if (c === ")") depth++;
306
+ else if (c === "(") {
307
+ depth--;
308
+ if (depth < 0) {
309
+ let k = j - 1;
310
+ while (k >= 0 && /\s/.test(text[k])) k--;
311
+ let end = k + 1;
312
+ while (k >= 0 && /\w/.test(text[k])) k--;
313
+ const op = text.slice(k + 1, end);
314
+ if (op && OPERATION_NAMES.includes(op)) {
315
+ return { kind: "insideOp", op };
316
+ }
317
+ if (op && ALL_FUNCTIONS.includes(op)) {
318
+ return { kind: "general" };
319
+ }
320
+ return { kind: "general" };
321
+ }
322
+ }
323
+ if (c === '"' || c === "'") {
324
+ const q = c;
325
+ j--;
326
+ while (j >= 0 && text[j] !== q) j--;
327
+ }
328
+ }
329
+ const trimmed = text.trimStart();
330
+ if (!trimmed.includes("|")) return { kind: "startOfQuery" };
331
+ return { kind: "general" };
332
+ }
333
+ function resolve(v) {
334
+ return typeof v === "function" ? v() : v;
335
+ }
336
+ function buildFieldCompletions(fields) {
337
+ return fields.map((f) => ({
338
+ label: f,
339
+ type: "variable",
340
+ detail: "field",
341
+ boost: 1
342
+ }));
343
+ }
344
+ function buildSourceCompletions(sources) {
345
+ return sources.map((s) => ({
346
+ label: s,
347
+ type: "variable",
348
+ detail: "source",
349
+ boost: 3
350
+ }));
351
+ }
352
+ function createCompletionSource(config) {
353
+ return function completionSource(cx) {
354
+ const word = cx.matchBefore(/[\w.]*/);
355
+ if (!word) return null;
356
+ if (word.from === word.to && !cx.explicit) return null;
357
+ const fields = resolve(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.fields]), () => ( [])));
358
+ const sources = resolve(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _2 => _2.sources]), () => ( [])));
359
+ const textBefore = cx.state.doc.sliceString(0, word.from);
360
+ const ctx = detectContext(textBefore);
361
+ let completions;
362
+ switch (ctx.kind) {
363
+ case "afterPipe":
364
+ completions = OP_COMPLETIONS;
365
+ break;
366
+ case "startOfQuery":
367
+ completions = [
368
+ ...buildSourceCompletions(sources),
369
+ ...OP_COMPLETIONS
370
+ ];
371
+ break;
372
+ case "insideOp":
373
+ switch (ctx.op) {
374
+ case "sort":
375
+ completions = [...buildFieldCompletions(fields), ...SORT_KW];
376
+ break;
377
+ case "select":
378
+ case "groupBy":
379
+ case "distinct":
380
+ completions = [...buildFieldCompletions(fields), ...FN_COMPLETIONS];
381
+ break;
382
+ case "rollup":
383
+ case "pivot":
384
+ completions = [...buildFieldCompletions(fields), ...AGG_COMPLETIONS];
385
+ break;
386
+ case "where":
387
+ case "map":
388
+ completions = [
389
+ ...buildFieldCompletions(fields),
390
+ ...FN_COMPLETIONS,
391
+ ...KW_COMPLETIONS
392
+ ];
393
+ break;
394
+ case "join":
395
+ completions = [
396
+ ...buildSourceCompletions(sources),
397
+ ...buildFieldCompletions(fields),
398
+ ...KW_COMPLETIONS
399
+ ];
400
+ break;
401
+ default:
402
+ completions = [
403
+ ...buildFieldCompletions(fields),
404
+ ...FN_COMPLETIONS,
405
+ ...KW_COMPLETIONS
406
+ ];
407
+ }
408
+ break;
409
+ case "general":
410
+ default:
411
+ completions = [
412
+ ...buildFieldCompletions(fields),
413
+ ...FN_COMPLETIONS,
414
+ ...KW_COMPLETIONS,
415
+ ...OP_COMPLETIONS
416
+ ];
417
+ }
418
+ return {
419
+ from: word.from,
420
+ options: completions,
421
+ validFor: /^\w*$/
422
+ };
423
+ };
424
+ }
425
+ function pipeQueryCompletion(config) {
426
+ return _autocomplete.autocompletion.call(void 0, {
427
+ override: [createCompletionSource(config)],
428
+ activateOnTyping: true,
429
+ icons: true
430
+ });
431
+ }
432
+
433
+ // src/highlighting/codemirror/index.ts
434
+ function pipeQuery(config) {
435
+ const lang = _language.StreamLanguage.define(pipeQueryStreamParser);
436
+ const extensions = [pipeQueryHighlightExtension];
437
+ if (_optionalChain([config, 'optionalAccess', _3 => _3.completion]) !== false) {
438
+ extensions.push(
439
+ pipeQueryCompletion(
440
+ typeof _optionalChain([config, 'optionalAccess', _4 => _4.completion]) === "object" ? config.completion : void 0
441
+ )
442
+ );
443
+ }
444
+ return new (0, _language.LanguageSupport)(lang, extensions);
445
+ }
446
+
447
+ // src/highlighting/monaco/language.ts
448
+ var monarchLanguage = {
449
+ defaultToken: "variable",
450
+ keywords: [...ALL_KEYWORDS],
451
+ functions: [...ALL_FUNCTIONS],
452
+ operators: [
453
+ ">=",
454
+ "<=",
455
+ "==",
456
+ "!=",
457
+ "&&",
458
+ "||",
459
+ ">",
460
+ "<",
461
+ "!",
462
+ "+",
463
+ "-",
464
+ "*",
465
+ "/",
466
+ "%"
467
+ ],
468
+ tokenizer: {
469
+ root: [
470
+ // Line comments (forward-compat)
471
+ [/\/\/.*$/, "comment"],
472
+ // Strings
473
+ [/"/, "string", "@string_double"],
474
+ [/'/, "string", "@string_single"],
475
+ // Numbers
476
+ [/\d+(\.\d+)?/, "number"],
477
+ // Pipe operator (bold styling via separate token)
478
+ [/\|/, "operator.pipe"],
479
+ // Multi-char operators first, then single-char
480
+ [/>=|<=|==|!=|&&|\|\|/, "operator"],
481
+ [/[><!+\-*/%]/, "operator"],
482
+ // Parentheses, comma, dot
483
+ [/[().,]/, "delimiter"],
484
+ // Identifiers, keywords, functions
485
+ [/[a-zA-Z_]\w*/, {
486
+ cases: {
487
+ "@keywords": "keyword",
488
+ "@functions": "type.function",
489
+ "@default": "variable"
490
+ }
491
+ }]
492
+ ],
493
+ string_double: [
494
+ [/[^\\"]+/, "string"],
495
+ [/\\./, "string.escape"],
496
+ [/"/, "string", "@pop"]
497
+ ],
498
+ string_single: [
499
+ [/[^\\']+/, "string"],
500
+ [/\\./, "string.escape"],
501
+ [/'/, "string", "@pop"]
502
+ ]
503
+ }
504
+ };
505
+ var languageConfiguration = {
506
+ brackets: [["(", ")"]],
507
+ autoClosingPairs: [
508
+ { open: "(", close: ")" },
509
+ { open: '"', close: '"' },
510
+ { open: "'", close: "'" }
511
+ ],
512
+ surroundingPairs: [
513
+ { open: "(", close: ")" },
514
+ { open: '"', close: '"' },
515
+ { open: "'", close: "'" }
516
+ ]
517
+ };
518
+
519
+ // src/highlighting/monaco/theme.ts
520
+ var tokenThemeRules = [
521
+ { token: "keyword", foreground: "c792ea", fontStyle: "bold" },
522
+ { token: "type.function", foreground: "ffcb6b" },
523
+ { token: "variable", foreground: "82aaff" },
524
+ { token: "string", foreground: "c3e88d" },
525
+ { token: "string.escape", foreground: "c3e88d", fontStyle: "bold" },
526
+ { token: "number", foreground: "f78c6c" },
527
+ { token: "operator", foreground: "89ddff" },
528
+ { token: "operator.pipe", foreground: "89ddff", fontStyle: "bold" },
529
+ { token: "delimiter", foreground: "89ddff" },
530
+ { token: "comment", foreground: "546e7a", fontStyle: "italic" }
531
+ ];
532
+
533
+ // src/highlighting/monaco/index.ts
534
+ function registerPipeQuery(monaco) {
535
+ monaco.languages.register({ id: "pipequery" });
536
+ monaco.languages.setMonarchTokensProvider("pipequery", monarchLanguage);
537
+ monaco.languages.setLanguageConfiguration("pipequery", languageConfiguration);
538
+ monaco.editor.defineTheme("pipequery-dark", {
539
+ base: "vs-dark",
540
+ inherit: true,
541
+ rules: tokenThemeRules,
542
+ colors: {}
543
+ });
544
+ }
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
558
+
559
+
560
+
561
+
562
+ exports.AGGREGATE_FUNCTIONS = AGGREGATE_FUNCTIONS; exports.ALL_FUNCTIONS = ALL_FUNCTIONS; exports.ALL_KEYWORDS = ALL_KEYWORDS; exports.BUILTIN_FUNCTIONS = BUILTIN_FUNCTIONS; exports.COLORS = COLORS; exports.KEYWORDS = KEYWORDS; exports.OPERATION_NAMES = OPERATION_NAMES; exports.WINDOW_FUNCTIONS = WINDOW_FUNCTIONS; exports.languageConfiguration = languageConfiguration; exports.monarchLanguage = monarchLanguage; exports.pipeQuery = pipeQuery; exports.pipeQueryCompletion = pipeQueryCompletion; exports.pipeQueryHighlightExtension = pipeQueryHighlightExtension; exports.pipeQueryHighlightStyle = pipeQueryHighlightStyle; exports.registerPipeQuery = registerPipeQuery; exports.tokenThemeRules = tokenThemeRules;
@@ -0,0 +1,136 @@
1
+ import { HighlightStyle, LanguageSupport } from '@codemirror/language';
2
+ import { Extension } from '@codemirror/state';
3
+
4
+ declare const OPERATION_NAMES: readonly ["where", "select", "sort", "groupBy", "join", "first", "last", "distinct", "map", "reduce", "rollup", "pivot", "flatten", "transpose"];
5
+ declare const KEYWORDS: readonly ["as", "asc", "desc", "true", "false", "null"];
6
+ declare const AGGREGATE_FUNCTIONS: readonly ["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"];
7
+ declare const BUILTIN_FUNCTIONS: readonly ["if", "coalesce", "lower", "upper", "len", "abs", "round", "concat", "contains", "startsWith", "endsWith", "trim", "substring", "replace"];
8
+ declare const WINDOW_FUNCTIONS: readonly ["running_sum", "running_avg", "running_count", "running_min", "running_max", "row_number", "lag", "lead"];
9
+ declare const ALL_FUNCTIONS: readonly ["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", "if", "coalesce", "lower", "upper", "len", "abs", "round", "concat", "contains", "startsWith", "endsWith", "trim", "substring", "replace", "running_sum", "running_avg", "running_count", "running_min", "running_max", "row_number", "lag", "lead"];
10
+ declare const ALL_KEYWORDS: readonly ["where", "select", "sort", "groupBy", "join", "first", "last", "distinct", "map", "reduce", "rollup", "pivot", "flatten", "transpose", "as", "asc", "desc", "true", "false", "null"];
11
+ declare const COLORS: {
12
+ readonly keyword: "#c792ea";
13
+ readonly string: "#c3e88d";
14
+ readonly number: "#f78c6c";
15
+ readonly operator: "#89ddff";
16
+ readonly field: "#82aaff";
17
+ readonly function: "#ffcb6b";
18
+ readonly comment: "#546e7a";
19
+ };
20
+
21
+ /**
22
+ * Highlight style for PipeQuery matching the project's dark theme palette.
23
+ */
24
+ declare const pipeQueryHighlightStyle: HighlightStyle;
25
+ /**
26
+ * CodeMirror extension that applies the PipeQuery highlight style.
27
+ */
28
+ declare const pipeQueryHighlightExtension: Extension;
29
+
30
+ interface PipeQueryCompletionConfig {
31
+ /** Dynamic field names from the current data context. */
32
+ fields?: string[] | (() => string[]);
33
+ /** Available data source names (e.g. "crypto", "orders"). */
34
+ sources?: string[] | (() => string[]);
35
+ }
36
+ declare function pipeQueryCompletion(config?: PipeQueryCompletionConfig): Extension;
37
+
38
+ interface PipeQueryConfig {
39
+ /**
40
+ * Autocomplete configuration. Pass `false` to disable.
41
+ * Defaults to enabled with no field/source suggestions.
42
+ */
43
+ completion?: PipeQueryCompletionConfig | false;
44
+ }
45
+ /**
46
+ * CodeMirror 6 language support for PipeQuery.
47
+ *
48
+ * Usage:
49
+ * ```ts
50
+ * import { pipeQuery } from './highlighting/codemirror';
51
+ *
52
+ * // Basic (keywords + functions autocomplete)
53
+ * const editor = new EditorView({ extensions: [pipeQuery()] });
54
+ *
55
+ * // With field & source suggestions
56
+ * const editor = new EditorView({
57
+ * extensions: [pipeQuery({ completion: { fields: ['id', 'name'], sources: ['orders'] } })],
58
+ * });
59
+ *
60
+ * // Disable autocomplete
61
+ * const editor = new EditorView({ extensions: [pipeQuery({ completion: false })] });
62
+ * ```
63
+ */
64
+ declare function pipeQuery(config?: PipeQueryConfig): LanguageSupport;
65
+
66
+ /**
67
+ * Monaco Monarch tokenizer definition for PipeQuery.
68
+ *
69
+ * See: https://microsoft.github.io/monaco-editor/monarch.html
70
+ */
71
+ declare const monarchLanguage: {
72
+ defaultToken: string;
73
+ keywords: ("where" | "select" | "sort" | "groupBy" | "join" | "first" | "last" | "distinct" | "map" | "reduce" | "rollup" | "pivot" | "flatten" | "transpose" | "as" | "asc" | "desc" | "true" | "false" | "null")[];
74
+ functions: ("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" | "if" | "coalesce" | "lower" | "upper" | "len" | "abs" | "round" | "concat" | "contains" | "startsWith" | "endsWith" | "trim" | "substring" | "replace" | "running_sum" | "running_avg" | "running_count" | "running_min" | "running_max" | "row_number" | "lag" | "lead")[];
75
+ operators: string[];
76
+ tokenizer: {
77
+ root: ((string | RegExp)[] | (RegExp | {
78
+ cases: {
79
+ '@keywords': string;
80
+ '@functions': string;
81
+ '@default': string;
82
+ };
83
+ })[])[];
84
+ string_double: (string | RegExp)[][];
85
+ string_single: (string | RegExp)[][];
86
+ };
87
+ };
88
+ /**
89
+ * Language configuration for PipeQuery (brackets, auto-closing, etc.).
90
+ */
91
+ declare const languageConfiguration: {
92
+ brackets: [string, string][];
93
+ autoClosingPairs: {
94
+ open: string;
95
+ close: string;
96
+ }[];
97
+ surroundingPairs: {
98
+ open: string;
99
+ close: string;
100
+ }[];
101
+ };
102
+
103
+ /**
104
+ * Monaco token theme rules for PipeQuery.
105
+ * Use with `monaco.editor.defineTheme()`.
106
+ *
107
+ * Colors match the project's dark theme palette from Docs.tsx.
108
+ */
109
+ declare const tokenThemeRules: ({
110
+ token: string;
111
+ foreground: string;
112
+ fontStyle: string;
113
+ } | {
114
+ token: string;
115
+ foreground: string;
116
+ fontStyle?: undefined;
117
+ })[];
118
+
119
+ /**
120
+ * Register the PipeQuery language with a Monaco Editor instance.
121
+ *
122
+ * Usage:
123
+ * ```ts
124
+ * import * as monaco from 'monaco-editor';
125
+ * import { registerPipeQuery } from './highlighting/monaco';
126
+ *
127
+ * registerPipeQuery(monaco);
128
+ * const editor = monaco.editor.create(container, {
129
+ * language: 'pipequery',
130
+ * theme: 'pipequery-dark',
131
+ * });
132
+ * ```
133
+ */
134
+ declare function registerPipeQuery(monaco: any): void;
135
+
136
+ export { AGGREGATE_FUNCTIONS, ALL_FUNCTIONS, ALL_KEYWORDS, BUILTIN_FUNCTIONS, COLORS, KEYWORDS, OPERATION_NAMES, type PipeQueryCompletionConfig, type PipeQueryConfig, WINDOW_FUNCTIONS, languageConfiguration, monarchLanguage, pipeQuery, pipeQueryCompletion, pipeQueryHighlightExtension, pipeQueryHighlightStyle, registerPipeQuery, tokenThemeRules };