@n8n/codemirror-lang-sql 1.0.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.
- package/.github/workflows/dispatch.yml +16 -0
- package/CHANGELOG.md +148 -0
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/index.cjs +723 -0
- package/dist/index.d.ts +196 -0
- package/dist/index.js +706 -0
- package/package.json +42 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
|
2
|
+
import { Extension } from '@codemirror/state';
|
|
3
|
+
import { Completion, CompletionSource } from '@codemirror/autocomplete';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Configuration for an [SQL Dialect](https://codemirror.net/6/docs/ref/#lang-sql.SQLDialect).
|
|
7
|
+
*/
|
|
8
|
+
type SQLDialectSpec = {
|
|
9
|
+
/**
|
|
10
|
+
A space-separated list of keywords for the dialect.
|
|
11
|
+
*/
|
|
12
|
+
keywords?: string;
|
|
13
|
+
/**
|
|
14
|
+
A space-separated string of built-in identifiers for the dialect.
|
|
15
|
+
*/
|
|
16
|
+
builtin?: string;
|
|
17
|
+
/**
|
|
18
|
+
A space-separated string of type names for the dialect.
|
|
19
|
+
*/
|
|
20
|
+
types?: string;
|
|
21
|
+
/**
|
|
22
|
+
Controls whether regular strings allow backslash escapes.
|
|
23
|
+
*/
|
|
24
|
+
backslashEscapes?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
Controls whether # creates a line comment.
|
|
27
|
+
*/
|
|
28
|
+
hashComments?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
Controls whether `//` creates a line comment.
|
|
31
|
+
*/
|
|
32
|
+
slashComments?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
When enabled `--` comments are only recognized when there's a
|
|
35
|
+
space after the dashes.
|
|
36
|
+
*/
|
|
37
|
+
spaceAfterDashes?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
When enabled, things quoted with "$$" are treated as
|
|
40
|
+
strings, rather than identifiers.
|
|
41
|
+
*/
|
|
42
|
+
doubleDollarQuotedStrings?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
When enabled, things quoted with double quotes are treated as
|
|
45
|
+
strings, rather than identifiers.
|
|
46
|
+
*/
|
|
47
|
+
doubleQuotedStrings?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
Enables strings like `_utf8'str'` or `N'str'`.
|
|
50
|
+
*/
|
|
51
|
+
charSetCasts?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
The set of characters that make up operators. Defaults to
|
|
54
|
+
`"*+\-%<>!=&|~^/"`.
|
|
55
|
+
*/
|
|
56
|
+
operatorChars?: string;
|
|
57
|
+
/**
|
|
58
|
+
The set of characters that start a special variable name.
|
|
59
|
+
Defaults to `"?"`.
|
|
60
|
+
*/
|
|
61
|
+
specialVar?: string;
|
|
62
|
+
/**
|
|
63
|
+
The characters that can be used to quote identifiers. Defaults
|
|
64
|
+
to `"\""`.
|
|
65
|
+
*/
|
|
66
|
+
identifierQuotes?: string;
|
|
67
|
+
/**
|
|
68
|
+
Controls whether bit values can be defined as 0b1010. Defaults
|
|
69
|
+
to false.
|
|
70
|
+
*/
|
|
71
|
+
unquotedBitLiterals?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
Controls whether bit values can contain other characters than 0 and 1.
|
|
74
|
+
Defaults to false.
|
|
75
|
+
*/
|
|
76
|
+
treatBitsAsBytes?: boolean;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
Represents an SQL dialect.
|
|
80
|
+
*/
|
|
81
|
+
declare class SQLDialect {
|
|
82
|
+
/**
|
|
83
|
+
The language for this dialect.
|
|
84
|
+
*/
|
|
85
|
+
readonly language: LRLanguage;
|
|
86
|
+
/**
|
|
87
|
+
The spec used to define this dialect.
|
|
88
|
+
*/
|
|
89
|
+
readonly spec: SQLDialectSpec;
|
|
90
|
+
private constructor();
|
|
91
|
+
/**
|
|
92
|
+
Returns the language for this dialect as an extension.
|
|
93
|
+
*/
|
|
94
|
+
get extension(): Extension;
|
|
95
|
+
/**
|
|
96
|
+
Define a new dialect.
|
|
97
|
+
*/
|
|
98
|
+
static define(spec: SQLDialectSpec): SQLDialect;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
Options used to configure an SQL extension.
|
|
102
|
+
*/
|
|
103
|
+
interface SQLConfig {
|
|
104
|
+
/**
|
|
105
|
+
The [dialect](https://codemirror.net/6/docs/ref/#lang-sql.SQLDialect) to use. Defaults to
|
|
106
|
+
[`StandardSQL`](https://codemirror.net/6/docs/ref/#lang-sql.StandardSQL).
|
|
107
|
+
*/
|
|
108
|
+
dialect?: SQLDialect;
|
|
109
|
+
/**
|
|
110
|
+
An object that maps table names, optionally prefixed with a
|
|
111
|
+
schema name (`"schema.table"`) to options (columns) that can be
|
|
112
|
+
completed for that table. Use lower-case names here.
|
|
113
|
+
*/
|
|
114
|
+
schema?: {
|
|
115
|
+
[table: string]: readonly (string | Completion)[];
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
By default, the completions for the table names will be
|
|
119
|
+
generated from the `schema` object. But if you want to
|
|
120
|
+
customize them, you can pass an array of completions through
|
|
121
|
+
this option.
|
|
122
|
+
*/
|
|
123
|
+
tables?: readonly Completion[];
|
|
124
|
+
/**
|
|
125
|
+
Similar to `tables`, if you want to provide completion objects
|
|
126
|
+
for your schemas rather than using the generated ones, pass them
|
|
127
|
+
here.
|
|
128
|
+
*/
|
|
129
|
+
schemas?: readonly Completion[];
|
|
130
|
+
/**
|
|
131
|
+
When given, columns from the named table can be completed
|
|
132
|
+
directly at the top level.
|
|
133
|
+
*/
|
|
134
|
+
defaultTable?: string;
|
|
135
|
+
/**
|
|
136
|
+
When given, tables prefixed with this schema name can be
|
|
137
|
+
completed directly at the top level.
|
|
138
|
+
*/
|
|
139
|
+
defaultSchema?: string;
|
|
140
|
+
/**
|
|
141
|
+
When set to true, keyword completions will be upper-case.
|
|
142
|
+
*/
|
|
143
|
+
upperCaseKeywords?: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
Returns a completion source that provides keyword completion for
|
|
147
|
+
the given SQL dialect.
|
|
148
|
+
*/
|
|
149
|
+
declare function keywordCompletionSource(dialect: SQLDialect, upperCase?: boolean): CompletionSource;
|
|
150
|
+
/**
|
|
151
|
+
Returns a completion sources that provides schema-based completion
|
|
152
|
+
for the given configuration.
|
|
153
|
+
*/
|
|
154
|
+
declare function schemaCompletionSource(config: SQLConfig): CompletionSource;
|
|
155
|
+
/**
|
|
156
|
+
SQL language support for the given SQL dialect, with keyword
|
|
157
|
+
completion, and, if provided, schema-based completion as extra
|
|
158
|
+
extensions.
|
|
159
|
+
*/
|
|
160
|
+
declare function sql(config?: SQLConfig): LanguageSupport;
|
|
161
|
+
/**
|
|
162
|
+
The standard SQL dialect.
|
|
163
|
+
*/
|
|
164
|
+
declare const StandardSQL: SQLDialect;
|
|
165
|
+
/**
|
|
166
|
+
Dialect for [PostgreSQL](https://www.postgresql.org).
|
|
167
|
+
*/
|
|
168
|
+
declare const PostgreSQL: SQLDialect;
|
|
169
|
+
/**
|
|
170
|
+
[MySQL](https://dev.mysql.com/) dialect.
|
|
171
|
+
*/
|
|
172
|
+
declare const MySQL: SQLDialect;
|
|
173
|
+
/**
|
|
174
|
+
Variant of [`MySQL`](https://codemirror.net/6/docs/ref/#lang-sql.MySQL) for
|
|
175
|
+
[MariaDB](https://mariadb.org/).
|
|
176
|
+
*/
|
|
177
|
+
declare const MariaSQL: SQLDialect;
|
|
178
|
+
/**
|
|
179
|
+
SQL dialect for Microsoft [SQL
|
|
180
|
+
Server](https://www.microsoft.com/en-us/sql-server).
|
|
181
|
+
*/
|
|
182
|
+
declare const MSSQL: SQLDialect;
|
|
183
|
+
/**
|
|
184
|
+
[SQLite](https://sqlite.org/) dialect.
|
|
185
|
+
*/
|
|
186
|
+
declare const SQLite: SQLDialect;
|
|
187
|
+
/**
|
|
188
|
+
Dialect for [Cassandra](https://cassandra.apache.org/)'s SQL-ish query language.
|
|
189
|
+
*/
|
|
190
|
+
declare const Cassandra: SQLDialect;
|
|
191
|
+
/**
|
|
192
|
+
[PL/SQL](https://en.wikipedia.org/wiki/PL/SQL) dialect.
|
|
193
|
+
*/
|
|
194
|
+
declare const PLSQL: SQLDialect;
|
|
195
|
+
|
|
196
|
+
export { Cassandra, MSSQL, MariaSQL, MySQL, PLSQL, PostgreSQL, SQLConfig, SQLDialect, SQLDialectSpec, SQLite, StandardSQL, keywordCompletionSource, schemaCompletionSource, sql };
|