@hcmai/cli 0.21.3 → 0.21.5

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/dist/index.js CHANGED
@@ -3993,7 +3993,7 @@ async function queryCommand(model, args) {
3993
3993
  const client3 = HcmClient2.fromAuthContext(await getActiveAuthContextFromCli(args));
3994
3994
  const result = await client3.query(model, dsl);
3995
3995
  const fmt = args.output ?? "table";
3996
- printQueryResult(result, fmt);
3996
+ printQueryResult(result, fmt, dsl);
3997
3997
  } catch (e) {
3998
3998
  const err = e;
3999
3999
  if (err?.isAxiosError) {
@@ -4015,13 +4015,31 @@ function buildQueryDsl(args) {
4015
4015
  if (!dsl.limit) dsl.limit = 20;
4016
4016
  return dsl;
4017
4017
  }
4018
- function printQueryResult(result, fmt) {
4018
+ function printQueryResult(result, fmt, dsl = {}) {
4019
4019
  const out = formatRows(result.rows, { format: fmt });
4020
4020
  process.stdout.write(out + "\n");
4021
4021
  if (fmt === "table" && result.total !== void 0) {
4022
4022
  process.stdout.write(`Showing ${result.rows.length} of ${result.total} results.
4023
4023
  `);
4024
4024
  }
4025
+ const limit = dsl.limit ?? 20;
4026
+ const offset = Math.floor((dsl.offset ?? 0) / limit) * limit;
4027
+ const nextPage = `\u8BF7\u6309 --limit ${limit} --offset ${offset + limit} \u7EE7\u7EED\u67E5\u8BE2\uFF1B\u5168\u91CF\u7EDF\u8BA1\u5FC5\u987B\u6536\u9F50\u6240\u6709\u5206\u9875\u3002`;
4028
+ if (typeof result.total === "number" && Number.isSafeInteger(result.total) && result.total >= 0) {
4029
+ if (result.total > result.rows.length) {
4030
+ const nextStep = result.total > offset + result.rows.length ? nextPage : "\u5DF2\u5230\u672B\u9875\uFF1B\u5168\u91CF\u7EDF\u8BA1\u8BF7\u4ECE --offset 0 \u5F00\u59CB\u6536\u9F50\u6240\u6709\u5206\u9875\u3002";
4031
+ process.stderr.write(
4032
+ `\u67E5\u8BE2\u7ED3\u679C\u672A\u53D6\u5168\uFF1A\u672C\u9875\u8FD4\u56DE ${result.rows.length} \u6761\uFF0C\u5339\u914D\u603B\u6570 ${result.total}\uFF0Climit=${limit}\uFF0Coffset=${offset}\u3002${nextStep}
4033
+ `
4034
+ );
4035
+ }
4036
+ } else if (result.rows.length >= limit || offset > 0) {
4037
+ const nextStep = result.rows.length >= limit ? nextPage : "\u672C\u6B21\u672A\u67E5\u8BE2\u6B64\u524D\u5206\u9875\uFF1B\u8BF7\u4ECE --offset 0 \u5F00\u59CB\u6536\u9F50\u6240\u6709\u5206\u9875\u3002";
4038
+ process.stderr.write(
4039
+ `\u5339\u914D\u603B\u6570\u672A\u77E5\uFF1A\u672C\u9875\u8FD4\u56DE ${result.rows.length} \u6761\uFF0Coffset=${offset}\uFF0C\u7ED3\u679C\u53EF\u80FD\u4E0D\u5B8C\u6574\uFF08limit=${limit}\uFF09\u3002${nextStep}
4040
+ `
4041
+ );
4042
+ }
4025
4043
  process.exitCode = 0;
4026
4044
  }
4027
4045
  function parseAdditionsOrThrow(text) {
@@ -4753,9 +4771,17 @@ function formatDescriptionTable(desc, verbose = false) {
4753
4771
  const req = f.required ? " required" : " ";
4754
4772
  const extras = verbose ? [f.label, f.description, formatEnumValues(f.enums)] : [f.label];
4755
4773
  const lbl = extras.filter((s) => s && s.length > 0).map((s) => ` ${s}`).join("");
4756
- const type = f.i18n ? `${f.type} (i18n)` : f.type;
4774
+ const hints = [f.i18n && "i18n", f.jsonObject && "json", f.decimalNumber && "decimal"].filter(Boolean).map((hint) => ` (${hint})`).join("");
4775
+ const type = f.type + hints;
4776
+ const writeHints = [f.readOnly && "readonly", f.systemManaged && "system-managed"].filter(Boolean).map((hint) => ` [${hint}]`).join("");
4757
4777
  const objectRef = f.object ? ` \u2192 ${f.object}` : "";
4758
- lines.push(` ${f.name.padEnd(20)} ${type.padEnd(14)} ${req}${lbl}${objectRef}`);
4778
+ lines.push(` ${f.name.padEnd(20)} ${type.padEnd(14)} ${req}${lbl}${objectRef}${writeHints}`);
4779
+ }
4780
+ if (desc.fields.some((f) => f.jsonObject)) {
4781
+ lines.push(" \u2139\uFE0F (json) = JSON \u7ED3\u6784\uFF0C\u6309\u5B57\u6BB5\u8981\u6C42\u4F20\u5BF9\u8C61\u6216\u6570\u7EC4\uFF1B\u4E0D\u8981\u6309\u666E\u901A\u5B57\u7B26\u4E32\u731C\u503C");
4782
+ }
4783
+ if (desc.fields.some((f) => f.decimalNumber)) {
4784
+ lines.push(" \u2139\uFE0F (decimal) = \u7CBE\u786E\u5C0F\u6570\uFF0C\u53EF\u4F20\u6570\u503C\u6216\u5341\u8FDB\u5236\u5B57\u7B26\u4E32");
4759
4785
  }
4760
4786
  if (desc.fields.some((f) => f.object)) {
4761
4787
  lines.push(