@elastic/monaco-esql 3.1.7 → 3.1.9
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/README.md +3 -6
- package/lib/definitions.d.ts +1 -0
- package/lib/definitions.js +14 -4
- package/lib/monarch.js +42 -17
- package/package.json +20 -21
package/README.md
CHANGED
|
@@ -5,20 +5,18 @@ grammar engine).
|
|
|
5
5
|
|
|
6
6
|
<img width="725" alt="image" src="https://github.com/user-attachments/assets/a725841e-68d6-4765-aa29-54a3062e6a3e" />
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
## Usage
|
|
10
9
|
|
|
11
10
|
To highlight ES|QL code in Monaco editor, you need to register ES|QL language
|
|
12
11
|
and its Monarch grammar:
|
|
13
12
|
|
|
14
13
|
```js
|
|
15
|
-
import { language as monarchLanguage } from
|
|
14
|
+
import { language as monarchLanguage } from "@elastic/monaco-esql/lib/monarch-shared";
|
|
16
15
|
|
|
17
|
-
monaco.languages.register({id:
|
|
18
|
-
monaco.languages.setMonarchTokensProvider(
|
|
16
|
+
monaco.languages.register({ id: "esql" });
|
|
17
|
+
monaco.languages.setMonarchTokensProvider("esql", monarchLanguage);
|
|
19
18
|
```
|
|
20
19
|
|
|
21
|
-
|
|
22
20
|
## Releasing
|
|
23
21
|
|
|
24
22
|
Publish with `release-it` tool:
|
|
@@ -28,7 +26,6 @@ yarn build
|
|
|
28
26
|
npx release-it
|
|
29
27
|
```
|
|
30
28
|
|
|
31
|
-
|
|
32
29
|
## License
|
|
33
30
|
|
|
34
31
|
MIT
|
package/lib/definitions.d.ts
CHANGED
package/lib/definitions.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.temporalUnits = exports.operators = exports.delimiters = exports.functions = exports.literals = exports.options = exports.processingCommands = exports.sourceCommands = void 0;
|
|
3
|
+
exports.temporalUnits = exports.operators = exports.delimiters = exports.functions = exports.literals = exports.options = exports.processingCommands = exports.sourceCommands = exports.headerCommands = void 0;
|
|
4
|
+
exports.headerCommands = ["SET"];
|
|
4
5
|
exports.sourceCommands = [
|
|
5
6
|
"FROM",
|
|
6
7
|
"ROW",
|
|
@@ -18,6 +19,7 @@ exports.processingCommands = [
|
|
|
18
19
|
"EVAL",
|
|
19
20
|
"FORK",
|
|
20
21
|
"FULL JOIN",
|
|
22
|
+
"FUSE",
|
|
21
23
|
"GROK",
|
|
22
24
|
"INFO",
|
|
23
25
|
"INLINESTATS",
|
|
@@ -35,13 +37,21 @@ exports.processingCommands = [
|
|
|
35
37
|
"RERANK",
|
|
36
38
|
"RIGHT JOIN",
|
|
37
39
|
"RIGHT",
|
|
38
|
-
"RRF",
|
|
39
40
|
"SAMPLE",
|
|
40
41
|
"SORT",
|
|
41
42
|
"STATS",
|
|
42
|
-
"WHERE"
|
|
43
|
+
"WHERE",
|
|
44
|
+
];
|
|
45
|
+
exports.options = [
|
|
46
|
+
"BY",
|
|
47
|
+
"ON",
|
|
48
|
+
"WITH",
|
|
49
|
+
"METADATA",
|
|
50
|
+
"WHERE",
|
|
51
|
+
"SCORE",
|
|
52
|
+
"KEY",
|
|
53
|
+
"GROUP",
|
|
43
54
|
];
|
|
44
|
-
exports.options = ["BY", "ON", "WITH", "METADATA", "WHERE"];
|
|
45
55
|
exports.literals = ["TRUE", "FALSE", "NULL"];
|
|
46
56
|
exports.functions = [
|
|
47
57
|
"ABS",
|
package/lib/monarch.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.create = void 0;
|
|
4
4
|
const create = (deps = {}) => {
|
|
5
|
-
const { sourceCommands = [], processingCommands = [], options = [], literals = [], functions = [], delimiters = [], temporalUnits = [], } = deps;
|
|
6
|
-
const timeUnits = withLowercaseVariants(temporalUnits.flat()).sort((a, b) =>
|
|
5
|
+
const { headerCommands = [], sourceCommands = [], processingCommands = [], options = [], literals = [], functions = [], delimiters = [], temporalUnits = [], } = deps;
|
|
6
|
+
const timeUnits = withLowercaseVariants(temporalUnits.flat()).sort((a, b) => a > b ? -1 : 1);
|
|
7
7
|
return {
|
|
8
8
|
// Uncomment when developing.
|
|
9
9
|
// defaultToken: "invalid",
|
|
10
10
|
// ES|QL is case-insensitive.
|
|
11
11
|
ignoreCase: false,
|
|
12
12
|
// Lists of known language keywords and built-ins.
|
|
13
|
+
headerCommands: withLowercaseVariants(headerCommands),
|
|
13
14
|
sourceCommands: withLowercaseVariants(sourceCommands),
|
|
14
15
|
processingCommands: withLowercaseVariants(processingCommands),
|
|
15
16
|
processingCommandsOnlyUppercase: processingCommands,
|
|
@@ -24,8 +25,8 @@ const create = (deps = {}) => {
|
|
|
24
25
|
// Pre-defined regular expressions.
|
|
25
26
|
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
|
26
27
|
digits: /\d+(_+\d+)*/,
|
|
27
|
-
symbols: /[
|
|
28
|
-
columnIdentifier: /[a-zA-Z0-9_
|
|
28
|
+
symbols: /[=><!~:&|+\-*/^%.,]+/,
|
|
29
|
+
columnIdentifier: /[a-zA-Z0-9_*-]+/,
|
|
29
30
|
brackets: [
|
|
30
31
|
{ open: "[", close: "]", token: "delimiter.square" },
|
|
31
32
|
{ open: "(", close: ")", token: "delimiter.parenthesis" },
|
|
@@ -37,11 +38,14 @@ const create = (deps = {}) => {
|
|
|
37
38
|
{ include: "@whitespace" },
|
|
38
39
|
// Keywords
|
|
39
40
|
[
|
|
40
|
-
/@?[a-zA-Z_$][\w$]*(?![
|
|
41
|
+
/@?[a-zA-Z_$][\w$]*(?![.\-:a-zA-Z_0-9])/,
|
|
41
42
|
{
|
|
42
43
|
cases: {
|
|
44
|
+
"@headerCommands": { token: "keyword.command.header.$0" },
|
|
43
45
|
"@sourceCommands": { token: "keyword.command.source.$0" },
|
|
44
|
-
"@processingCommandsOnlyUppercase": {
|
|
46
|
+
"@processingCommandsOnlyUppercase": {
|
|
47
|
+
token: "keyword.command.processing.$0",
|
|
48
|
+
},
|
|
45
49
|
"@options": { token: "keyword.option.$0" },
|
|
46
50
|
"@literals": { token: "keyword.literal.$0" },
|
|
47
51
|
"@functions": { token: "identifier.function.$0" },
|
|
@@ -72,14 +76,14 @@ const create = (deps = {}) => {
|
|
|
72
76
|
[/\/\/.*$/, "comment"],
|
|
73
77
|
],
|
|
74
78
|
comment: [
|
|
75
|
-
[/[
|
|
79
|
+
[/[^/*]+/, "comment"],
|
|
76
80
|
[/\*\//, "comment", "@pop"],
|
|
77
|
-
[/[
|
|
81
|
+
[/[/*]/, "comment"],
|
|
78
82
|
],
|
|
79
83
|
doc: [
|
|
80
|
-
[/[
|
|
84
|
+
[/[^/*]+/, "comment.doc"],
|
|
81
85
|
[/\*\//, "comment.doc", "@pop"],
|
|
82
|
-
[/[
|
|
86
|
+
[/[/*]/, "comment.doc"],
|
|
83
87
|
],
|
|
84
88
|
// ---------------------------------------------------------------- Commands
|
|
85
89
|
// This code block allows to color commands when they are followed by a pipe
|
|
@@ -90,22 +94,43 @@ const create = (deps = {}) => {
|
|
|
90
94
|
/\|/,
|
|
91
95
|
{ token: "delimiter.pipe", switchTo: "@beforeMnemonicWhitespace" },
|
|
92
96
|
],
|
|
97
|
+
[
|
|
98
|
+
/\(/,
|
|
99
|
+
{
|
|
100
|
+
token: "delimiter.parenthesis",
|
|
101
|
+
switchTo: "@firstCommandNameInSubQuery",
|
|
102
|
+
},
|
|
103
|
+
],
|
|
93
104
|
],
|
|
94
105
|
beforeMnemonicWhitespace: [
|
|
95
106
|
{ include: "@whitespace" },
|
|
96
107
|
["", { token: "", switchTo: "@commandName" }],
|
|
97
108
|
],
|
|
98
|
-
|
|
99
|
-
commandName: [
|
|
100
|
-
// First tries to match all known command names.
|
|
109
|
+
exactCommandName: [
|
|
101
110
|
[
|
|
102
|
-
|
|
111
|
+
withLowercaseVariants(headerCommands).join("|"),
|
|
112
|
+
{ token: "keyword.command.header.$0", switchTo: "@root" },
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
withLowercaseVariants(sourceCommands).join("|"),
|
|
103
116
|
{ token: "keyword.command.source.$0", switchTo: "@root" },
|
|
104
117
|
],
|
|
105
118
|
[
|
|
106
|
-
processingCommands.join("|"),
|
|
119
|
+
withLowercaseVariants(processingCommands).join("|"),
|
|
107
120
|
{ token: "keyword.command.processing.$0", switchTo: "@root" },
|
|
108
121
|
],
|
|
122
|
+
],
|
|
123
|
+
firstCommandNameInSubQuery: [
|
|
124
|
+
{ include: "@whitespace" },
|
|
125
|
+
// Try to match an exact command name
|
|
126
|
+
{ include: "@exactCommandName" },
|
|
127
|
+
// If not matched, go to root
|
|
128
|
+
{ include: "@root" },
|
|
129
|
+
],
|
|
130
|
+
// Matches *command name*, i.e. the mnemonic.
|
|
131
|
+
commandName: [
|
|
132
|
+
// First tries to match all known command names.
|
|
133
|
+
{ include: "@exactCommandName" },
|
|
109
134
|
// If command name is not well known, just matches the first word.
|
|
110
135
|
[
|
|
111
136
|
/\w+\b/,
|
|
@@ -145,8 +170,8 @@ const create = (deps = {}) => {
|
|
|
145
170
|
],
|
|
146
171
|
timeInterval: [[`(@digits)\\s*(${timeUnits.join("|")})`, "number.time"]],
|
|
147
172
|
number: [
|
|
148
|
-
[/(@digits)[eE]([
|
|
149
|
-
[/(@digits)?\.(@digits)([eE][
|
|
173
|
+
[/(@digits)[eE]([-+]?(@digits))?/, "number.float"],
|
|
174
|
+
[/(@digits)?\.(@digits)([eE][-+]?(@digits))?/, "number.float"],
|
|
150
175
|
[/(@digits)/, "number"],
|
|
151
176
|
],
|
|
152
177
|
// Single double-quote strings: "str"
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/monaco-esql",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
|
-
"access": "public"
|
|
6
|
+
"access": "public",
|
|
7
|
+
"registry": "https://registry.npmjs.org"
|
|
7
8
|
},
|
|
8
9
|
"description": "Monaco editor Monarch language syntax definitions for ES|QL",
|
|
9
10
|
"main": "lib/index.js",
|
|
@@ -15,18 +16,19 @@
|
|
|
15
16
|
"format": "biome format ./src",
|
|
16
17
|
"format:fix": "biome format --write ./src",
|
|
17
18
|
"lint": "biome lint ./src",
|
|
18
|
-
"lint:fix": "biome lint --
|
|
19
|
+
"lint:fix": "biome lint --write ./src",
|
|
19
20
|
"test": "echo \"no tests...\"",
|
|
20
21
|
"clean": "npx rimraf@5.0.5 lib",
|
|
21
22
|
"build:es2020": "tsc --project tsconfig.build.json --module commonjs --target es2020 --outDir lib",
|
|
22
23
|
"build": "yarn build:es2020",
|
|
23
24
|
"storybook": "storybook dev -p 6006",
|
|
24
|
-
"build-storybook": "storybook build"
|
|
25
|
+
"build-storybook": "storybook build",
|
|
26
|
+
"release": "npx release-it --ci"
|
|
25
27
|
},
|
|
26
28
|
"license": "MIT",
|
|
27
29
|
"repository": {
|
|
28
30
|
"type": "git",
|
|
29
|
-
"url": "https://github.com/elastic/
|
|
31
|
+
"url": "git+https://github.com/elastic/monaco-esql.git"
|
|
30
32
|
},
|
|
31
33
|
"keywords": [
|
|
32
34
|
"esql",
|
|
@@ -48,26 +50,23 @@
|
|
|
48
50
|
"monaco-editor": "*"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"@biomejs/biome": "2.
|
|
52
|
-
"@chromatic-com/storybook": "
|
|
53
|
+
"@biomejs/biome": "2.2.4",
|
|
54
|
+
"@chromatic-com/storybook": "4.1.1",
|
|
53
55
|
"@monaco-editor/react": "4.7.0",
|
|
54
|
-
"@storybook/addon-
|
|
55
|
-
"@storybook/
|
|
56
|
-
"@
|
|
57
|
-
"@storybook/experimental-addon-test": "^8.6.14",
|
|
58
|
-
"@storybook/react": "8",
|
|
59
|
-
"@storybook/react-vite": "8",
|
|
60
|
-
"@storybook/test": "^8.6.14",
|
|
61
|
-
"@types/react": "19.1.10",
|
|
56
|
+
"@storybook/addon-onboarding": "9.1.10",
|
|
57
|
+
"@storybook/react-vite": "9.1.10",
|
|
58
|
+
"@types/react": "19.1.13",
|
|
62
59
|
"@vitest/browser": "3.2.4",
|
|
63
60
|
"@vitest/coverage-v8": "3.2.4",
|
|
64
|
-
"monaco-editor": "0.
|
|
65
|
-
"playwright": "1.
|
|
61
|
+
"monaco-editor": "0.53.0",
|
|
62
|
+
"playwright": "1.55.1",
|
|
66
63
|
"react": "19.1.1",
|
|
67
64
|
"react-dom": "19.1.1",
|
|
68
|
-
"storybook": "
|
|
65
|
+
"storybook": "9.1.10",
|
|
69
66
|
"typescript": "5.9.2",
|
|
70
|
-
"vitest": "3.2.4"
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
"vitest": "3.2.4",
|
|
68
|
+
"@storybook/addon-vitest": "9.1.10",
|
|
69
|
+
"@storybook/addon-docs": "9.1.10",
|
|
70
|
+
"release-it": "19.0.5"
|
|
71
|
+
}
|
|
73
72
|
}
|