Skip to content
dsh-invest 文档
Esc
↑↓navigate↵open⌘Jpreview
On this page

扩展点

provider、图表、页面、测试与发布的扩展点总览。

插件页:投资工作台的组件与偏好。

插件页:投资工作台的组件与偏好。

目标

先有 manifest,才有切面。按这条线往下做:catalog / history 是行情,snapshot / detail 是资料,stream 是实时,execution 是交易;lake 是本地回填,图表与页面是展示面,最后测试与发布。

你要做的 入口 页面
接一个行情 / 交易源 ctx.invest.provideVenue(s) 接入 provider
目录与 K 线 catalog / history 切面 provider/catalog-history
快照与标的详情 snapshot / detail 切面 provider/snapshot-detail
实时推送 stream 切面 provider/streams
下单与账户 execution 切面 provider/execution
落盘与回填 lake 切面 provider/lake
图表 provider / 周期表 ctx.invest.charts 图表接缝
页面 / tab 注入 ctx.invest.nav、席位 页面与 tab
一致性测试 dsh-invest/testing testing
发布 latest / next dist-tag publishing

要改哪些文件

src/index.ts              host 半:apply / provideVenue(s) / 动作
src/client/index.ts       浏览器半:ctx.invest.charts、nav、席位
src/shared/manifest.ts    venue manifest(身份 + 切面)
src/shared/descriptor.ts  id / label / origin 等字面量只留一份
cordis.patch.yml          insert 一行;id/name 都是包名
tests/                    describeVenue + 假端口的行为用例

只做 host 数据面时可以没有浏览器半;只做图表周期表时可以没有 host 数据面。

契约

两条先记住的边界:

  1. provider 不 value-import 核心(dsh-invest/identity 是唯一值例外)。两份核心会各持一份注册表,症状是「注册成功但界面没有」。
  2. 出站只走宿主给的端口(EgressPort / ExecutorScope.egress / ports.fetchJson)。自己 fetch 会绕过代理、缓存、限流与审计。

注册一律挂在 ctx.effect 的 disposer 上;HMR 后第二次激活不能抛 already registered。

完整的字段与路由表在 VenueManifest 字段、数据源、动作、HTTP 路由 与 配置。

失败与重试

  • 服务没到:用 ctx.inject(deps, cb),不要静态 inject 等一个可选服务。
  • 能力缺失:用 invest.features.includes(...) 探测,缺了只少一个功能,不要抛。
  • 注册失败:manifest 形状错误是作者错误,记一条可检索的日志并让这个源缺席;provideVenues 已经整批回滚。
  • 重复注册:同 id 会被拒绝;注册前先确定稳定 id,不要按会话拼。

验证

pnpm --filter dsh-invest-provider-demo run check:all

预期依次跑 build / typecheck / verify / verify:plugin / test,退出码 0。

装进 profile 后重启,读一次注册结果:

curl -s http://127.0.0.1:<port>/dsh-invest/health | jq '.invest'

预期 venues 与对应切面计数都增加;没有增加说明插件没加载或注册被拒。

Was this page helpful?