Support nested folders in `config/queries/` for query organization

未关闭
#218 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
sql, typescript
领域
backend, tooling

调研方向

先阅读 plugins/server/utils.js 中的 AppManager.getAppQuery()、getQueries(),以及 typegen 中的 generateQueriesFromDescribe(),然后检查它们对 flat readdir 和 path.basename 的处理。完成的标准是:嵌套的 .sql 文件能够解析为稳定的相对 query key,验证接受所选的 separator,并且类型生成和前端查找覆盖文档中的示例。

由索引模型根据 Issue 内容生成。

描述

Support nested folders in config/queries/ for query organization

Problem

As the number of SQL queries in a project grows, config/queries/ becomes a flat bag of files with no way to organize them by feature or domain. The only option is naming conventions (e.g. nego_chart_data.sql, trip_summary.sql), which doesn't scale well and provides no structural separation.

Current behavior

  • AppManager hardcodes queriesDir to path.resolve(process.cwd(), "config/queries")
  • fs.readdir() is non-recursive — subdirectories are silently ignored
  • Query key validation (/^[a-zA-Z0-9_-]+$/) rejects any delimiter that could encode a path
  • generate-types (typegen) also uses flat readdir + path.basename

Proposed behavior

Allow queries to live in subdirectories:

config/queries/
  negotiations/
    chart_data.sql
    spend_summary.sql
  dashboard/
    trip_summary.sql
    trips_by_day.sql
  docs/
    annotations.obo.sql

Query key derivation would use the relative path with a separator (e.g. / or .):

  • negotiations/chart_data or negotiations.chart_data

Frontend usage:

useAnalyticsQuery('negotiations/chart_data', params)

Minimal change required

The fix is small — roughly 3-4 locations need updating:

  1. AppManager.getAppQuery() — change fs.readdir() to fs.readdir(dir, { recursive: true }) and adjust filename matching to include relative subdirectory paths
  2. getQueries() in plugins/server/utils.js — same recursive readdir change
  3. generateQueriesFromDescribe() in typegen — derive query names from relative paths instead of just path.basename()
  4. Query key validation regex — allow / or . as a path separator

Workarounds

Currently using prefix naming (nego_*, trip_*) which works but doesn't provide IDE folder navigation or structural grouping benefits.

主要语言
TypeScript
星标
119
派生
36
平均合并
4 天 16 小时
30 天内合并 PR
37

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

databricks/appkit 的其他 Issue

查看 databricks/appkit 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。