initial commit - far from runnable

This commit is contained in:
Anika Raemer 2025-09-21 12:39:54 +02:00
commit db057ce342
8614 changed files with 1032171 additions and 0 deletions

59
node_modules/sql-highlight/lib/escapeHtml.js generated vendored Normal file
View file

@ -0,0 +1,59 @@
/*
* Simplified version of the escape-html library which can be found at
* https://github.com/component/escape-html
*
* Original license:
* (The MIT License)
*
* Copyright (c) 2012-2013 TJ Holowaychuk
* Copyright (c) 2015 Andreas Lubbe
* Copyright (c) 2015 Tiancheng "Timothy" Gu
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* 'Software'), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
const charCodeMap = {
34: '"', // "
38: '&', // &
39: ''', // '
60: '&lt;', // <
62: '&gt;' // >
};
function escapeHtml(str) {
let html = '';
let lastIndex = 0;
for (let i = 0; i < str.length; i++) {
const replacement = charCodeMap[str.charCodeAt(i)];
if (!replacement) continue;
if (lastIndex !== i) {
html += str.substring(lastIndex, i);
}
lastIndex = i + 1;
html += replacement;
}
return html + str.substring(lastIndex);
}
module.exports = escapeHtml;

30
node_modules/sql-highlight/lib/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,30 @@
declare module 'sql-highlight' {
export interface HighlightOptions {
html?: boolean;
htmlEscaper?: (str: string) => string;
classPrefix?: string;
colors?: {
keyword: string;
function: string;
number: string;
string: string;
identifier: string;
special: string;
bracket: string;
comment: string;
clear: string;
};
}
export interface Segment {
name: string;
content: string;
}
export function getSegments(sqlString: string): Array<Segment>;
export function highlight(
sqlString: string,
options?: HighlightOptions
): string;
export const DEFAULT_OPTIONS: HighlightOptions;
}

85
node_modules/sql-highlight/lib/index.js generated vendored Normal file
View file

@ -0,0 +1,85 @@
const keywords = require('./keywords');
const escapeHtml = require('./escapeHtml');
const DEFAULT_OPTIONS = {
html: false,
htmlEscaper: escapeHtml,
classPrefix: 'sql-hl-',
colors: {
keyword: '\x1b[35m',
function: '\x1b[31m',
number: '\x1b[32m',
string: '\x1b[32m',
identifier: '\x1b[0m',
special: '\x1b[33m',
bracket: '\x1b[33m',
comment: '\x1b[2m\x1b[90m',
clear: '\x1b[0m'
}
};
const highlighters = [
/(?<number>[+-]?(?:\d+\.\d+|\d+|\.\d+)(?:E[+-]?\d+)?)/,
// Note: Repeating string escapes like 'sql''server' will also work as they are just repeating strings
/(?<string>'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*")/,
/(?<comment>--[^\n\r]*|#[^\n\r]*|\/\*(?:[^*]|\*(?!\/))*\*\/)/,
// Future improvement: Comments should be allowed between the function name and the opening parenthesis
/\b(?<function>\w+)(?=\s*\()/,
/(?<bracket>[()])/,
/(?<identifier>\b\w+\b|`(?:[^`\\]|\\.)*`)/,
/(?<whitespace>\s+)/,
// Multi-character arithmetic, bitwise, comparison, and compound operators as listed in
// https://www.w3schools.com/sql/sql_operators.asp, https://www.tutorialspoint.com/sql/sql-operators.htm,
// https://data-flair.training/blogs/sql-operators/, plus any single character (in particular ,:;.) not matched by
// the above regexps.
/(?<special>\^-=|\|\*=|\+=|-=|\*=|\/=|%=|&=|>=|<=|<>|!=|!<|!>|>>|<<|.)/
];
// Regex of the shape /(?<token1>...)|(?<token2>...)|.../g
const tokenizer = new RegExp(
[
`\\b(?<keyword>${keywords.join('|')})\\b`,
...highlighters.map((regex) => regex.source)
].join('|'),
'gis'
);
function getSegments(sqlString) {
const segments = Array.from(sqlString.matchAll(tokenizer), (match) => ({
name: Object.keys(match.groups).find((key) => match.groups[key]),
content: match[0]
}));
return segments;
}
function highlight(sqlString, options) {
const fullOptions = Object.assign({}, DEFAULT_OPTIONS, options);
return getSegments(sqlString)
.map(({ name, content }) => {
if (fullOptions.html) {
const escapedContent = fullOptions.htmlEscaper(content);
return name === 'whitespace'
? escapedContent
: `<span class="${fullOptions.classPrefix}${name}">${escapedContent}</span>`;
}
if (fullOptions.colors[name]) {
return fullOptions.colors[name] + content + fullOptions.colors.clear;
}
return content;
})
.join('');
}
module.exports = {
getSegments,
highlight,
DEFAULT_OPTIONS
};

146
node_modules/sql-highlight/lib/keywords.js generated vendored Normal file
View file

@ -0,0 +1,146 @@
module.exports = [
'ADD CONSTRAINT',
'ADD',
'ALL',
'ALTER COLUMN',
'ALTER TABLE',
'ALTER',
'AND',
'ANY',
'AS',
'ASC',
'AUTO_INCREMENT',
'BACKUP DATABASE',
'BEGIN',
'BETWEEN',
'BINARY',
'BLOB',
'BY',
'CASCADE',
'CASE',
'CHAR',
'CHECK',
'COLUMN',
'COMMIT',
'CONSTRAINT',
'CREATE DATABASE',
'CREATE INDEX',
'CREATE OR REPLACE VIEW',
'CREATE PROCEDURE',
'CREATE TABLE',
'CREATE UNIQUE INDEX',
'CREATE VIEW',
'CREATE',
'CURRENT_DATE',
'CURRENT_TIME',
'DATABASE',
'DATETIME',
'DECIMAL',
'DECLARE',
'DEFAULT',
'DELETE',
'DESC',
'DISTINCT',
'DROP COLUMN',
'DROP CONSTRAINT',
'DROP DATABASE',
'DROP DEFAULT',
'DROP INDEX',
'DROP TABLE',
'DROP VIEW',
'DROP',
'EACH',
'ELSE',
'ELSEIF',
'END',
'ENGINE',
'EXEC',
'EXISTS',
'FALSE',
'FOR',
'FOREIGN KEY',
'FROM',
'FULL OUTER JOIN',
'GROUP BY',
'GROUP',
'HAVING',
'IF',
'IFNULL',
'ILIKE',
'IN',
'INDEX_LIST',
'INDEX',
'INNER JOIN',
'INSERT INTO SELECT',
'INSERT INTO',
'INSERT',
'INTEGER',
'INTERVAL',
'INTO',
'IS NOT NULL',
'IS NULL',
'IS',
'JOIN',
'KEY',
'KEYS',
'LEADING',
'LEFT JOIN',
'LEFT',
'LIKE',
'LIMIT',
'LONGTEXT',
'MATCH',
'NOT NULL',
'NOT',
'NULL',
'ON',
'OPTION',
'OR',
'ORDER BY',
'ORDER',
'OUT',
'OUTER JOIN',
'OUTER',
'OVERLAPS',
'PRAGMA',
'PRIMARY KEY',
'PRIMARY',
'PRINT',
'PROCEDURE',
'REFERENCES',
'REPLACE',
'RETURNING',
'RIGHT JOIN',
'RIGHT',
'ROWNUM',
'SELECT DISTINCT',
'SELECT INTO',
'SELECT TOP',
'SELECT',
'SET',
'SHOW',
'TABLE',
'TEXT',
'THEN',
'TIMESTAMP',
'TINYBLOB',
'TINYINT',
'TINYTEXT',
'TO',
'TOP',
'TRAILING',
'TRUE',
'TRUNCATE TABLE',
'UNION ALL',
'UNION',
'UNIQUE',
'UNSIGNED',
'UPDATE',
'VALUES',
'VARBINARY',
'VARCHAR',
'VIEW',
'WHEN',
'WHERE',
'WITH'
];