feat: Server Beam — sql.on across two Destinations - #158
Merged
Conversation
Cross-DB data move via Node cells: up to 2 link servers and 10 sql.on() calls per editor Execute. Explicitly omit commercial/edition metering. Co-authored-by: huy.phan9 <huyplb@users.noreply.github.com>
Replace Link Servers plan with docs/plans/server-beam.md; same caps (2 endpoints, 10 sql.on per Execute), no paid-tier metering notes. Co-authored-by: huy.phan9 <huyplb@users.noreply.github.com>
Node cells can call sql.on('source'|'target') with up to 2 checked
Destinations (order = source, then target) and at most 10 sql.on() calls
per Execute. Adds ping / copy / chunked samples and bridge tests.
Co-authored-by: huy.phan9 <huyplb@users.noreply.github.com>
Single objects and primitive/Date values become a one-row grid instead of
failing normalization (which left the result grid unusable). Explicit
{ columns, rows } shape is unchanged.
Co-authored-by: huy.phan9 <huyplb@users.noreply.github.com>
Co-authored-by: huy.phan9 <huyplb@users.noreply.github.com>
Update cap constant, error copy, tests, plan, and sample comments. Co-authored-by: huy.phan9 <huyplb@users.noreply.github.com>
Contributor
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_1971e07b-9f32-4ae4-98be-eb4199aa2965) |
huyplb
added a commit
that referenced
this pull request
Aug 3, 2026
…ible (#159) Review of #158 found main shipped red: `tsc --noEmit` failed with two errors and two unit tests were failing. Fixed those, plus the defects behind them. **main was broken.** - `SqlBinding = ReturnType<typeof makeSqlBinding>` on a function annotated `: SqlBinding` is circular; TS2456 + TS2577. Dropped the annotation and let it infer — the alias still serves consumers. - `server-beam.test.ts` expected /at most 2/ while the message said "cant handle more than 2". Aligned the message (and its missing apostrophe). - `codeCellExec.test.ts` still asserted the OLD contract: #158 deliberately widened normalizeCodeCellReturn so `return 1` / `return [1,2,3]` / a bare object become grids. Updated the assertions to the new behaviour rather than narrowing the feature — only a missing return is rejected now. **Alias lookup accepted inherited keys.** `!beamDialects[key]` let `toString`, `constructor`, `valueOf` and `__proto__` past the unknown-alias check, then used the inherited *function* as the dialect — surfacing as "dialect .toLowerCase is not a function" instead of "Unknown Server Beam alias". Now `Object.hasOwn`. Not exploitable (the parent routes through a Map and fails closed) but a confusing dead end. Third time this class has appeared in this codebase — a shared hasOwn helper or lint rule would be cheaper than a fourth. **Which server is `target` was invisible.** Aliases come from list order, not click order, and `sql.on('target')` is what writes — so a wrong assumption writes to the wrong database. Two changes: a third checked Destination is now an error instead of a silent `slice(0, 2)`, and every beam run prints the resolved mapping ("Server Beam → source = A, target = B") before results. **Samples for both editor cases**, each executed against real SQLite before committing: - general, one server, no alias — plain sql`…`, no beam. - migration, source → target — read, reshape, chunked write, read back. Verified across two separate database files: rows landed in target, and the source was confirmed untouched. Writing the migration sample caught a bug in the sample itself: `domain` was split from the pre-lowercased email, yielding "Example.COM" beside "o'brien@example.com". Normalize once, then derive. 801 tests pass, tsc and eslint clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Server Beam lets a
-- @nodecell move data between databases withsql.on('source')/sql.on('target')(async / Promises).Behavior
MAX_SERVERSsql.on()calls per editor Execute —MAX_SQLresolveRefExamples (Bookmarks → Add samples)
★ Sample · Server Beam ping (source + target)★ Sample · Server Beam copy rows source → target★ Sample · Server Beam chunked pull → pushDocs
docs/plans/server-beam.mdHow to try