feat: 聚合管道可视化构建器#9
Merged
Merged
Conversation
- 编辑器右侧可折叠面板:分阶段搭 pipeline,每 stage = 类型下拉 + 带字段补全的 CodeMirror 小编辑器(stageCompletion 复用聚合操作符 + 采样字段) - 逐阶段预览:点 ▶ 跑前 N 个 enabled stage,就地展示样本+计数;非法 body 归因到该卡片飘红 - 拖拽排序 / 启用开关 / 增删;「应用到编辑器」生成 db.coll.aggregate([...]) 经 applyQuery 回填 - 状态挂 QueryTab.pipeline(轻量文本,随 tab 持久),预览结果瞬态(pipelinePreviews 不持久) - 纯逻辑 lib/pipelineBuilder.ts(文本拼接保留 ObjectId(...) 等构造器)+ 11 单测 - 抽 useIsDark 共享给两个编辑器;无新依赖(原生 HTML5 DnD) 校验:typecheck 干净、311 单测、生产构建通过、面板/卡片视觉用独立预览截图核对。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- 🔴 安全:$out/$merge 阶段「预览」会静默写库(limit 只约束客户端游标, 约束不了服务端写入)。buildPreviewCode 剥离写阶段(纵深防御), StageCard 对写阶段禁用 ▶ 预览并给出提示 - 🟡 pipelinePreviews 永不清理:删除 stage / 关闭 tab 时剔除对应预览条目 - 预览 in-flight 时禁用 ▶ 防重复发请求 - 预览计数文案改「样本/Sample」,避免被误读为该阶段总输出条数 - 补 1 个单测:预览代码绝不含 $out/$merge,而 apply 代码保留 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- 自动加载目标集合:面板打开即 loadCollections,撞到未在侧栏展开过的库时
下拉不再为空;采到后默认选首个集合
- 撞名集合名走 getCollection:db.admin / db.collection / db.aggregate 等会被
shell proxy 解析成方法而非集合,dbCollRef 对 Db 成员denylist 改用 getCollection("…")
- 陈旧预览失效:改 stage body/op、启用、移动、删除、换集合时清掉该 stage 及
下游(或全部)的预览,不再显示过期样本
- Apply 落当前 tab:applyPipeline 直接 patch 本 tab code(不再走 applyQuery
的避让路径开新 tab、隐藏构建器、重复点击刷一堆 tab)
- 补单测:撞名集合名生成 getCollection("…")
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
背景
backlog #12,被标「大件、需单独立项」——NoSQLBooster 招牌功能。原先用户只能手敲整段
db.coll.aggregate([...]),看不到中间变换。本 PR 在 Shell 工作区编辑器右侧加一个可折叠管道构建器面板(已与用户敲定 v1 范围)。功能
$match/$group/$project/… 18 个常用算子)+ 一个带字段补全的 CodeMirror 小编辑器(stageCompletion复用聚合算子词表 + 采样字段名)。db.<coll>.aggregate([...])经现有applyQuery填充范式回填(不覆盖用户代码、不自动跑)。架构
QueryTab.pipeline(轻量文本,随 tab 持久);预览结果瞬态存pipelinePreviews(不进 tab、不持久 — ADR-0004 chore: 升级 electron-vite 5 + vite 7 + vitest 4 #6)。全部patchTab不可变更新。shell:execute(构造前缀 pipeline,不加.toArray()→ shell 引擎自动有界分页),无新 IPC 通道。useIsDark共享给主编辑器与 stage 编辑器;mongoCompletion的算子词表导出给stageCompletion复用。验证
pnpm typecheck干净;pnpm test:unit311 通过(+11 pipelineBuilder 纯逻辑:CRUD/排序/代码拼接精确格式/构造器保真;i18n 三语键齐全)pnpm build生产构建通过(含新 lazy 编辑器分块)pnpm dev连库手测一遍:开面板 → 选集合 → 搭 3-4 stage → 逐阶段预览 → 应用到编辑器 → Run 比对。🤖 Generated with Claude Code