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

21
node_modules/sql-highlight/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Malcolm Nihlén
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.

184
node_modules/sql-highlight/README.md generated vendored Normal file
View file

@ -0,0 +1,184 @@
# sql-highlight
> A simple and lightweight library for highlighting SQL queries written in pure
> JavaScript
[![Tests Status][tests-badge]][tests-url]
[![Coverage Status][coveralls-badge]][coveralls-url]
[![NPM Version][npm-version-badge]][npm-url]
[![Bundle Size][bundlejs-badge]][bundlejs-url]
> [!IMPORTANT]
> Due to some recent issues with the release flow, the 5.0.0 release was somewhat prematurely released. With NPM not allowing unpublishing the current release is 6.0.0.
## What's it all about?
sql-highlight is a small package that highlights SQL queries. It can output to
both the terminal with Unicode escape sequences, as well as to normal HTML. Oh,
and there are no external dependencies 😉
## Installation
sql-highlight is tested to work with Node.js 16, 18, 20 and 22.
Install with Yarn:
```bash
yarn add sql-highlight
```
Install with NPM:
```bash
npm install sql-highlight
```
## Usage
**In its most basic form:**
```js
const { highlight } = require('sql-highlight')
const sqlString = "SELECT `id`, `username` FROM `users` WHERE `email` = 'test@example.com'"
const highlighted = highlight(sqlString)
console.log(highlighted)
```
**Output:**
![Screenshot](screenshot.png)
**HTML mode:**
```js
const { highlight } = require('sql-highlight')
const sqlString = "SELECT `id`, `username` FROM `users` WHERE `email` = 'test@example.com'"
const highlighted = highlight(sqlString, {
html: true
})
document.body.innerHTML += highlighted
```
**Output:**
```html
<span class="sql-hl-keyword">SELECT</span>
<span class="sql-hl-identifier">`id`</span>
<span class="sql-hl-special">,</span>
<span class="sql-hl-identifier">`username`</span>
<span class="sql-hl-keyword">FROM</span>
<span class="sql-hl-identifier">`users`</span>
<span class="sql-hl-keyword">WHERE</span>
<span class="sql-hl-identifier">`email`</span>
<span class="sql-hl-special">=</span>
<span class="sql-hl-string">'test@example.com'</span>
```
## Options
The following options may be passed to the `highlight` function.
| Option | Value | Default | Description |
| --- | --- | --- | --- |
| html | `boolean` | `false` | Set to true to render HTML instead of Unicode.
| htmlEscaper | `(str: string) => string` | Basic escaper | Function to escape HTML entities. Uses a basic escaper by default. If HTML mode is used in a browser environment this could be useful to escape strings using the DOM.
| classPrefix | `string` | `'sql-hl-'` | Prefix to prepend to classes for HTML span-tags. Is appended with entity name.
| colors | `Object` | _See below_* | What color codes to use for Unicode rendering. A list of basic color codes can be found [here](https://docs.rs/embedded-text/0.4.0/embedded_text/style/index.html#standard-color-codes).
\* `colors` option default value
```js
{
keyword: '\x1b[35m', // SQL reserved keywords
function: '\x1b[31m', // Functions
number: '\x1b[32m', // Numbers
string: '\x1b[32m', // Strings
special: '\x1b[33m', // Special characters
bracket: '\x1b[33m', // Brackets (parentheses)
comment: '\x1b[2m\x1b[90m', // Comments
clear: '\x1b[0m' // Clear (inserted after each match)
}
```
## Custom highlighting
In case you want to do the highlighting yourself you can use `getSegments` to only let sql-highlight parse the SQL string for you. You can then use the segments to highlight it yourself.
```js
const { getSegments } = require('sql-highlight')
const sqlString = "SELECT `id`, `username` FROM `users` WHERE `email` = 'test@example.com'"
const segments = getSegments(sqlString)
console.log(segments)
```
**Output:**
```js
[
{ name: 'keyword', content: 'SELECT' },
{ name: 'whitespace', content: ' ' },
{ name: 'identifier', content: '`id`' },
{ name: 'special', content: ',' },
{ name: 'whitespace', content: ' ' },
{ name: 'identifier', content: '`username`' },
{ name: 'whitespace', content: ' ' },
{ name: 'keyword', content: 'FROM' },
{ name: 'whitespace', content: ' ' },
{ name: 'identifier', content: '`users`' },
{ name: 'whitespace', content: ' ' },
{ name: 'keyword', content: 'WHERE' },
{ name: 'whitespace', content: ' ' },
{ name: 'identifier', content: '`email`' },
{ name: 'whitespace', content: ' ' },
{ name: 'special', content: '=' },
{ name: 'whitespace', content: ' ' },
{ name: 'string', content: "'test@example.com'" }
]
```
## Contributing
See the [contribution guidelines](CONTRIBUTING.md).
## Tests
We use [Jest](https://jestjs.io/) for running our tests. The test suite can be run by running `npm run test`. This will run both Jest and Biome.
## Code style
We use [Biome](https://biomejs.dev/) for making sure that our code remains pretty and consistent throughout the project. If your editor doesn't automatically pick up our config you can lint the code using `npm run lint`.
## A note on Dependabot
[Dependabot Auto
Merge](https://github.com/marketplace/actions/dependabot-auto-merge) is
installed in this repository to automatically merge dependabot PRs for minor
version updates. Only PRs that pass the tests get merged. No new releases will
be created for dependency updates as there are no production dependencies and a
release would therefore be completely unnecessary.
## Additional information
Malcolm Nihlén - malcolm.nihlen@gmail.com
Distributed under the MIT licence. See `LICENCE` for more information.
https://github.com/scriptcoded
## Disclaimer
This was initially a fork from https://github.com/pomahtuk/sequilize-highlight.
The repo wasn't being updated, NPM wasn't serving the latest version and there
was a severe memory leak. Though the latest version now exists on NPM, issues
still persist. This repo serves to address those problems, as well as providing
a cleaner interface that's not bound to Sequelize.
With version 3.0.0 the library was almost completely rewritten, which leaves
very little similarity with the original repo.
[tests-badge]: https://img.shields.io/github/actions/workflow/status/scriptcoded/sql-highlight/test.yml?branch=main&label=tests
[tests-url]: https://github.com/scriptcoded/sql-highlight/actions/workflows/test.yml
[coveralls-badge]: https://coveralls.io/repos/github/scriptcoded/sql-highlight/badge.svg
[coveralls-url]: https://coveralls.io/github/scriptcoded/sql-highlight
[npm-version-badge]: https://img.shields.io/npm/v/sql-highlight.svg
[npm-url]: https://npmjs.org/package/sql-highlight
[bundlejs-badge]: https://deno.bundlejs.com/?bundle&q=sql-highlight&badge
[bundlejs-url]: https://bundlejs.com/?bundle&q=sql-highlight

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: '&quot;', // "
38: '&amp;', // &
39: '&#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'
];

49
node_modules/sql-highlight/package.json generated vendored Normal file
View file

@ -0,0 +1,49 @@
{
"name": "sql-highlight",
"version": "6.1.0",
"description": "A simple and lightweight library for highlighting SQL queries written in pure JavaScript",
"main": "lib/index.js",
"types": "./lib/index.d.ts",
"repository": {
"type": "git",
"url": "git@github.com:scriptcoded/sql-highlight.git"
},
"files": [
"/lib"
],
"engines": {
"node": ">=14"
},
"scripts": {
"pretest": "npm run lint",
"test": "jest",
"test:coverage": "jest --coverage",
"lint": "biome check",
"lint:fix": "biome check --write"
},
"keywords": [
"sql",
"syntax",
"highlight",
"highlighter"
],
"author": "Malcolm Nihlén <malcolm.nihlen@gmail.com>",
"contributors": [
"pomahtuk"
],
"funding": [
"https://github.com/scriptcoded/sql-highlight?sponsor=1",
{
"type": "github",
"url": "https://github.com/sponsors/scriptcoded"
}
],
"license": "MIT",
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"jest": "^29.7.0",
"semantic-release": "^24.2.5"
}
}