diff --git a/CLAUDE.md b/CLAUDE.md index 0bb2f489..78c54556 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,7 +1,7 @@ # Contributor guide — altinity-sql-browser A modular ES-module SPA that builds to one self-contained HTML file served from -ClickHouse. No framework; runtime deps are rare and deliberate (currently five, +ClickHouse. No framework; runtime deps are rare and deliberate (currently seven, all bundled — see hard rule 4). Quality is held by tests. ## Hard rules @@ -38,10 +38,11 @@ all bundled — see hard rule 4). Quality is held by tests. fail clearly. `package-lock.json` is committed; use `npm ci` for a reproducible dependency graph in local, CI, and release builds, and update the lock only with an intentional dependency change. - There are **six** bundled runtime dependencies — **CodeMirror 6** (the SQL + There are **seven** bundled runtime dependencies — **CodeMirror 6** (the SQL editor, saved-query Spec JSON editor, and read-only source viewer, behind injected seams — #21/#212/#213), - **Chart.js** (the Chart result view) with **chartjs-adapter-date-fns** + **Chart.js** (the Chart result view) with **chartjs-adapter-date-fns** and + **date-fns** (registers the date-math backend Chart.js's `time` scale needs for line/area charts over a time-role X column — #309; the pure axis/role decision of *whether* to use it stays in `core/chart-data.ts`, the adapter @@ -55,7 +56,7 @@ all bundled — see hard rule 4). Quality is held by tests. token tree is projected into DOM by `ui/doc-markdown-view.ts` under the fail-closed policy: images/raw HTML/rejected links render as literal text; measured +44 KB raw / ~3% artifact delta) — all inlined into the - artifact, so the page still makes zero third-party requests. + artifact, so the page loads no runtime libraries from third-party CDNs. Adding *another* runtime dependency is a deliberate decision (it grows the single served file) — don't do it casually. When a feature needs a library, keep the testable logic pure in `src/core/` (chart axis/role/pivot math in diff --git a/README.md b/README.md index c6dbd106..ad8b1df7 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,16 @@ tabbed SQL editor with syntax highlighting, find/replace, bracket matching, and schema-aware autocomplete, streaming results with table / JSON / chart views, saved queries, history, and shareable links. It ships as a **single self-contained HTML file served from ClickHouse itself** (no Node -server, no CDN, no external fonts) — the page makes **zero third-party -requests** and renders in the OS's native UI font. Its five bundled runtime +server, no CDN, no external fonts) — every runtime dependency is bundled, and +the page renders in the OS's native UI font. Its seven bundled runtime dependencies — **CodeMirror 6** (the SQL editor, saved-query Spec JSON editor, and read-only source viewer), -**Chart.js** + **chartjs-adapter-date-fns** (the chart result view, including -a real time scale for time-series line/area charts), **@dagrejs/dagre** (the +**Chart.js** + **chartjs-adapter-date-fns** + **date-fns** (the chart result +view, including a real time scale for time-series line/area charts), +**@dagrejs/dagre** (the EXPLAIN pipeline-graph layout), and -**@preact/signals-core** (state reactivity) — are inlined into that one file. +**@preact/signals-core** (state reactivity), and **marked** (Markdown +tokenization for reference documentation) — are inlined into that one file. Refactored from a single-file SPA into a fully modular, test-first codebase held at **100% test coverage**. @@ -59,7 +61,7 @@ only moving parts are ClickHouse's HTTP handlers and your OAuth provider. The workbench uses **CodeMirror 6** behind separately injected SQL and Spec editor seams (#143/#21/#212) — bundled and inlined like the other runtime deps, -so the page still makes zero third-party requests. A saved-query tab exposes a +so no editor library is loaded from a third-party CDN. A saved-query tab exposes a visible **SQL | Spec** switch: SQL edits the executable text, while Spec edits only the complete `query.spec` JSON. Linked Save validates and atomically commits both drafts; an unsaved tab remains SQL-only until its first Save. diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md index 194cac8d..3c19ce1b 100644 --- a/THIRD-PARTY-NOTICES.md +++ b/THIRD-PARTY-NOTICES.md @@ -23,6 +23,46 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI --- +## chartjs-adapter-date-fns — v3.0.0 + +The MIT License (MIT) + +Copyright (c) 2019 Chart.js Contributors + +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. + +--- + +## date-fns — v4.4.0 + +MIT License + +Copyright (c) 2021 Sasha Koss and Lesha Koss https://kossnocorp.mit-license.org + +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. + +--- + ## @dagrejs/dagre — v3.0.0 The MIT License (MIT) @@ -51,6 +91,62 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI --- +## marked — v18.0.7 + +### Marked + +Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/) +Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/) + +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. + +### Markdown + +Copyright © 2004, John Gruber +http://daringfireball.net/ +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +- Neither the name “Markdown” nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +This software is provided by the copyright holders and contributors “as is” +and any express or implied warranties, including, but not limited to, the +implied warranties of merchantability and fitness for a particular purpose are +disclaimed. In no event shall the copyright owner or contributors be liable +for any direct, indirect, incidental, special, exemplary, or consequential +damages (including, but not limited to, procurement of substitute goods or +services; loss of use, data, or profits; or business interruption) however +caused and on any theory of liability, whether in contract, strict liability, +or tort (including negligence or otherwise) arising in any way out of the use +of this software, even if advised of the possibility of such damage. + +--- + ## Ajv — v8.20.0 (build-time schema compiler; generated helpers only) MIT License diff --git a/docs/ADR-0001-reactivity.md b/docs/ADR-0001-reactivity.md index 52b38a0b..7dd7f17c 100644 --- a/docs/ADR-0001-reactivity.md +++ b/docs/ADR-0001-reactivity.md @@ -19,7 +19,7 @@ a dependent → stale UI. This is an *absence-of-reactivity* problem, distinct f a *component-model* problem. Three hard constraints frame any solution: a single self-contained HTML artifact -with zero third-party requests (CLAUDE.md rule 4 — deliberate deps only), the +with no third-party asset loads (CLAUDE.md rule 4 — deliberate deps only), the per-file 100/100/100/100 coverage gate (rule 1), and the injected-seam layering (rule 2). @@ -40,8 +40,8 @@ memoized `computed()` — none of which the naive synchronous prototype provides It costs one small, zero-transitive-dependency package and **+1.4 KB gzip** to the artifact (vs +0.45 KB hand-rolled), in exchange for not owning ~70 lines + ~180 test lines of correctness-critical reactive code. Per CLAUDE.md rule 4 this -is a deliberate dependency; it is still inlined, so the artifact makes zero -third-party requests. +is a deliberate dependency; it is still inlined, so the artifact makes no +third-party asset request for it. ## Options considered (all measured) @@ -122,8 +122,8 @@ re-opening this ADR's "no framework" line for *complex panels only*. **What it cost (measured / observed):** - **Bundle: +6.8 KB gzip** (148,044 → 154,873 B; raw 457,892 → 474,440) — close - to this ADR's +5.9 KB estimate. ~+4.6% of the artifact, still zero third-party - requests (inlined). + to this ADR's +5.9 KB estimate. ~+4.6% of the artifact, still with no + third-party asset loads (inlined). - **A second paradigm.** signals-core `effect()`s drive the rest of `createApp` (tabs/results/title); the schema tree is Preact. Two render models coexist — the main ongoing cost. @@ -321,8 +321,8 @@ Three further observations: rewrite of ~9 k LOC of `src/ui/` and its 100%-covered tests. - Grafana/Superset use React for reasons this project does not have — a third-party plugin ecosystem and a very large contributor surface. This - project's differentiator is the opposite: one self-contained file, zero - third-party requests. + project's differentiator is the opposite: one self-contained file with no + third-party asset loads. - ADR-0002 (incremental strict TypeScript) further reduces the framework pull: a typed `h()` hyperscript and a typed `app` controller surface recover much of the edit-time DX people reach for a framework to get. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 3a18edda..fdff9dc1 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -118,6 +118,7 @@ failure signs out; after, it is a query error). ## Build `build/build.mjs` runs esbuild (bundle + minify, IIFE), inlines the script and -`styles.css` into `build/template.html` → a single `dist/sql.html`. Five -bundled runtime dependencies (CodeMirror 6, Chart.js + chartjs-adapter-date-fns, -dagre, `@preact/signals-core`); the served page makes zero third-party requests. +`styles.css` into `build/template.html` → a single `dist/sql.html`. Seven +bundled runtime dependencies (CodeMirror 6, Chart.js + +chartjs-adapter-date-fns + date-fns, dagre, `@preact/signals-core`, marked); +none is loaded from a third-party CDN. diff --git a/docs/assets/site.css b/docs/assets/site.css index 38fa44fd..dbe64f01 100644 --- a/docs/assets/site.css +++ b/docs/assets/site.css @@ -1,5 +1,5 @@ /* Altinity SQL Browser — public site styles. - Hand-built, zero third-party requests. Tokens lifted from src/styles.css. */ + Hand-built, with no third-party asset loads. Tokens lifted from src/styles.css. */ :root { --accent: #0079AD; diff --git a/docs/blog/index.html b/docs/blog/index.html index e475ad6a..001feac7 100644 --- a/docs/blog/index.html +++ b/docs/blog/index.html @@ -40,7 +40,7 @@
One HTML file ClickHouse® serves itself, OAuth in the browser, per-user grants, zero third-party requests, and a CSP that enforces it.
+One HTML file ClickHouse® serves itself, OAuth in the browser, per-user grants, bundled dependencies, and a strict CSP.
diff --git a/docs/blog/no-backend-sql-console.html b/docs/blog/no-backend-sql-console.html index 7df25eff..68018d54 100644 --- a/docs/blog/no-backend-sql-console.html +++ b/docs/blog/no-backend-sql-console.html @@ -4,7 +4,7 @@Open the network tab while you use it. You'll see calls to ClickHouse and to your IdP — and nothing else. No CDN, no analytics, no web fonts; it renders in your OS font. Everything the app - needs is inlined into that one file at build time, including the two libraries it leans on (Chart.js - for the chart view, dagre for the graph layout). I'd rather ship one ~440 KB file I can diff than a + needs is inlined into that one file at build time, including CodeMirror, Chart.js and its date + adapter, dagre, signals-core, and marked. I'd rather ship one file I can diff than a tree of packages I can't.
That's a security property too, and it's enforced rather than hoped for. The handler ships a strict diff --git a/docs/index.html b/docs/index.html index 3021c266..8ce64537 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,11 +4,11 @@
An OAuth-gated query browser with charts, EXPLAIN pipeline graphs, data-flow graphs and smart autocomplete — built as a single self-contained HTML file. Serve it from ClickHouse itself, @@ -65,8 +65,8 @@
The browser talks straight to ClickHouse over HTTP. There is no app server, no database of its own, - and no third-party requests — just one HTML file and your OAuth provider.
+The browser talks straight to ClickHouse over HTTP. There is no app server or database of its own; + runtime libraries are bundled into the one HTML file.
esbuild bundles everything — including Chart.js and the graph layout engine — into a single
- sql.html. No CDN, no fonts, no external calls. Serve it from ClickHouse's
+ sql.html. No CDN or external font/library loads. Serve it from ClickHouse's
user_files and you're done.
One HTML file ClickHouse serves itself — OAuth in the browser, per-user grants, zero third-party requests.
+One HTML file ClickHouse serves itself — OAuth in the browser, per-user grants, dependencies bundled.