feat(cli): 参数别名收尾 + 全命令冒烟套件 (0.1.6)

- field list/get、view list、preset list 接受 --table-id(位置参数之外)
- record get/list 接受 --take/--skip 别名(= --page-size/--page 的原始偏移)
- scripts/smoke-commands.sh: 全命令冒烟套件,一次性验证所有 CLI 命令
  无幻影路由/无 CLI 语法错/无 CLI 请求形状错(80/80 通过,含 8 种触发器、
  preset/secret/subscription/plugin 只读命令)
- 轨迹依据: iteration-4 中 agent 猜 --table-id/--take 被拒,别名后归零
This commit is contained in:
yeuimu
2026-09-30 03:59:39 +00:00
parent 8dacbf7f2d
commit e584b7ebbe
4 changed files with 219 additions and 16 deletions
+35 -13
View File
@@ -236,16 +236,18 @@ function fieldCmd(): Command {
cmd.description('Manage fields (columns) in a table');
cmd
.command('list <tableId>')
.command('list [tableId]')
.description('List fields in a table')
.option('--table-id <id>', 'Table id (alternative to the positional argument)')
.option(
'--with-options',
'Add an OPTIONS summary column and expand select choices with their visibility conditions'
)
.action(
run(async (ctx, args, o) => {
const opts = o as { withOptions?: boolean };
const tableId = args[0] as string;
const opts = o as { withOptions?: boolean; tableId?: string };
const tableId = opts.tableId || (args[0] as string);
if (!tableId) throw new Error('Pass a tableId (positional or --table-id)');
const list = (await ctx.client.listFields(tableId)) as Array<Record<string, unknown>>;
if (ctx.json) printJson(list);
else {
@@ -305,13 +307,23 @@ function fieldCmd(): Command {
);
cmd
.command('get <tableId> <fieldIdOrName>')
.command('get [tableId] [fieldIdOrName]')
.description(
'Get field details by id or name (full options; select choices rendered with visibility conditions)'
)
.option('--table-id <id>', 'Table id (alternative to the positional argument)')
.action(
run(async (ctx, args) => {
const [tableId, fieldIdOrName] = args as [string, string];
run(async (ctx, args, o) => {
const opts = o as { tableId?: string };
let tableId = opts.tableId || (args[0] as string);
let fieldIdOrName = args[1] as string;
// `field get <fieldIdOrName> --table-id X` — one positional + flag
if (!fieldIdOrName) {
fieldIdOrName = args[0] as string;
tableId = opts.tableId || '';
}
if (!tableId || !fieldIdOrName)
throw new Error('Usage: field get <tableId> <fieldIdOrName> (or --table-id <id> <fieldIdOrName>)');
const field = await getFieldFlexible(ctx.client, tableId, fieldIdOrName);
if (ctx.json) printJson(field);
else {
@@ -478,7 +490,9 @@ function recordCmd(): Command {
.option('--filter <json>', 'Filter conditions JSON')
.option('--projection <json>', 'Field projection JSON array')
.option('--page-size <n>', 'Records per page')
.option('--take <n>', 'Alias of --page-size')
.option('--page <n>', 'Page number (1-based)')
.option('--skip <n>', 'Records to skip (raw offset; overrides --page)')
.option('--search <kw>', 'Search keyword')
.option('--base-id <id>', 'Base id (overrides default)')
.action(
@@ -488,7 +502,9 @@ function recordCmd(): Command {
filter?: string;
projection?: string;
pageSize?: string;
take?: string;
page?: string;
skip?: string;
search?: string;
baseId?: string;
recordId?: string;
@@ -512,9 +528,12 @@ function recordCmd(): Command {
if (opts.search) query.search = opts.search;
const page = opts.page ? parseInt(opts.page, 10) : undefined;
const pageSize = opts.pageSize ? parseInt(opts.pageSize, 10) : undefined;
const pageSize = opts.pageSize || opts.take
? parseInt((opts.pageSize || opts.take) as string, 10)
: undefined;
if (pageSize) query.take = pageSize;
if (page) {
if (opts.skip) query.skip = parseInt(opts.skip, 10);
else if (page) {
const take = pageSize || 100;
query.skip = (page - 1) * take;
if (!pageSize) query.take = take;
@@ -664,11 +683,13 @@ function viewCmd(): Command {
cmd.description('Manage views in a table');
cmd
.command('list <tableId>')
.command('list [tableId]')
.description('List views in a table')
.option('--table-id <id>', 'Table id (alternative to the positional argument)')
.action(
run(async (ctx, args) => {
const tableId = args[0] as string;
run(async (ctx, args, o) => {
const tableId = ((o as { tableId?: string }).tableId || args[0]) as string;
if (!tableId) throw new Error('Pass a tableId (positional or --table-id)');
const list = (await ctx.client.listViews(tableId)) as Array<Record<string, unknown>>;
if (ctx.json) printJson(list);
else {
@@ -832,12 +853,13 @@ function presetCmd(): Command {
);
cmd
.command('list <tableId>')
.command('list [tableId]')
.description('List view presets of a table (pass --view-id to scope to one view)')
.option('--table-id <id>', 'Table id (alternative to the positional argument)')
.option('--view-id <id>', 'Only presets bound to this view')
.action(
run(async (ctx, args, o) => {
const tableId = args[0] as string;
const tableId = ((o as { tableId?: string }).tableId || args[0]) as string;
const opts = o as unknown as IPresetOptions;
const list = (await ctx.client.listViewPresets(tableId, opts.viewId)) as Array<
Record<string, unknown>