@effiprint-nomi/auto-nomi-cli
v0.3.3
Published
Auto Nomi Developer API command-line tool
Downloads
435
Readme
@effiprint-nomi/auto-nomi-cli
Auto Nomi Developer API 命令行工具。Node.js 版本要求为 20 或更高。
npm config set @effiprint-nomi:registry https://registry.npmjs.org/
npm install -g @effiprint-nomi/auto-nomi-cli
auto-nomi auth login \
--web-url https://wh.indexcb.com/developer-api \
--profile prod
auto-nomi auth whoami --profile prod
auto-nomi auth logout --profile prod@effiprint-nomi 的包使用 npm 官方 registry。若安装日志访问
cdn.npmmirror.com 并返回 404,说明镜像尚未同步;上述 scope 配置只影响
@effiprint-nomi,不会改变其他 npm 包使用的 registry。
登录命令会在终端显示 8 位 JCode 并打开浏览器。浏览器 URL 只包含 session ID;开发人员使用 Auto Nomi 独立账号登录后,手动输入终端中的 JCode。新用户先在该页面使用管理员生成的邀请码注册。
如果当前终端不适合持续等待:
auto-nomi auth login \
--web-url https://wh.indexcb.com/developer-api \
--profile prod \
--no-wait
auto-nomi auth login finish --profile prod查询开放数据表
查询能力只访问管理员已全局启用并分配给当前账号的安全资源。CLI 支持本地受限 SQL, 但不会把原始 SQL 发送给服务端或数据库。查看当前开放资源:
auto-nomi tables list --profile prod
auto-nomi tables describe sla_node_status --profile prod按允许字段执行简单等值过滤:
auto-nomi tables query sla_node_status \
--where entity_type=workorder \
--where entity_id=EF260817000001 \
--limit 20 \
--profile prod响应中的 has_more=true 时,将 next_before_id 传入下一页:
auto-nomi tables query sla_node_status \
--before-id 12345 \
--limit 20 \
--profile prod复杂查询写入 JSON 文件,例如 sla-query.json:
{
"select": ["id", "entity_type", "entity_id", "sla_status", "started_at"],
"where": {
"and": [
{"field": "entity_type", "op": "in", "value": ["order", "workorder"]},
{
"or": [
{"field": "sla_status", "op": "in", "value": [1, 2]},
{"field": "started_at", "op": "between", "value": [1785513600, 1788191999]}
]
}
]
},
"limit": 50
}auto-nomi tables query sla_node_status \
--query-file ./sla-query.json \
--profile prod--query-file 不能与 --where、--limit 或 --before-id 混用。查询树最多嵌套
3 层、最多 20 个条件,单个 in 最多 100 个值;选择字段时必须包含 id,用于稳定
分页。具体字段允许的操作符以 tables describe 返回结果为准。
单次最多返回 100 行,固定按 id DESC 排序。管理员可以从独立查询账号已获得列级
SELECT 的安全目录中勾选全局资源,再按邀请码或账号分配;CLI 不能自行扩大权限。
CLI 0.3.3 起自动使用 node --tls-max-v1.2 启动实际命令,以兼容当前
wh.indexcb.com CDN 在部分 Node.js 机器上的 TLS 握手行为;使用者不需要设置
NODE_OPTIONS=--tls-max-v1.2。证书校验保持开启。
使用受限 SQL 查询
日常查询推荐使用 SQL 入口:
auto-nomi sql \
"SELECT id, entity_id, sla_status FROM sla_node_status WHERE sla_status IN (1, 2) AND id > 100 ORDER BY id DESC LIMIT 20" \
--profile prod多行查询可以保存为 query.sql:
SELECT id, entity_type, entity_id, sla_status
FROM sla_node_status
WHERE entity_type = 'workorder'
AND (sla_status IN (1, 2) OR completed_at IS NULL)
ORDER BY id DESC
LIMIT 20;auto-nomi sql --file ./query.sql --profile prod也可以通过标准输入传入:
printf '%s\n' "SELECT * FROM sla_node_status LIMIT 20" |
auto-nomi sql --profile prod当前支持 SELECT、单表 FROM、括号、AND、OR、=、!=、<>、>、
>=、<、<=、IN、BETWEEN、IS NULL、ORDER BY id DESC 和 1 至 100
的 LIMIT。显式选择字段时必须包含 id;SELECT * 只返回服务端允许的字段。
不支持多语句、注释、别名、JOIN、子查询、函数、聚合、OFFSET、写入语句或数据库
管理语句。SQL 会在本地转换成现有结构化查询协议,最终表、字段、操作符和账号权限仍由
Developer API 校验。
