mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-27 11:25:42 +00:00
- Add host-rendered native IDE primitives (PluginCodeEditor/Monaco, PluginDataGrid/@tanstack/react-virtual, PluginSplitPane, PluginErCanvas) with Shadow DOM slot projection (zero iframes, zero plugin JS in renderer) - Expand Remote DOM budgets, expose full 22 Netcatty semantic CSS tokens, add dblclick/contextmenu/scroll/selection events, cursor-anchored PluginPopover, database theme icon, and full-bleed chrome flag - Add dynamic user-approved TCP/TLS byte streams (incl. localhost opt-in blocking internal control ports), in-band STARTTLS upgrade with cert fingerprint confirmation, durable revocable Vault SSH host bindings, plugin-owned encrypted secrets, native ui.openFile/saveFile streaming handles, 4 MiB clipboard, and prefix-filtered storage.keys - Optimize plugin view image pipeline with pooled sandboxed rasterizer window (auto-destroyed on idle/error/dispose), LRU version+hash cache in PluginViewResources, transient failure eviction in HostDrawnViewHost, renderer-side session deduplication, and RemoteImageElement cache + retry - Temporarily enable plugin host by default in hostBootstrap.cjs (marked TODO(revert), opt-out via NETCATTY_PLUGIN_DEV=0)
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { extractCurrentSqlStatement, extractSqlTableAliases } from './sqlStatement';
|
|
|
|
test('extractCurrentSqlStatement splits statements respecting strings, comments, and PG dollar quotes', () => {
|
|
const sql = [
|
|
"-- first query; not a split",
|
|
"SELECT 'semi;colon' AS a;",
|
|
"CREATE FUNCTION f() RETURNS text AS $$ BEGIN RETURN 'x;y'; END; $$ LANGUAGE plpgsql;",
|
|
"SELECT /* block; comment */ * FROM orders WHERE id = 1",
|
|
].join('\n');
|
|
|
|
const firstIdx = sql.indexOf("SELECT 'semi");
|
|
assert.equal(extractCurrentSqlStatement(sql, firstIdx + 5), "-- first query; not a split\nSELECT 'semi;colon' AS a");
|
|
|
|
const fnIdx = sql.indexOf("RETURN 'x;y'");
|
|
assert.equal(
|
|
extractCurrentSqlStatement(sql, fnIdx),
|
|
"CREATE FUNCTION f() RETURNS text AS $$ BEGIN RETURN 'x;y'; END; $$ LANGUAGE plpgsql",
|
|
);
|
|
|
|
const lastIdx = sql.indexOf('FROM orders');
|
|
assert.equal(
|
|
extractCurrentSqlStatement(sql, lastIdx),
|
|
'SELECT /* block; comment */ * FROM orders WHERE id = 1',
|
|
);
|
|
});
|
|
|
|
test('extractSqlTableAliases resolves table names and aliases across FROM and JOIN clauses', () => {
|
|
const sql = 'SELECT o.id, u.email FROM public.orders AS o INNER JOIN users u ON u.id = o.user_id WHERE o.status = 1';
|
|
const aliases = extractSqlTableAliases(sql);
|
|
assert.equal(aliases.get('o'), 'orders');
|
|
assert.equal(aliases.get('orders'), 'orders');
|
|
assert.equal(aliases.get('u'), 'users');
|
|
assert.equal(aliases.get('users'), 'users');
|
|
assert.equal(aliases.has('where'), false);
|
|
});
|