monaco-yql-languages 1.0.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/.editorconfig ADDED
@@ -0,0 +1,17 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_size = 4
7
+ indent_style = space
8
+ insert_final_newline = true
9
+ max_line_length = 100
10
+ trim_trailing_whitespace = true
11
+
12
+ [{*.json, *.yaml, *.yml}]
13
+ indent_size = 2
14
+
15
+ [*.md]
16
+ max_line_length = 0
17
+ trim_trailing_whitespace = false
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ dist/
package/.eslintrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": ["@gravity-ui/eslint-config", "@gravity-ui/eslint-config/prettier"],
3
+ "root": true,
4
+ "env": {
5
+ "node": true,
6
+ },
7
+ }
@@ -0,0 +1,44 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ verify_files:
11
+ name: Verify Files
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v3
16
+ with:
17
+ fetch-depth: 0
18
+ - name: Setup Node
19
+ uses: actions/setup-node@v3
20
+ with:
21
+ node-version: 18
22
+ cache: 'npm'
23
+ - name: Install Packages
24
+ run: npm ci
25
+ - name: Lint Files
26
+ run: npm run lint
27
+ - name: Typecheck
28
+ run: npm run typecheck
29
+
30
+ tests:
31
+ name: Tests
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - name: Checkout
35
+ uses: actions/checkout@v3
36
+ with:
37
+ fetch-depth: 0
38
+ - name: Setup Node
39
+ uses: actions/setup-node@v3
40
+ with:
41
+ node-version: 18
42
+ cache: 'npm'
43
+ - name: Install Packages
44
+ run: npm ci
@@ -0,0 +1,21 @@
1
+ on:
2
+ release:
3
+ types: [released]
4
+
5
+ name: Publication
6
+
7
+ jobs:
8
+ publication:
9
+ runs-on: ubuntu-latest
10
+ env:
11
+ ASSET_NAME: embedded-ui
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: actions/setup-node@v4
15
+ with:
16
+ node-version: 18
17
+ registry-url: https://registry.npmjs.org
18
+ - run: npm ci
19
+ - run: npm publish
20
+ env:
21
+ NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
@@ -0,0 +1,21 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ jobs:
8
+ release:
9
+ if: github.repository == 'ydb-platform/monaco-yql-languages'
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v3
13
+ - uses: actions/setup-node@v3
14
+ with:
15
+ node-version: 18
16
+ - run: npm ci
17
+ - run: npm run lint
18
+ - uses: GoogleCloudPlatform/release-please-action@v3
19
+ with:
20
+ token: ${{ secrets.YDB_PLATFORM_BOT_TOKEN_REPO }}
21
+ release-type: node
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx commitlint -e
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx nano-staged
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 18
@@ -0,0 +1,4 @@
1
+ storybook-static
2
+ dist
3
+ CHANGELOG.md
4
+ CONTRIBUTING.md
@@ -0,0 +1,2 @@
1
+ dist/
2
+
package/.prettierrc.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('@gravity-ui/prettier-config');
package/.stylelintrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["@gravity-ui/stylelint-config", "@gravity-ui/stylelint-config/prettier"]
3
+ }
package/AUTHORS ADDED
@@ -0,0 +1,5 @@
1
+ The following authors have created the source code of "Yandex Database Grafana plugin" published and distributed by YANDEX LLC as the owner.
2
+
3
+ Note: This list does not necessarily include everyone who has contributed code, especially since many employees of one corporation may be contributing. The revision history in source control gives the full list of contributors.
4
+
5
+ Valerii Sidorenko <balepas@yandex-team.ru>
package/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ ## [1.0.2](https://github.com/ydb-platform/monaco-yql-languages/compare/v1.0.1...v1.0.2) (2024-07-23)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * reorder keywords ([#11](https://github.com/ydb-platform/monaco-yql-languages/issues/11)) ([a27d7ad](https://github.com/ydb-platform/monaco-yql-languages/commit/a27d7ad5d098c19fc10fd118bdc673ee1f69ab02))
9
+
10
+ ## [1.0.1](https://github.com/ydb-platform/monaco-yql-languages/compare/v1.0.0...v1.0.1) (2024-07-22)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * change repository name ([#7](https://github.com/ydb-platform/monaco-yql-languages/issues/7)) ([12dede2](https://github.com/ydb-platform/monaco-yql-languages/commit/12dede2afff61037a0fc6ff81730491ef0eacddd))
16
+ * repo name ([#5](https://github.com/ydb-platform/monaco-yql-languages/issues/5)) ([76272e7](https://github.com/ydb-platform/monaco-yql-languages/commit/76272e7238bb1216a3d91138f9feca2a1d6a8512))
17
+ * **YQL:** reorder keywords ([#6](https://github.com/ydb-platform/monaco-yql-languages/issues/6)) ([852d03d](https://github.com/ydb-platform/monaco-yql-languages/commit/852d03d1ab98088b9e67a1a1580dba196da853b2))
18
+
19
+ ## 1.0.0 (2024-07-22)
20
+
21
+
22
+ ### Features
23
+
24
+ * initial commit ([37f1034](https://github.com/ydb-platform/monaco-yql-languages/commit/37f10349d4444735f4b1d860ddb1a455147c3718))
25
+ * **YQL:** add keywords "intersect", "except" ([#1](https://github.com/ydb-platform/monaco-yql-languages/issues/1)) ([db08828](https://github.com/ydb-platform/monaco-yql-languages/commit/db08828838e83b2831593897a6d85e36440a3d8f))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * license in package.json, add CHANGELOG ([#2](https://github.com/ydb-platform/monaco-yql-languages/issues/2)) ([d45e9e1](https://github.com/ydb-platform/monaco-yql-languages/commit/d45e9e17ce6f216bfe53eaf62c9bf2f9bef22cd3))
31
+ * package-lock ([#3](https://github.com/ydb-platform/monaco-yql-languages/issues/3)) ([9f346a9](https://github.com/ydb-platform/monaco-yql-languages/commit/9f346a942a4f32a38226c8e2733e48d506cd95a8))
package/CODEOWNERS ADDED
@@ -0,0 +1 @@
1
+ * @Raubzeug
@@ -0,0 +1,36 @@
1
+ # Notice to external contributors
2
+
3
+ ## General info
4
+
5
+ Hello! In order for us (YANDEX LLC) to accept patches and other contributions from you, you will have to adopt our Yandex Contributor License Agreement (the “**CLA**”). The current version of the CLA can be found here:
6
+
7
+ 1. https://yandex.ru/legal/cla/?lang=en (in English) and
8
+ 2. https://yandex.ru/legal/cla/?lang=ru (in Russian).
9
+
10
+ By adopting the CLA, you state the following:
11
+
12
+ - You obviously wish and are willingly licensing your contributions to us for our open source projects under the terms of the CLA,
13
+ - You have read the terms and conditions of the CLA and agree with them in full,
14
+ - You are legally able to provide and license your contributions as stated,
15
+ - We may use your contributions for our open source projects and for any other our project too,
16
+ - We rely on your assurances concerning the rights of third parties in relation to your contributions.
17
+
18
+ If you agree with these principles, please read and adopt our CLA. By providing us your contributions, you hereby declare that you have already read and adopt our CLA, and we may freely merge your contributions with our corresponding open source project and use it in further in accordance with terms and conditions of the CLA.
19
+
20
+ ## Provide contributions
21
+
22
+ If you have already adopted terms and conditions of the CLA, you are able to provide your contributions. When you submit your pull request, please add the following information into it:
23
+
24
+ ```
25
+ I hereby agree to the terms of the CLA available at: [link].
26
+ ```
27
+
28
+ Replace the bracketed text as follows:
29
+
30
+ - [link] is the link to the current version of the CLA: https://yandex.ru/legal/cla/?lang=en (in English) or https://yandex.ru/legal/cla/?lang=ru (in Russian).
31
+
32
+ It is enough to provide us such notification once.
33
+
34
+ ## Other questions
35
+
36
+ If you have any questions, please mail us at opensource@yandex-team.ru.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 YANDEX LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # monaco-yql-languages &middot; [![npm package](https://img.shields.io/npm/v/monaco-yql-languages)](https://www.npmjs.com/package/monaco-yql-languages) [![CI](https://img.shields.io/github/actions/workflow/status/ydb-platform/monaco-yql-languages/.github/workflows/ci.yml?label=CI&logo=github)](https://github.com/ydb-platform/monaco-yql-languages/actions/workflows/ci.yml?query=branch:main)
2
+
3
+ ## Install
4
+
5
+ ```
6
+ npm install --save monaco-editor monaco-editor-webpack-plugin monaco-yql-languages
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ Add `customLanguages` section to monaco-editor-webpack-plugin options:
12
+
13
+ ```json
14
+ {
15
+ "customLanguages": [{"label": "yql", "entry": "monaco-yql-languages/build/monaco.contribution"}]
16
+ }
17
+ ```
18
+
19
+ This adds colorization for languages `yql (yql_ansi)`, `s-expression` and `clickhouse`
@@ -0,0 +1 @@
1
+ module.exports = {extends: ['@commitlint/config-conventional']};
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "monaco-yql-languages",
3
+ "version": "1.0.2",
4
+ "description": "YQL languages for the Monaco Editor, based on monaco-languages.",
5
+ "author": "YDB",
6
+ "license": "MIT",
7
+ "module": "./build/monaco.contribution.js",
8
+ "types": "./build/monaco.contribution.d.ts",
9
+ "scripts": {
10
+ "prepare": "husky",
11
+ "build": "npm run build:clean && npm run build:compile",
12
+ "build:clean": "rimraf build",
13
+ "build:compile": "tsc",
14
+ "lint": "npm run lint:code && npm run lint:other",
15
+ "lint:code": "eslint --ext .js,.jsx,.ts,.tsx --quiet .",
16
+ "lint:other": "npm run prettier -- --check ",
17
+ "prettier": "prettier \"**/*.{md,yaml,yml}\"",
18
+ "typecheck": "tsc --noEmit",
19
+ "prepublishOnly": "npm run lint && npm run build"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git@github.com:ydb-platform/monaco-yql-languages.git"
24
+ },
25
+ "devDependencies": {
26
+ "@gravity-ui/eslint-config": "^3.1.1",
27
+ "@gravity-ui/prettier-config": "^1.1.0",
28
+ "@gravity-ui/stylelint-config": "^4.0.1",
29
+ "@gravity-ui/tsconfig": "^1.0.0",
30
+ "eslint": "^8.10.0",
31
+ "husky": "^9.0.11",
32
+ "monaco-editor": "^0.32.1",
33
+ "prettier": "^3.2.5",
34
+ "rimraf": "^3.0.2",
35
+ "typescript": "^5.4.2"
36
+ },
37
+ "peerDependencies": {
38
+ "monaco-editor": ">=0.27.0"
39
+ },
40
+ "nano-staged": {
41
+ "*.{scss}": [
42
+ "stylelint --fix --quiet"
43
+ ],
44
+ "*.{js,jsx,ts,tsx}": [
45
+ "eslint --fix --quiet"
46
+ ],
47
+ "*.md": [
48
+ "prettier --write"
49
+ ]
50
+ }
51
+ }
@@ -0,0 +1,246 @@
1
+ import {CompletionLists, getCompletionItemsProvider} from './completion';
2
+ import {Emitter, IDisposable, IEvent, languages} from './fillers/monaco-editor-core';
3
+
4
+ interface ILang extends languages.ILanguageExtensionPoint {
5
+ loader: () => Promise<ILangImpl>;
6
+ }
7
+
8
+ interface ILangImpl {
9
+ conf: languages.LanguageConfiguration;
10
+ language: languages.IMonarchLanguage;
11
+ completions?: CompletionLists;
12
+ }
13
+
14
+ const languageDefinitions: {[languageId: string]: ILang} = {};
15
+ const lazyLanguageLoaders: {[languageId: string]: LazyLanguageLoader} = {};
16
+
17
+ class LazyLanguageLoader {
18
+ static getOrCreate(languageId: string): LazyLanguageLoader {
19
+ if (!lazyLanguageLoaders[languageId]) {
20
+ lazyLanguageLoaders[languageId] = new LazyLanguageLoader(languageId);
21
+ }
22
+ return lazyLanguageLoaders[languageId];
23
+ }
24
+
25
+ private readonly _languageId: string;
26
+ private _loadingTriggered: boolean;
27
+ private _lazyLoadPromise: Promise<ILangImpl>;
28
+ private _lazyLoadPromiseResolve!: (value: ILangImpl) => void;
29
+ private _lazyLoadPromiseReject!: (err: any) => void;
30
+
31
+ constructor(languageId: string) {
32
+ this._languageId = languageId;
33
+ this._loadingTriggered = false;
34
+ this._lazyLoadPromise = new Promise((resolve, reject) => {
35
+ this._lazyLoadPromiseResolve = resolve;
36
+ this._lazyLoadPromiseReject = reject;
37
+ });
38
+ }
39
+
40
+ whenLoaded(): Promise<ILangImpl> {
41
+ return this._lazyLoadPromise;
42
+ }
43
+
44
+ load(): Promise<ILangImpl> {
45
+ if (!this._loadingTriggered) {
46
+ this._loadingTriggered = true;
47
+ languageDefinitions[this._languageId].loader().then(
48
+ (mod) => this._lazyLoadPromiseResolve(mod),
49
+ (err) => this._lazyLoadPromiseReject(err),
50
+ );
51
+ }
52
+ return this._lazyLoadPromise;
53
+ }
54
+ }
55
+
56
+ export function loadLanguage(languageId: string): Promise<ILangImpl> {
57
+ return LazyLanguageLoader.getOrCreate(languageId).load();
58
+ }
59
+
60
+ export function registerLanguage(def: ILang): void {
61
+ const languageId = def.id;
62
+
63
+ languageDefinitions[languageId] = def;
64
+ languages.register(def);
65
+
66
+ const lazyLanguageLoader = LazyLanguageLoader.getOrCreate(languageId);
67
+ languages.setMonarchTokensProvider(
68
+ languageId,
69
+ lazyLanguageLoader.whenLoaded().then((mod) => mod.language),
70
+ );
71
+ languages.onLanguage(languageId, () => {
72
+ lazyLanguageLoader.load().then((mod) => {
73
+ languages.setLanguageConfiguration(languageId, mod.conf);
74
+ });
75
+ });
76
+ lazyLanguageLoader.whenLoaded().then((mod) => {
77
+ if (mod.completions) {
78
+ registerCompletionItemProvider(languageId, mod.completions);
79
+ }
80
+ });
81
+ }
82
+
83
+ function registerCompletionItemProvider(languageId: string, completions: CompletionLists) {
84
+ const disposables: IDisposable[] = [];
85
+
86
+ function unregister() {
87
+ while (disposables.length > 0) {
88
+ disposables.pop()?.dispose();
89
+ }
90
+ }
91
+
92
+ const defaults: LanguageServiceDefaults | undefined = (languages as any)[languageId];
93
+
94
+ if (!defaults || defaults.modeConfiguration.completionItems) {
95
+ disposables.push(
96
+ languages.registerCompletionItemProvider(
97
+ languageId,
98
+ getCompletionItemsProvider(completions, languages.CompletionItemKind),
99
+ ),
100
+ );
101
+ }
102
+
103
+ if (defaults) {
104
+ disposables.push(
105
+ defaults.onDidChange(() => {
106
+ unregister();
107
+ registerCompletionItemProvider(languageId, completions);
108
+ }),
109
+ );
110
+ }
111
+ }
112
+
113
+ export interface ICreateData {
114
+ languageId: string;
115
+ }
116
+
117
+ export interface ModeConfiguration {
118
+ /**
119
+ * Defines whether the built-in completionItemProvider is enabled.
120
+ */
121
+ readonly completionItems?: boolean;
122
+
123
+ /**
124
+ * Defines whether the built-in hoverProvider is enabled.
125
+ */
126
+ readonly hovers?: boolean;
127
+
128
+ /**
129
+ * Defines whether the built-in documentSymbolProvider is enabled.
130
+ */
131
+ readonly documentSymbols?: boolean;
132
+
133
+ /**
134
+ * Defines whether the built-in definitions provider is enabled.
135
+ */
136
+ readonly definitions?: boolean;
137
+
138
+ /**
139
+ * Defines whether the built-in references provider is enabled.
140
+ */
141
+ readonly references?: boolean;
142
+
143
+ /**
144
+ * Defines whether the built-in references provider is enabled.
145
+ */
146
+ readonly documentHighlights?: boolean;
147
+
148
+ /**
149
+ * Defines whether the built-in rename provider is enabled.
150
+ */
151
+ readonly rename?: boolean;
152
+
153
+ /**
154
+ * Defines whether the built-in color provider is enabled.
155
+ */
156
+ readonly colors?: boolean;
157
+
158
+ /**
159
+ * Defines whether the built-in foldingRange provider is enabled.
160
+ */
161
+ readonly foldingRanges?: boolean;
162
+
163
+ /**
164
+ * Defines whether the built-in diagnostic provider is enabled.
165
+ */
166
+ readonly diagnostics?: boolean;
167
+
168
+ /**
169
+ * Defines whether the built-in selection range provider is enabled.
170
+ */
171
+ readonly selectionRanges?: boolean;
172
+ }
173
+
174
+ export interface DiagnosticsOptions {
175
+ readonly validate?: boolean;
176
+ }
177
+
178
+ export interface LanguageServiceDefaults {
179
+ readonly languageId: string;
180
+ readonly onDidChange: IEvent<LanguageServiceDefaults>;
181
+ readonly diagnosticsOptions: DiagnosticsOptions;
182
+ readonly modeConfiguration: ModeConfiguration;
183
+ setDiagnosticsOptions(options: DiagnosticsOptions): void;
184
+ setModeConfiguration(modeConfiguration: ModeConfiguration): void;
185
+ }
186
+
187
+ export class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
188
+ private _onDidChange = new Emitter<LanguageServiceDefaults>();
189
+ private _diagnosticsOptions!: DiagnosticsOptions;
190
+ private _modeConfiguration!: ModeConfiguration;
191
+ private _languageId: string;
192
+
193
+ constructor(
194
+ languageId: string,
195
+ diagnosticsOptions: DiagnosticsOptions,
196
+ modeConfiguration: ModeConfiguration,
197
+ ) {
198
+ this._languageId = languageId;
199
+ this.setDiagnosticsOptions(diagnosticsOptions);
200
+ this.setModeConfiguration(modeConfiguration);
201
+ }
202
+
203
+ get onDidChange(): IEvent<LanguageServiceDefaults> {
204
+ return this._onDidChange.event;
205
+ }
206
+
207
+ get languageId(): string {
208
+ return this._languageId;
209
+ }
210
+
211
+ get modeConfiguration(): ModeConfiguration {
212
+ return this._modeConfiguration;
213
+ }
214
+
215
+ get diagnosticsOptions(): DiagnosticsOptions {
216
+ return this._diagnosticsOptions;
217
+ }
218
+
219
+ setDiagnosticsOptions(options: DiagnosticsOptions): void {
220
+ this._diagnosticsOptions = options || Object.create(null);
221
+ this._onDidChange.fire(this);
222
+ }
223
+
224
+ setModeConfiguration(modeConfiguration: ModeConfiguration): void {
225
+ this._modeConfiguration = modeConfiguration || Object.create(null);
226
+ this._onDidChange.fire(this);
227
+ }
228
+ }
229
+
230
+ export const modeConfigurationDefault: Required<ModeConfiguration> = {
231
+ completionItems: true,
232
+ hovers: true,
233
+ documentSymbols: true,
234
+ definitions: true,
235
+ references: true,
236
+ documentHighlights: true,
237
+ rename: true,
238
+ colors: true,
239
+ foldingRanges: true,
240
+ diagnostics: true,
241
+ selectionRanges: true,
242
+ };
243
+
244
+ export const diagnosticDefault: Required<DiagnosticsOptions> = {
245
+ validate: true,
246
+ };
@@ -0,0 +1,31 @@
1
+ import {
2
+ LanguageServiceDefaults,
3
+ LanguageServiceDefaultsImpl,
4
+ diagnosticDefault,
5
+ modeConfigurationDefault,
6
+ registerLanguage,
7
+ } from '../_.contribution';
8
+ import {languages} from '../fillers/monaco-editor-core';
9
+
10
+ export const LANGUAGE_ID = 'clickhouse';
11
+
12
+ registerLanguage({
13
+ id: LANGUAGE_ID,
14
+ extensions: [],
15
+ loader: () =>
16
+ import('./clickhouse').then((module) => {
17
+ return {
18
+ conf: module.conf,
19
+ language: module.language,
20
+ completions: module.completionLists,
21
+ };
22
+ }),
23
+ });
24
+
25
+ export const clickhouseDefaults: LanguageServiceDefaults = new LanguageServiceDefaultsImpl(
26
+ LANGUAGE_ID,
27
+ diagnosticDefault,
28
+ modeConfigurationDefault,
29
+ );
30
+
31
+ (languages as any)[LANGUAGE_ID] = clickhouseDefaults;