siluzan-tso-cli 1.0.0-beta.30 → 1.0.0-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ siluzan-tso init -d /path/to/skills # 写入自定义目录
20
20
  siluzan-tso init --force # 强制覆盖已存在文件
21
21
  ```
22
22
 
23
- > **注意**:当前为测试版(1.0.0-beta.30),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-tso-cli`。
23
+ > **注意**:当前为测试版(1.0.0-beta.31),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-tso-cli`。
24
24
 
25
25
  | 助手 | 建议 `--ai` |
26
26
  |------|-------------|
package/dist/index.js CHANGED
@@ -1218,6 +1218,18 @@ async function runUpdate(options) {
1218
1218
  console.log(" \u5982\u679C AI \u52A9\u624B\u6B63\u5728\u8FD0\u884C\uFF0C\u5EFA\u8BAE\u91CD\u542F\u4EE5\u4F7F\u65B0 Skill \u6587\u4EF6\u751F\u6548\u3002\n");
1219
1219
  }
1220
1220
 
1221
+ // src/utils/list-json-envelope.ts
1222
+ function wrapListJson(params) {
1223
+ const itemCount = Array.isArray(params.items) ? params.items.length : 0;
1224
+ return {
1225
+ page: params.page,
1226
+ pageSize: params.pageSize,
1227
+ total: params.total === void 0 || params.total === null ? null : params.total,
1228
+ itemCount,
1229
+ items: params.items
1230
+ };
1231
+ }
1232
+
1221
1233
  // src/utils/cli-table.ts
1222
1234
  import Table from "cli-table3";
1223
1235
  var ASCII_TABLE_CHARS = {
@@ -1611,17 +1623,28 @@ async function runListAccounts(opts) {
1611
1623
  }
1612
1624
  }
1613
1625
  if (opts.json) {
1614
- console.log(JSON.stringify(items, null, 2));
1615
- return;
1616
- }
1617
- if (items.length === 0) {
1618
- console.log("\n\u6682\u65E0\u5E7F\u544A\u8D26\u6237\u6570\u636E\u3002\n");
1626
+ console.log(
1627
+ JSON.stringify(
1628
+ wrapListJson({
1629
+ page,
1630
+ pageSize,
1631
+ total: total ?? null,
1632
+ items
1633
+ }),
1634
+ null,
1635
+ 2
1636
+ )
1637
+ );
1619
1638
  return;
1620
1639
  }
1621
1640
  const totalInfo = total !== void 0 ? `\uFF0C\u5171 ${total} \u6761` : "";
1622
1641
  console.log(`
1623
1642
  \u5E7F\u544A\u8D26\u6237\u5217\u8868\uFF08\u7B2C ${page} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761${totalInfo}\uFF09
1624
1643
  `);
1644
+ if (items.length === 0) {
1645
+ console.log("\u6682\u65E0\u5E7F\u544A\u8D26\u6237\u6570\u636E\u3002\n");
1646
+ return;
1647
+ }
1625
1648
  const isGoogle = opts.media === "Google";
1626
1649
  const isYandex = opts.media === "Yandex";
1627
1650
  const isTikTok = opts.media === "TikTok";
@@ -1989,26 +2012,30 @@ async function runBalance(opts) {
1989
2012
  `);
1990
2013
  process.exit(1);
1991
2014
  }
2015
+ const out = accountIds.map((id) => {
2016
+ const info = balanceMap.get(id);
2017
+ return {
2018
+ mediaCustomerId: id,
2019
+ remainingAccountBudget: info?.remainingAccountBudget ?? null,
2020
+ status: info?.status ?? null,
2021
+ currencyCode: info?.currencyCode ?? null,
2022
+ name: info?.name ?? null
2023
+ };
2024
+ });
1992
2025
  if (opts.json) {
1993
- const out = accountIds.map((id) => {
1994
- const info = balanceMap.get(id);
1995
- return {
1996
- mediaCustomerId: id,
1997
- remainingAccountBudget: info?.remainingAccountBudget ?? null,
1998
- status: info?.status ?? null,
1999
- currencyCode: info?.currencyCode ?? null,
2000
- name: info?.name ?? null
2001
- };
2002
- });
2003
- console.log(JSON.stringify(out, null, 2));
2026
+ const n = out.length;
2027
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items: out }), null, 2));
2004
2028
  return;
2005
2029
  }
2006
2030
  if (balanceMap.size === 0) {
2007
- console.log("\n\u672A\u8FD4\u56DE\u4F59\u989D\u6570\u636E\uFF0C\u8BF7\u786E\u8BA4\u8D26\u6237 ID \u662F\u5426\u6B63\u786E\u4E14\u8D26\u6237\u72B6\u6001\u6709\u6548\u3002\n");
2031
+ console.log(`
2032
+ ${media} \u8D26\u6237\u4F59\u989D\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 0 \u6761\uFF0C\u5171 0 \u6761\uFF09
2033
+ `);
2034
+ console.log("\u672A\u8FD4\u56DE\u4F59\u989D\u6570\u636E\uFF0C\u8BF7\u786E\u8BA4\u8D26\u6237 ID \u662F\u5426\u6B63\u786E\u4E14\u8D26\u6237\u72B6\u6001\u6709\u6548\u3002\n");
2008
2035
  return;
2009
2036
  }
2010
2037
  console.log(`
2011
- ${media} \u8D26\u6237\u4F59\u989D
2038
+ ${media} \u8D26\u6237\u4F59\u989D\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${out.length} \u6761\uFF0C\u5171 ${out.length} \u6761\uFF09
2012
2039
  `);
2013
2040
  const cols = [
2014
2041
  { key: "id", header: "\u8D26\u6237ID" },
@@ -2084,17 +2111,20 @@ async function runStats(opts) {
2084
2111
  }
2085
2112
  const items = Array.isArray(raw) ? raw : raw.items ?? [];
2086
2113
  if (opts.json) {
2087
- console.log(JSON.stringify(items, null, 2));
2114
+ const n = items.length;
2115
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items }), null, 2));
2088
2116
  return;
2089
2117
  }
2118
+ const rangeLabel = `${startDate} ~ ${endDate}`;
2090
2119
  if (items.length === 0) {
2091
2120
  console.log(`
2092
- ${opts.media} \u5728 ${startDate} ~ ${endDate} \u65E0\u6295\u653E\u6570\u636E\u3002
2121
+ ${opts.media} \u6295\u653E\u6570\u636E\uFF08${rangeLabel}\uFF09\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 0 \u6761\uFF0C\u5171 0 \u6761\uFF09
2093
2122
  `);
2123
+ console.log("\u65E0\u6295\u653E\u6570\u636E\u3002\n");
2094
2124
  return;
2095
2125
  }
2096
2126
  console.log(`
2097
- ${opts.media} \u6295\u653E\u6570\u636E\uFF08${startDate} ~ ${endDate}\uFF09
2127
+ ${opts.media} \u6295\u653E\u6570\u636E\uFF08${rangeLabel}\uFF09\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${items.length} \u6761\uFF09
2098
2128
  `);
2099
2129
  const cols = [
2100
2130
  { key: "id", header: "\u8D26\u6237ID" },
@@ -2162,27 +2192,43 @@ async function runAccountHistory(opts) {
2162
2192
  params.set("mediaAccountState", opts.status ?? historyStates);
2163
2193
  const url = `${config.apiBaseUrl}/query/media-account/?${params}`;
2164
2194
  let items;
2195
+ let total;
2165
2196
  try {
2166
- items = await apiFetch2(url, config, {}, opts.verbose);
2197
+ const res = await apiFetchWithHeaders2(url, config, {}, opts.verbose);
2198
+ items = res.data ?? [];
2199
+ const hit = res.headers["s-total-hits"];
2200
+ if (hit !== void 0) total = parseInt(hit, 10) || void 0;
2167
2201
  } catch (err) {
2168
2202
  console.error(`
2169
2203
  \u274C \u67E5\u8BE2\u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}
2170
2204
  `);
2171
2205
  process.exit(1);
2172
2206
  }
2207
+ const page = opts.page ?? 1;
2208
+ const pageSize = opts.pageSize ?? 20;
2173
2209
  if (opts.json) {
2174
- console.log(JSON.stringify(items, null, 2));
2210
+ console.log(
2211
+ JSON.stringify(
2212
+ wrapListJson({
2213
+ page,
2214
+ pageSize,
2215
+ total: total ?? null,
2216
+ items
2217
+ }),
2218
+ null,
2219
+ 2
2220
+ )
2221
+ );
2175
2222
  return;
2176
2223
  }
2224
+ const totalInfo = total !== void 0 ? `\uFF0C\u5171 ${total} \u6761` : "";
2225
+ console.log(`
2226
+ \u5F00\u6237\u7533\u8BF7\u5386\u53F2\uFF08\u7B2C ${page} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761${totalInfo}\uFF09
2227
+ `);
2177
2228
  if (items.length === 0) {
2178
- console.log("\n\u6682\u65E0\u5F00\u6237\u7533\u8BF7\u8BB0\u5F55\u3002\n");
2229
+ console.log("\u6682\u65E0\u5F00\u6237\u7533\u8BF7\u8BB0\u5F55\u3002\n");
2179
2230
  return;
2180
2231
  }
2181
- const page = opts.page ?? 1;
2182
- const pageSize = opts.pageSize ?? 20;
2183
- console.log(`
2184
- \u5F00\u6237\u7533\u8BF7\u5386\u53F2\uFF08\u7B2C ${page} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF09
2185
- `);
2186
2232
  const rows = items.map((item) => ({
2187
2233
  mediaType: item.ma.mediaAccountType ?? "",
2188
2234
  mediaCustomerId: item.ma.mediaCustomerId ?? "(\u672A\u5F00\u901A)",
@@ -2198,7 +2244,8 @@ async function runAccountHistory(opts) {
2198
2244
  { key: "createdAt", header: "\u521B\u5EFA\u65E5\u671F" }
2199
2245
  ];
2200
2246
  printCliTable(rows, cols);
2201
- if (items.length >= pageSize) {
2247
+ const hasMore = total !== void 0 ? page * pageSize < total : items.length >= pageSize;
2248
+ if (hasMore) {
2202
2249
  console.log(`
2203
2250
  \u4F7F\u7528 --page <n> \u7FFB\u9875\uFF0C--page-size <n> \u8C03\u6574\u6BCF\u9875\u6570\u91CF\u3002`);
2204
2251
  }
@@ -2245,14 +2292,14 @@ async function runReportList(opts) {
2245
2292
  ...item,
2246
2293
  viewUrl: item.reportReady ? `${webUrl}/media-report/${pathByType[item.reportType ?? ""] ?? "publish"}/${item.entityId}?culture=zh-CN` : ""
2247
2294
  }));
2295
+ const page = opts.page ?? 1;
2296
+ const pageSize = opts.pageSize ?? 20;
2248
2297
  if (opts.json) {
2249
- console.log(JSON.stringify({ ...data, results: itemsWithUrl }, null, 2));
2298
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items: itemsWithUrl }), null, 2));
2250
2299
  return;
2251
2300
  }
2252
- const page = opts.page ?? 1;
2253
- const pageSize = opts.pageSize ?? 20;
2254
2301
  console.log(`
2255
- \u4F18\u5316\u62A5\u544A\u5217\u8868\uFF08\u7B2C ${page}/${Math.ceil(total / pageSize)} \u9875\uFF0C\u5171 ${total} \u6761\uFF09
2302
+ \u4F18\u5316\u62A5\u544A\u5217\u8868\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
2256
2303
  `);
2257
2304
  if (items.length === 0) {
2258
2305
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -2489,15 +2536,19 @@ async function runReportPushList(opts) {
2489
2536
  `);
2490
2537
  process.exit(1);
2491
2538
  }
2539
+ const items = data.results ?? [];
2540
+ const total = data.totalResultCount ?? 0;
2541
+ const page = opts.page ?? 1;
2542
+ const pageSize = opts.pageSize ?? 20;
2492
2543
  if (opts.json) {
2493
- console.log(JSON.stringify(data, null, 2));
2544
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
2494
2545
  return;
2495
2546
  }
2496
- const items = data.results ?? [];
2497
- const total = data.totalResultCount ?? 0;
2498
- console.log(`
2499
- \u63A8\u9001\u7BA1\u7406\u5217\u8868\uFF08\u5171 ${total} \u6761\uFF09
2500
- `);
2547
+ console.log(
2548
+ `
2549
+ \u63A8\u9001\u7BA1\u7406\u5217\u8868\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
2550
+ `
2551
+ );
2501
2552
  if (items.length === 0) {
2502
2553
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
2503
2554
  return;
@@ -3629,16 +3680,16 @@ async function runTransferList(opts) {
3629
3680
  `);
3630
3681
  process.exit(1);
3631
3682
  }
3632
- if (opts.json) {
3633
- console.log(JSON.stringify(data, null, 2));
3634
- return;
3635
- }
3636
3683
  const items = data.list ?? data.results ?? [];
3637
3684
  const total = data.total ?? data.totalResultCount ?? 0;
3638
3685
  const page = opts.page ?? 1;
3639
3686
  const pageSize = opts.pageSize ?? 20;
3687
+ if (opts.json) {
3688
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
3689
+ return;
3690
+ }
3640
3691
  console.log(`
3641
- \u8F6C\u8D26\u8BB0\u5F55\uFF08\u7B2C ${page}/${Math.ceil(total / pageSize)} \u9875\uFF0C\u5171 ${total} \u6761\uFF09
3692
+ \u8F6C\u8D26\u8BB0\u5F55\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
3642
3693
  `);
3643
3694
  if (items.length === 0) {
3644
3695
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -3720,16 +3771,16 @@ async function runInvoiceList(opts) {
3720
3771
  `);
3721
3772
  process.exit(1);
3722
3773
  }
3723
- if (opts.json) {
3724
- console.log(JSON.stringify(data, null, 2));
3725
- return;
3726
- }
3727
3774
  const items = data.results ?? [];
3728
3775
  const total = data.totalResultCount ?? 0;
3729
3776
  const page = opts.page ?? 1;
3730
3777
  const pageSize = opts.pageSize ?? 20;
3778
+ if (opts.json) {
3779
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
3780
+ return;
3781
+ }
3731
3782
  console.log(`
3732
- \u5F00\u7968\u8BB0\u5F55\uFF08\u7B2C ${page}/${Math.ceil(total / pageSize)} \u9875\uFF0C\u5171 ${total} \u6761\uFF09
3783
+ \u5F00\u7968\u8BB0\u5F55\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
3733
3784
  `);
3734
3785
  if (items.length === 0) {
3735
3786
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -3853,17 +3904,17 @@ async function runInvoiceBillable(opts) {
3853
3904
  `);
3854
3905
  process.exit(1);
3855
3906
  }
3856
- if (opts.json) {
3857
- console.log(JSON.stringify(data, null, 2));
3858
- return;
3859
- }
3860
3907
  const items = data.results ?? [];
3861
3908
  const total = data.totalResultCount ?? 0;
3862
3909
  const page = opts.page ?? 1;
3863
3910
  const pageSize = opts.pageSize ?? 20;
3911
+ if (opts.json) {
3912
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
3913
+ return;
3914
+ }
3864
3915
  const label = opts.wallet ? "\u94B1\u5305\u53EF\u5F00\u7968\u8BB0\u5F55" : "\u5145\u503C\u53EF\u5F00\u7968\u8BA2\u5355";
3865
3916
  console.log(`
3866
- ${label}\uFF08\u7B2C ${page}/${Math.ceil(total / pageSize)} \u9875\uFF0C\u5171 ${total} \u6761\uFF09
3917
+ ${label}\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
3867
3918
  `);
3868
3919
  if (items.length === 0) {
3869
3920
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -4088,17 +4139,19 @@ async function runInvoiceInfoList(opts) {
4088
4139
  `);
4089
4140
  process.exit(1);
4090
4141
  }
4091
- if (opts.json) {
4092
- console.log(JSON.stringify(data, null, 2));
4093
- return;
4094
- }
4095
4142
  const items = data.results ?? [];
4096
4143
  const total = data.totalResultCount ?? 0;
4097
4144
  const page = opts.page ?? 1;
4098
4145
  const pageSize = opts.pageSize ?? 20;
4099
- console.log(`
4100
- \u53D1\u7968\u62AC\u5934\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u5171 ${total} \u6761\uFF09
4101
- `);
4146
+ if (opts.json) {
4147
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
4148
+ return;
4149
+ }
4150
+ console.log(
4151
+ `
4152
+ \u53D1\u7968\u62AC\u5934\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
4153
+ `
4154
+ );
4102
4155
  if (items.length === 0) {
4103
4156
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
4104
4157
  return;
@@ -4256,16 +4309,16 @@ async function runAiCreationList(opts) {
4256
4309
  `);
4257
4310
  process.exit(1);
4258
4311
  }
4259
- if (opts.json) {
4260
- console.log(JSON.stringify(data, null, 2));
4261
- return;
4262
- }
4263
4312
  const items = data.results ?? [];
4264
4313
  const total = data.totalResultCount ?? 0;
4265
4314
  const page = opts.page ?? 1;
4266
4315
  const pageSize = opts.pageSize ?? 20;
4316
+ if (opts.json) {
4317
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
4318
+ return;
4319
+ }
4267
4320
  console.log(`
4268
- AI\u667A\u6295\u8BB0\u5F55\uFF08\u7B2C ${page}/${Math.ceil(total / pageSize)} \u9875\uFF0C\u5171 ${total} \u6761\uFF09
4321
+ AI\u667A\u6295\u8BB0\u5F55\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
4269
4322
  `);
4270
4323
  if (items.length === 0) {
4271
4324
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -5287,16 +5340,16 @@ async function runOptimizeList(opts) {
5287
5340
  `);
5288
5341
  process.exit(1);
5289
5342
  }
5290
- if (opts.json) {
5291
- console.log(JSON.stringify(data, null, 2));
5292
- return;
5293
- }
5294
5343
  const items = data.results ?? [];
5295
5344
  const total = data.totalResultCount ?? 0;
5296
5345
  const page = opts.page ?? 1;
5297
5346
  const pageSize = opts.pageSize ?? 20;
5347
+ if (opts.json) {
5348
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
5349
+ return;
5350
+ }
5298
5351
  console.log(`
5299
- AI\u5E7F\u544A\u4F18\u5316\uFF08\u7B2C ${page}/${Math.ceil(total / pageSize)} \u9875\uFF0C\u5171 ${total} \u4E2A\u8D26\u6237\uFF09
5352
+ AI\u5E7F\u544A\u4F18\u5316\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
5300
5353
  `);
5301
5354
  if (items.length === 0) {
5302
5355
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -5341,21 +5394,21 @@ async function runOptimizeRecords(opts) {
5341
5394
  `);
5342
5395
  process.exit(1);
5343
5396
  }
5344
- if (opts.json) {
5345
- console.log(JSON.stringify(data, null, 2));
5346
- return;
5347
- }
5348
5397
  const items = data.results ?? [];
5349
5398
  const total = data.totalResultCount ?? 0;
5350
5399
  const page = opts.page ?? 1;
5351
5400
  const pageSize = opts.pageSize ?? 20;
5401
+ if (opts.json) {
5402
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
5403
+ return;
5404
+ }
5352
5405
  const stateLabels = {
5353
5406
  Created: "\u5DF2\u521B\u5EFA",
5354
5407
  Optimizing: "\u4F18\u5316\u4E2D",
5355
5408
  Optimized: "\u5DF2\u5B8C\u6210"
5356
5409
  };
5357
5410
  console.log(`
5358
- \u4F18\u5316\u8BB0\u5F55\uFF08\u7B2C ${page}/${Math.ceil(total / pageSize)} \u9875\uFF0C\u5171 ${total} \u6761\uFF09
5411
+ \u4F18\u5316\u8BB0\u5F55\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
5359
5412
  `);
5360
5413
  if (items.length === 0) {
5361
5414
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -5383,15 +5436,19 @@ async function runOptimizeChildren(opts) {
5383
5436
  `);
5384
5437
  process.exit(1);
5385
5438
  }
5439
+ const items = data.results ?? [];
5440
+ const total = data.totalResultCount ?? 0;
5441
+ const page = opts.page ?? 1;
5442
+ const pageSize = opts.pageSize ?? 20;
5386
5443
  if (opts.json) {
5387
- console.log(JSON.stringify(data, null, 2));
5444
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
5388
5445
  return;
5389
5446
  }
5390
- const items = data.results ?? [];
5391
- const total = data.totalResultCount ?? 0;
5392
- console.log(`
5393
- \u5E7F\u544A\u7CFB\u5217\u4F18\u5316\u660E\u7EC6\uFF08parentId: ${opts.parentId}\uFF0C\u5171 ${total} \u6761\uFF09
5394
- `);
5447
+ console.log(
5448
+ `
5449
+ \u5E7F\u544A\u7CFB\u5217\u4F18\u5316\u660E\u7EC6\uFF08parentId: ${opts.parentId}\uFF0C\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
5450
+ `
5451
+ );
5395
5452
  if (items.length === 0) {
5396
5453
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
5397
5454
  return;
@@ -5437,16 +5494,16 @@ async function runForewarningList(opts) {
5437
5494
  `);
5438
5495
  process.exit(1);
5439
5496
  }
5440
- if (opts.json) {
5441
- console.log(JSON.stringify(data, null, 2));
5442
- return;
5443
- }
5444
5497
  const items = data.results ?? [];
5445
5498
  const total = data.totalResultCount ?? 0;
5446
5499
  const page = opts.page ?? 1;
5447
5500
  const pageSize = opts.pageSize ?? 20;
5501
+ if (opts.json) {
5502
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
5503
+ return;
5504
+ }
5448
5505
  console.log(`
5449
- \u667A\u80FD\u9884\u8B66\u89C4\u5219\uFF08\u7B2C ${page}/${Math.ceil(total / pageSize)} \u9875\uFF0C\u5171 ${total} \u6761\uFF09
5506
+ \u667A\u80FD\u9884\u8B66\u89C4\u5219\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
5450
5507
  `);
5451
5508
  if (items.length === 0) {
5452
5509
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -5505,16 +5562,16 @@ async function runForewarningRecords(opts) {
5505
5562
  `);
5506
5563
  process.exit(1);
5507
5564
  }
5508
- if (opts.json) {
5509
- console.log(JSON.stringify(data, null, 2));
5510
- return;
5511
- }
5512
5565
  const items = data.results ?? [];
5513
5566
  const total = data.totalResultCount ?? 0;
5514
5567
  const page = opts.page ?? 1;
5515
5568
  const pageSize = opts.pageSize ?? 20;
5569
+ if (opts.json) {
5570
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items }), null, 2));
5571
+ return;
5572
+ }
5516
5573
  console.log(`
5517
- \u9884\u8B66\u8BB0\u5F55\uFF08\u7B2C ${page}/${Math.ceil(total / pageSize)} \u9875\uFF0C\u5171 ${total} \u6761\uFF09
5574
+ \u9884\u8B66\u8BB0\u5F55\uFF08\u7B2C ${page}/${Math.max(1, Math.ceil(total / pageSize))} \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${total} \u6761\uFF09
5518
5575
  `);
5519
5576
  if (items.length === 0) {
5520
5577
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -5594,8 +5651,11 @@ async function runForewarningNotifyAccounts(opts) {
5594
5651
  `);
5595
5652
  process.exit(1);
5596
5653
  }
5654
+ const page = 1;
5655
+ const pageSize = Math.max(accounts.length, 1);
5656
+ const total = accounts.length;
5597
5657
  if (opts.json) {
5598
- console.log(JSON.stringify(accounts, null, 2));
5658
+ console.log(JSON.stringify(wrapListJson({ page, pageSize, total, items: accounts }), null, 2));
5599
5659
  return;
5600
5660
  }
5601
5661
  const returnUrl = encodeURIComponent("https://tso.siluzan.com");
@@ -5606,7 +5666,9 @@ async function runForewarningNotifyAccounts(opts) {
5606
5666
  qrLink = typeof qrData === "string" ? qrData : qrData.redirectUrl ?? qrData.url ?? "";
5607
5667
  } catch {
5608
5668
  }
5609
- console.log("\n\u{1F4F1} \u5FAE\u4FE1\u901A\u77E5\u5BF9\u8C61\u5217\u8868\n");
5669
+ console.log(`
5670
+ \u{1F4F1} \u5FAE\u4FE1\u901A\u77E5\u5BF9\u8C61\u5217\u8868\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${accounts.length} \u6761\uFF0C\u5171 ${accounts.length} \u6761\uFF09
5671
+ `);
5610
5672
  console.log(" \u901A\u77E5\u6E20\u9053\uFF1A\u4E1D\u8DEF\u8D5E\u5E73\u53F0\u5FAE\u4FE1\u670D\u52A1\u53F7\uFF08\u9700\u626B\u7801\u5173\u6CE8\u540E\u624D\u80FD\u6536\u5230\u9884\u8B66\u901A\u77E5\uFF09\n");
5611
5673
  if (qrLink) {
5612
5674
  try {
@@ -5773,12 +5835,13 @@ async function fetchTikTokClues(opts, config) {
5773
5835
  `);
5774
5836
  process.exit(1);
5775
5837
  }
5838
+ const n = leads.length;
5776
5839
  if (opts.json) {
5777
- console.log(JSON.stringify(leads, null, 2));
5840
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items: leads }), null, 2));
5778
5841
  return;
5779
5842
  }
5780
5843
  console.log(`
5781
- TikTok \u7EBF\u7D22\u8868\u5355\uFF08\u8D26\u6237 ${opts.account}\uFF0C\u5171 ${leads.length} \u6761\uFF09
5844
+ TikTok \u7EBF\u7D22\u8868\u5355\uFF08\u8D26\u6237 ${opts.account}\uFF0C\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${leads.length} \u6761\uFF0C\u5171 ${leads.length} \u6761\uFF09
5782
5845
  `);
5783
5846
  if (leads.length === 0) {
5784
5847
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -5813,12 +5876,13 @@ async function fetchMetaClues(opts, config) {
5813
5876
  const leads = (raw.formLeadsGroups ?? []).flatMap(
5814
5877
  (group) => (group.leads ?? []).filter((l) => !l["platform"] || l["platform"] === "fb").map((l) => ({ ...l, form: group.form }))
5815
5878
  );
5879
+ const n = leads.length;
5816
5880
  if (opts.json) {
5817
- console.log(JSON.stringify(leads, null, 2));
5881
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items: leads }), null, 2));
5818
5882
  return;
5819
5883
  }
5820
5884
  console.log(`
5821
- Meta \u7EBF\u7D22\u8868\u5355\uFF08\u8D26\u6237 ${opts.account}\uFF0C\u5171 ${leads.length} \u6761\uFF09
5885
+ Meta \u7EBF\u7D22\u8868\u5355\uFF08\u8D26\u6237 ${opts.account}\uFF0C\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${leads.length} \u6761\uFF0C\u5171 ${leads.length} \u6761\uFF09
5822
5886
  `);
5823
5887
  if (leads.length === 0) {
5824
5888
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -5885,13 +5949,24 @@ async function runAdCampaigns(opts) {
5885
5949
  `);
5886
5950
  process.exit(1);
5887
5951
  }
5952
+ const items = data.data ?? [];
5953
+ const n = items.length;
5888
5954
  if (opts.json) {
5889
- console.log(JSON.stringify(data, null, 2));
5955
+ console.log(
5956
+ JSON.stringify(
5957
+ {
5958
+ ...wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items }),
5959
+ code: data.code ?? null,
5960
+ message: data.message ?? null
5961
+ },
5962
+ null,
5963
+ 2
5964
+ )
5965
+ );
5890
5966
  return;
5891
5967
  }
5892
- const items = data.data ?? [];
5893
5968
  console.log(`
5894
- \u5E7F\u544A\u7CFB\u5217\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u5171 ${items.length} \u6761\uFF09
5969
+ \u5E7F\u544A\u7CFB\u5217\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${items.length} \u6761\uFF09
5895
5970
  `);
5896
5971
  if (items.length === 0) {
5897
5972
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -5945,13 +6020,20 @@ async function runAdGroups(opts) {
5945
6020
  `);
5946
6021
  process.exit(1);
5947
6022
  }
6023
+ const items = data.data ?? [];
6024
+ const n = items.length;
5948
6025
  if (opts.json) {
5949
- console.log(JSON.stringify(data, null, 2));
6026
+ console.log(
6027
+ JSON.stringify(
6028
+ { ...wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items }), code: data.code ?? null },
6029
+ null,
6030
+ 2
6031
+ )
6032
+ );
5950
6033
  return;
5951
6034
  }
5952
- const items = data.data ?? [];
5953
6035
  console.log(`
5954
- \u5E7F\u544A\u7EC4\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u5171 ${items.length} \u6761\uFF09
6036
+ \u5E7F\u544A\u7EC4\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${items.length} \u6761\uFF09
5955
6037
  `);
5956
6038
  if (items.length === 0) {
5957
6039
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -6003,13 +6085,14 @@ async function runAdList(opts) {
6003
6085
  `);
6004
6086
  process.exit(1);
6005
6087
  }
6088
+ const items = data.data ?? [];
6089
+ const n = items.length;
6006
6090
  if (opts.json) {
6007
- console.log(JSON.stringify(data, null, 2));
6091
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items }), null, 2));
6008
6092
  return;
6009
6093
  }
6010
- const items = data.data ?? [];
6011
6094
  console.log(`
6012
- \u5E7F\u544A\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u5171 ${items.length} \u6761\uFF09
6095
+ \u5E7F\u544A\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${items.length} \u6761\uFF09
6013
6096
  `);
6014
6097
  if (items.length === 0) {
6015
6098
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -6066,10 +6149,6 @@ async function runAdKeywords(opts) {
6066
6149
  `);
6067
6150
  process.exit(1);
6068
6151
  }
6069
- if (opts.json) {
6070
- console.log(JSON.stringify(data, null, 2));
6071
- return;
6072
- }
6073
6152
  const rawItems = data.data ?? [];
6074
6153
  const seen = /* @__PURE__ */ new Set();
6075
6154
  const items = rawItems.filter((item) => {
@@ -6079,8 +6158,13 @@ async function runAdKeywords(opts) {
6079
6158
  return true;
6080
6159
  });
6081
6160
  const label = opts.negative ? "\u5426\u5B9A\u5173\u952E\u8BCD" : "\u5173\u952E\u8BCD";
6161
+ const n = items.length;
6162
+ if (opts.json) {
6163
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items }), null, 2));
6164
+ return;
6165
+ }
6082
6166
  console.log(`
6083
- ${label}\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u5171 ${items.length} \u6761` + (rawItems.length !== items.length ? `\uFF0C\u539F\u59CB ${rawItems.length} \u6761\u5DF2\u53BB\u91CD` : "") + `\uFF09
6167
+ ${label}\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${items.length} \u6761` + (rawItems.length !== items.length ? `\uFF0C\u539F\u59CB ${rawItems.length} \u6761\u5DF2\u53BB\u91CD` : "") + `\uFF09
6084
6168
  `);
6085
6169
  if (items.length === 0) {
6086
6170
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -6774,10 +6858,6 @@ async function runAdExtensionList(opts) {
6774
6858
  `);
6775
6859
  process.exit(1);
6776
6860
  }
6777
- if (opts.json) {
6778
- console.log(JSON.stringify(data, null, 2));
6779
- return;
6780
- }
6781
6861
  let items = data.data ?? [];
6782
6862
  if (opts.type) {
6783
6863
  const filterType = opts.type.toUpperCase();
@@ -6785,8 +6865,13 @@ async function runAdExtensionList(opts) {
6785
6865
  (i) => String(i["typeV2"] ?? i["assetFieldType"] ?? "").toUpperCase() === filterType
6786
6866
  );
6787
6867
  }
6868
+ const n = items.length;
6869
+ if (opts.json) {
6870
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items }), null, 2));
6871
+ return;
6872
+ }
6788
6873
  console.log(`
6789
- \u9644\u52A0\u4FE1\u606F\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u5171 ${items.length} \u6761\uFF09
6874
+ \u9644\u52A0\u4FE1\u606F\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${items.length} \u6761\uFF09
6790
6875
  `);
6791
6876
  if (items.length === 0) {
6792
6877
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -6908,13 +6993,14 @@ async function runAdSearchTerms(opts) {
6908
6993
  `);
6909
6994
  process.exit(1);
6910
6995
  }
6996
+ const items = data.data ?? [];
6997
+ const n = items.length;
6911
6998
  if (opts.json) {
6912
- console.log(JSON.stringify(data, null, 2));
6999
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items }), null, 2));
6913
7000
  return;
6914
7001
  }
6915
- const items = data.data ?? [];
6916
7002
  console.log(`
6917
- \u641C\u7D22\u5B57\u8BCD\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u5171 ${items.length} \u6761\uFF09
7003
+ \u641C\u7D22\u5B57\u8BCD\uFF08\u8D26\u6237\uFF1A${opts.account}\uFF0C\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${items.length} \u6761\uFF09
6918
7004
  `);
6919
7005
  if (items.length === 0) {
6920
7006
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -7001,15 +7087,16 @@ async function runAdGeoList(opts) {
7001
7087
  `);
7002
7088
  process.exit(1);
7003
7089
  }
7004
- if (opts.json) {
7005
- console.log(JSON.stringify(data, null, 2));
7006
- return;
7007
- }
7008
7090
  const rawData = data.data;
7009
7091
  const items = Array.isArray(rawData) ? rawData : rawData?.countries ?? [];
7010
7092
  const modeLabel = { targeted: "\u5DF2\u5B9A\u4F4D", excluded: "\u5DF2\u6392\u9664", report: "\u6D88\u8017\u62A5\u544A" }[opts.mode];
7093
+ const n = items.length;
7094
+ if (opts.json) {
7095
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items }), null, 2));
7096
+ return;
7097
+ }
7011
7098
  console.log(`
7012
- \u5730\u7406\u4F4D\u7F6E\uFF08${modeLabel}\uFF0C\u8D26\u6237\uFF1A${opts.account}\uFF0C\u5171 ${items.length} \u6761\uFF09
7099
+ \u5730\u7406\u4F4D\u7F6E\uFF08${modeLabel}\uFF0C\u8D26\u6237\uFF1A${opts.account}\uFF0C\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${items.length} \u6761\uFF09
7013
7100
  `);
7014
7101
  if (items.length === 0) {
7015
7102
  console.log(" \u6682\u65E0\u6570\u636E\u3002\n");
@@ -7189,12 +7276,13 @@ async function runKeywordSuggest(opts) {
7189
7276
  return !excludes.some((exc) => kw.includes(exc));
7190
7277
  });
7191
7278
  }
7279
+ const n = items.length;
7192
7280
  if (opts.json) {
7193
- console.log(JSON.stringify(items, null, 2));
7281
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items }), null, 2));
7194
7282
  return;
7195
7283
  }
7196
7284
  console.log(`
7197
- \u5173\u952E\u5B57\u63A8\u8350\uFF08\u5171 ${items.length} \u4E2A\uFF09
7285
+ \u5173\u952E\u5B57\u63A8\u8350\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${items.length} \u6761\uFF09
7198
7286
  `);
7199
7287
  if (items.length === 0) {
7200
7288
  console.log(" \u6682\u65E0\u63A8\u8350\u5173\u952E\u8BCD\u3002\n");
@@ -7705,11 +7793,13 @@ async function runAccountWithdrawList(opts) {
7705
7793
  `);
7706
7794
  process.exit(1);
7707
7795
  }
7796
+ const allItems = Array.isArray(data) ? data : [];
7797
+ const page = 1;
7798
+ const rawTotal = allItems.length;
7708
7799
  if (opts.json) {
7709
- console.log(JSON.stringify(data, null, 2));
7800
+ console.log(JSON.stringify(wrapListJson({ page, pageSize: Math.max(rawTotal, 1), total: rawTotal, items: allItems }), null, 2));
7710
7801
  return;
7711
7802
  }
7712
- const allItems = Array.isArray(data) ? data : [];
7713
7803
  const suspendedItems = allItems.filter((item) => item.mai?.status === "Suspended");
7714
7804
  const skippedCount = allItems.length - suspendedItems.length;
7715
7805
  if (skippedCount > 0) {
@@ -7718,7 +7808,10 @@ async function runAccountWithdrawList(opts) {
7718
7808
  `);
7719
7809
  }
7720
7810
  if (suspendedItems.length === 0) {
7721
- console.log("\n \u6682\u65E0 Google Suspended\uFF08\u88AB\u5C01\uFF09\u5E7F\u544A\u8D26\u6237\u3002\n");
7811
+ console.log(`
7812
+ Google Suspended\uFF08\u88AB\u5C01\u7981\uFF09\u8D26\u6237\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 0 \u6761\uFF0C\u5171 0 \u6761\uFF09
7813
+ `);
7814
+ console.log(" \u6682\u65E0 Google Suspended\uFF08\u88AB\u5C01\uFF09\u5E7F\u544A\u8D26\u6237\u3002\n");
7722
7815
  return;
7723
7816
  }
7724
7817
  const withdrawable = suspendedItems.filter((item) => {
@@ -7731,9 +7824,11 @@ async function runAccountWithdrawList(opts) {
7731
7824
  const adjustments = Number(item.mai?.totalAdjustmentsMicros ?? 0);
7732
7825
  return balance - adjustments <= 0;
7733
7826
  });
7734
- console.log(`
7735
- Google Suspended\uFF08\u88AB\u5C01\u7981\uFF09\u8D26\u6237\uFF08\u5171 ${suspendedItems.length} \u6761\uFF0C\u5176\u4E2D ${withdrawable.length} \u6761\u6709\u4F59\u989D\u53EF\u63D0\u73B0\uFF09
7736
- `);
7827
+ console.log(
7828
+ `
7829
+ Google Suspended\uFF08\u88AB\u5C01\u7981\uFF09\u8D26\u6237\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${suspendedItems.length} \u6761\uFF0C\u5171 ${suspendedItems.length} \u6761\uFF0C\u5176\u4E2D ${withdrawable.length} \u6761\u6709\u4F59\u989D\u53EF\u63D0\u73B0\uFF09
7830
+ `
7831
+ );
7737
7832
  const cols = [
7738
7833
  { key: "entityId", header: "entityId" },
7739
7834
  { key: "mediaCustomerId", header: "mediaCustomerId" },
@@ -8038,16 +8133,21 @@ async function runAccountEmailAuthList(opts) {
8038
8133
  `);
8039
8134
  process.exit(1);
8040
8135
  }
8136
+ const page = 1;
8137
+ const total = items.length;
8041
8138
  if (opts.json) {
8042
- console.log(JSON.stringify(items, null, 2));
8139
+ console.log(JSON.stringify(wrapListJson({ page, pageSize: Math.max(total, 1), total, items }), null, 2));
8043
8140
  return;
8044
8141
  }
8045
8142
  if (items.length === 0) {
8046
- console.log("\n \u6682\u65E0\u90AE\u7BB1\u6388\u6743\u8BB0\u5F55\u3002\n");
8143
+ console.log(`
8144
+ \u8D26\u6237 ${opts.customerId} \u7684\u90AE\u7BB1\u6388\u6743\u5217\u8868\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 0 \u6761\uFF0C\u5171 0 \u6761\uFF09
8145
+ `);
8146
+ console.log(" \u6682\u65E0\u90AE\u7BB1\u6388\u6743\u8BB0\u5F55\u3002\n");
8047
8147
  return;
8048
8148
  }
8049
8149
  console.log(`
8050
- \u8D26\u6237 ${opts.customerId} \u7684\u90AE\u7BB1\u6388\u6743\u5217\u8868\uFF08\u5171 ${items.length} \u6761\uFF09
8150
+ \u8D26\u6237 ${opts.customerId} \u7684\u90AE\u7BB1\u6388\u6743\u5217\u8868\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${items.length} \u6761\uFF0C\u5171 ${items.length} \u6761\uFF09
8051
8151
  `);
8052
8152
  const cols = [
8053
8153
  { key: "invitationId", header: "\u9080\u8BF7 ID" },
@@ -8215,17 +8315,20 @@ async function runListAdvertiserGroups(opts) {
8215
8315
  `);
8216
8316
  process.exit(1);
8217
8317
  }
8318
+ const groups = data?.profile?.mediaAccountGroups ?? [];
8319
+ const n = groups.length;
8320
+ const page = 1;
8218
8321
  if (opts.json) {
8219
- console.log(JSON.stringify(data?.profile?.mediaAccountGroups ?? [], null, 2));
8322
+ console.log(JSON.stringify(wrapListJson({ page, pageSize: Math.max(n, 1), total: n, items: groups }), null, 2));
8220
8323
  return;
8221
8324
  }
8222
- const groups = data?.profile?.mediaAccountGroups ?? [];
8223
8325
  if (groups.length === 0) {
8224
- console.log("\n \u6682\u65E0\u5E7F\u544A\u4E3B\u7EC4\uFF0C\u8BF7\u5148\u5728 Siluzan TSO \u5E73\u53F0\u521B\u5EFA\u5E7F\u544A\u4E3B\u3002\n");
8326
+ console.log("\n\u5E7F\u544A\u4E3B\u7EC4\u5217\u8868\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 0 \u6761\uFF0C\u5171 0 \u6761\uFF09\n");
8327
+ console.log(" \u6682\u65E0\u5E7F\u544A\u4E3B\u7EC4\uFF0C\u8BF7\u5148\u5728 Siluzan TSO \u5E73\u53F0\u521B\u5EFA\u5E7F\u544A\u4E3B\u3002\n");
8225
8328
  return;
8226
8329
  }
8227
8330
  console.log(`
8228
- \u5E7F\u544A\u4E3B\u7EC4\u5217\u8868\uFF08\u5171 ${groups.length} \u6761\uFF09
8331
+ \u5E7F\u544A\u4E3B\u7EC4\u5217\u8868\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${groups.length} \u6761\uFF0C\u5171 ${groups.length} \u6761\uFF09
8229
8332
  `);
8230
8333
  const cols = [
8231
8334
  { key: "magKey", header: "magKey\uFF08\u5F00\u6237\u65F6\u4F7F\u7528\uFF09" },
@@ -8682,12 +8785,13 @@ async function runOpenAccountGoogleTimezones(opts) {
8682
8785
  return code.includes(kw) || name.includes(kw) || time.includes(kw) || label.includes(kw);
8683
8786
  });
8684
8787
  }
8788
+ const n = rows.length;
8685
8789
  if (opts.json) {
8686
- console.log(JSON.stringify(rows, null, 2));
8790
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items: rows }), null, 2));
8687
8791
  return;
8688
8792
  }
8689
8793
  console.log(`
8690
- Google \u5F00\u6237\u53EF\u9009\u65F6\u533A\uFF08\u4E0E\u7F51\u9875 /openAnAccount \u4E0B\u62C9\u4E00\u81F4\uFF0C\u5171 ${rows.length} \u6761\uFF09
8794
+ Google \u5F00\u6237\u53EF\u9009\u65F6\u533A\uFF08\u4E0E\u7F51\u9875 /openAnAccount \u4E0B\u62C9\u4E00\u81F4\uFF0C\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${rows.length} \u6761\uFF0C\u5171 ${rows.length} \u6761\uFF09
8691
8795
  `);
8692
8796
  if (rows.length === 0) {
8693
8797
  console.log(" \u65E0\u6570\u636E\u3002\u53EF\u5C1D\u8BD5\u53BB\u6389 --keyword \u6216\u52A0 --verbose\u3002\n");
@@ -9064,12 +9168,13 @@ async function runOpenAccountTikTokTimezones(opts) {
9064
9168
  return code.includes(kw) || name.includes(kw) || time.includes(kw);
9065
9169
  });
9066
9170
  }
9171
+ const n = rows.length;
9067
9172
  if (opts.json) {
9068
- console.log(JSON.stringify(rows, null, 2));
9173
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items: rows }), null, 2));
9069
9174
  return;
9070
9175
  }
9071
9176
  console.log(`
9072
- TikTok \u5F00\u6237\u53EF\u9009\u65F6\u533A\uFF08\u5171 ${rows.length} \u6761\uFF09
9177
+ TikTok \u5F00\u6237\u53EF\u9009\u65F6\u533A\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${rows.length} \u6761\uFF0C\u5171 ${rows.length} \u6761\uFF09
9073
9178
  `);
9074
9179
  if (rows.length === 0) {
9075
9180
  console.log(" \u65E0\u6570\u636E\u3002\n");
@@ -9109,12 +9214,13 @@ async function runOpenAccountTikTokIndustries(opts) {
9109
9214
  if (kw) {
9110
9215
  rows = rows.filter((r) => String(r.IndustryName ?? "").toLowerCase().includes(kw));
9111
9216
  }
9217
+ const n = rows.length;
9112
9218
  if (opts.json) {
9113
- console.log(JSON.stringify(rows, null, 2));
9219
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items: rows }), null, 2));
9114
9220
  return;
9115
9221
  }
9116
9222
  console.log(`
9117
- TikTok \u884C\u4E1A\u5217\u8868\uFF08\u5171 ${rows.length} \u6761\uFF0C--industry-id \u4F20\u53F6\u5B50\u8282\u70B9 ID\uFF09
9223
+ TikTok \u884C\u4E1A\u5217\u8868\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${rows.length} \u6761\uFF0C\u5171 ${rows.length} \u6761\uFF0C--industry-id \u4F20\u53F6\u5B50\u8282\u70B9 ID\uFF09
9118
9224
  `);
9119
9225
  if (rows.length === 0) {
9120
9226
  console.log(" \u65E0\u6570\u636E\u3002\n");
@@ -9153,12 +9259,13 @@ async function runOpenAccountBingIndustries(opts) {
9153
9259
  if (kw) {
9154
9260
  list = list.filter((r) => r.name.toLowerCase().includes(kw));
9155
9261
  }
9262
+ const n = list.length;
9156
9263
  if (opts.json) {
9157
- console.log(JSON.stringify(list, null, 2));
9264
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items: list }), null, 2));
9158
9265
  return;
9159
9266
  }
9160
9267
  console.log(`
9161
- BingV2 \u884C\u4E1A\u5217\u8868\uFF08\u5171 ${list.length} \u6761\uFF0C\u5C06 name \u503C\u4F20\u7ED9 --trade-id\uFF09
9268
+ BingV2 \u884C\u4E1A\u5217\u8868\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${list.length} \u6761\uFF0C\u5171 ${list.length} \u6761\uFF0C\u5C06 name \u503C\u4F20\u7ED9 --trade-id\uFF09
9162
9269
  `);
9163
9270
  if (list.length === 0) {
9164
9271
  console.log(" \u65E0\u6570\u636E\u3002\n");
@@ -9193,12 +9300,13 @@ async function runOpenAccountTikTokAreas(opts) {
9193
9300
  (r) => String(r.Key ?? "").toLowerCase().includes(kw) || String(r.Value ?? "").toLowerCase().includes(kw)
9194
9301
  );
9195
9302
  }
9303
+ const n = rows.length;
9196
9304
  if (opts.json) {
9197
- console.log(JSON.stringify(rows, null, 2));
9305
+ console.log(JSON.stringify(wrapListJson({ page: 1, pageSize: Math.max(n, 1), total: n, items: rows }), null, 2));
9198
9306
  return;
9199
9307
  }
9200
9308
  console.log(`
9201
- TikTok \u6CE8\u518C\u5730\u5217\u8868\uFF08\u5171 ${rows.length} \u6761\uFF0C--registered-area \u4F20 Key \u503C\uFF09
9309
+ TikTok \u6CE8\u518C\u5730\u5217\u8868\uFF08\u7B2C 1 \u9875\uFF0C\u672C\u9875 ${rows.length} \u6761\uFF0C\u5171 ${rows.length} \u6761\uFF0C--registered-area \u4F20 Key \u503C\uFF09
9202
9310
  `);
9203
9311
  if (rows.length === 0) {
9204
9312
  console.log(" \u65E0\u6570\u636E\u3002\n");
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "slug": "siluzan-tso",
3
- "version": "1.0.0-beta.30",
4
- "publishedAt": 1774507264267
3
+ "version": "1.0.0-beta.31",
4
+ "publishedAt": 1774509377471
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siluzan-tso-cli",
3
- "version": "1.0.0-beta.30",
3
+ "version": "1.0.0-beta.31",
4
4
  "description": "Siluzan 广告账户管理 CLI — 查询账户、余额、消耗数据,管理绑定关系与充值。",
5
5
  "type": "module",
6
6
  "bin": {