Skip to content

dab auto-config

在配置文件中创建或更新 autoentities 定义。通过基于模式的规则,在启动时自动将匹配的数据库对象公开为实体。配套的 auto-config-simulate 命令在不修改配置文件的前提下预览匹配结果。

IMPORTANT

autoentities 当前仅支持 MSSQL(SQL Server)数据源。

auto-config 语法

bash
dab auto-config <definition-name> [options]

auto-config 选项

模式选项

选项说明默认值
--patterns.include包含数据库对象的 T-SQL LIKE 模式["%.%"]
--patterns.exclude排除模式
--patterns.name实体命名模板,支持 {schema}{object}"{schema}_{object}"

权限

选项说明
--permissions默认权限,格式 "role:actions"

模板选项

选项说明默认值
--template.rest.enabled匹配实体是否启用 RESTtrue
--template.graphql.enabled匹配实体是否启用 GraphQLtrue
--template.mcp.dml-tools匹配实体是否启用 MCP DML 工具true
--template.health.enabled匹配实体是否启用健康检查true
--template.cache.enabled匹配实体是否启用缓存false
--template.cache.ttl-seconds缓存 TTL(秒)
--template.cache.level缓存级别:L1 / L1L2L1L2

auto-config 示例

bash
dab auto-config public-tables \
  --patterns.include "dbo.public_%" \
  --patterns.exclude "dbo.public_internal_%" \
  --patterns.name "{schema}_{object}" \
  --template.rest.enabled true \
  --template.graphql.enabled true \
  --template.cache.enabled true \
  --template.cache.ttl-seconds 30 \
  --permissions "anonymous:read"

auto-config-simulate 语法

bash
dab auto-config-simulate [options]

auto-config-simulate 选项

选项说明
-c, --config配置文件路径
-o, --output输出 CSV 文件路径;省略则打印到控制台
--autoentities.include覆盖配置中的 include 模式
--autoentities.exclude覆盖配置中的 exclude 模式
--autoentities.name覆盖配置中的命名模板
--csv-output以 CSV 格式输出匹配结果

CSV 输出列包括:

列名说明
filter_name匹配的 autoentities 定义名
entity_name生成的实体名称
database_object匹配的数据库对象全名

auto-config-simulate 示例

控制台预览

bash
dab auto-config-simulate

CSV 输出

bash
dab auto-config-simulate --output results.csv

覆盖模式预览

bash
dab auto-config-simulate \
  --autoentities.include "dbo.api_%" \
  --autoentities.name "{object}"

生成的配置

json
{
  "autoentities": {
    "public-tables": {
      "patterns": {
        "include": ["dbo.public_%"],
        "exclude": ["dbo.public_internal_%"],
        "name": "{schema}_{object}"
      },
      "template": {
        "rest": { "enabled": true },
        "graphql": { "enabled": true },
        "cache": { "enabled": true, "ttl-seconds": 30, "level": "L1L2" }
      },
      "permissions": [
        { "role": "anonymous", "actions": ["read"] }
      ]
    }
  }
}

下一步

数据墙DBW 产品文档与开发指南。