bpmax-cli 0.2.1-beta.24 → 0.2.1-beta.25

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
@@ -180,6 +180,8 @@ Use typed project search for high-volume reads, candidate lookup, form-field loo
180
180
  bpmax-cli project search --profile yuanrong --body @project-search-query.json --page 1 --page-size 20 --format json
181
181
  ```
182
182
 
183
+ `project search`, `project list`, and the compatibility alias `es project-search` send pagination in the `/project/list` request body as `page` and `page_size`. For older CLI versions, put `page` and `page_size` directly in the `--body` JSON to avoid repeated first-page reads.
184
+
183
185
  ```json
184
186
  {
185
187
  "data_set_key": "budget_project",
package/dist/bin.js CHANGED
@@ -469,7 +469,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
469
469
  // package.json
470
470
  var package_default = {
471
471
  name: "bpmax-cli",
472
- version: "0.2.1-beta.24",
472
+ version: "0.2.1-beta.25",
473
473
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
474
474
  type: "module",
475
475
  bin: {
@@ -4654,42 +4654,277 @@ function validateFlowTemplateActionTarget(errors, pathName, target, nodeIds, con
4654
4654
  }
4655
4655
  }
4656
4656
  var FLOW_TEMPLATE_OWNER_AUTO_RANGE_TYPES = /* @__PURE__ */ new Set(["owner", "role", "user", "leader", "continuous_leader", "group", "fieldvalue", "matrix"]);
4657
+ var FLOW_TEMPLATE_LEADER_MATCH_METHODS = /* @__PURE__ */ new Set(["owner", "form"]);
4658
+ var FLOW_TEMPLATE_LEADER_SUPERIOR_TYPES = /* @__PURE__ */ new Set(["org", "direct"]);
4659
+ var FLOW_TEMPLATE_CONTINUOUS_DIRECTIONS = /* @__PURE__ */ new Set(["up", "down"]);
4660
+ var FLOW_TEMPLATE_RUNTIME_CC_TYPES = /* @__PURE__ */ new Set(["fieldvalue", "matrix"]);
4661
+ var FLOW_TEMPLATE_CC_TRIGGER_MODES = /* @__PURE__ */ new Set(["all", "approve", "refuse"]);
4662
+ var FLOW_TEMPLATE_CC_TRIGGER_TIMINGS = /* @__PURE__ */ new Set(["step_active", "step_finish"]);
4663
+ var FLOW_TEMPLATE_MATRIX_FLOW_PATTERN = /^[^:\s]+:[^:\s]*$/;
4664
+ function isPositiveIntegerLike(value) {
4665
+ if (typeof value !== "number" && typeof value !== "string") {
4666
+ return false;
4667
+ }
4668
+ if (typeof value === "string" && !value.trim()) {
4669
+ return false;
4670
+ }
4671
+ const numericValue = Number(value);
4672
+ return Number.isInteger(numericValue) && numericValue > 0;
4673
+ }
4674
+ function isNonEmptyFlowTemplateIdentifier(value) {
4675
+ if (typeof value === "number") {
4676
+ return Number.isFinite(value) && value > 0;
4677
+ }
4678
+ return typeof value === "string" && Boolean(value.trim());
4679
+ }
4680
+ function isValidFlowTemplateRoleCount(value) {
4681
+ return value === void 0 || value === null || value === "" || value === false || value === true || value === 0 || value === "all" || isPositiveIntegerLike(value);
4682
+ }
4683
+ function isUsableFlowTemplateScript(value) {
4684
+ if (typeof value !== "string" || !value.trim()) {
4685
+ return false;
4686
+ }
4687
+ const withoutComments = value.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/\/\/[^\r\n]*/g, " ").trim();
4688
+ if (!withoutComments) {
4689
+ return false;
4690
+ }
4691
+ const normalized = withoutComments.replace(/\s+/g, " ").replace(/^(?:debugger\s*;\s*)+/i, "").replace(/;+\s*$/, "").trim();
4692
+ return !(/^(?:todo|tbd|placeholder|not implemented)$/i.test(normalized) || /^return\s+(?:(?:await\s+)?Promise\.resolve\s*\(\s*)?(?:\[\]|\{\}|null|undefined)(?:\s*\))?$/i.test(normalized) || /^return\s+(?:new\s+)?Array\s*\(\s*\)$/i.test(normalized) || /^throw\s+new\s+error\s*\(\s*['"`](?:todo|tbd|placeholder|not implemented)[^'"`]*['"`]\s*\)$/i.test(normalized));
4693
+ }
4694
+ function validateFlowTemplateMatrixConfig(value, pathName, errors) {
4695
+ if (!isRecord3(value)) {
4696
+ errors.push(`${pathName} is required and must be an object.`);
4697
+ return;
4698
+ }
4699
+ const flow = typeof value.flow === "string" ? value.flow.trim() : "";
4700
+ if (!FLOW_TEMPLATE_MATRIX_FLOW_PATTERN.test(flow)) {
4701
+ errors.push(`${pathName}.flow must use "flow_type:flow_key" format.`);
4702
+ }
4703
+ if (!isUsableFlowTemplateScript(value.script)) {
4704
+ errors.push(`${pathName}.script must be a non-placeholder script.`);
4705
+ }
4706
+ }
4707
+ function validateFlowTemplateLeaderRule(rawRule, pathName, errors) {
4708
+ if (!isRecord3(rawRule)) {
4709
+ errors.push(`${pathName} must be an object.`);
4710
+ return;
4711
+ }
4712
+ const matchMethod = typeof rawRule.match_method === "string" ? rawRule.match_method.trim() : "";
4713
+ if (!FLOW_TEMPLATE_LEADER_MATCH_METHODS.has(matchMethod)) {
4714
+ errors.push(`${pathName}.match_method must be owner or form.`);
4715
+ } else if (matchMethod === "owner" && (typeof rawRule.step_id !== "string" || !rawRule.step_id.trim())) {
4716
+ errors.push(`${pathName}.step_id is required when match_method is owner.`);
4717
+ } else if (matchMethod === "form") {
4718
+ if (typeof rawRule.form_source_type !== "string" || !rawRule.form_source_type.trim()) {
4719
+ errors.push(`${pathName}.form_source_type is required when match_method is form.`);
4720
+ }
4721
+ if (typeof rawRule.form_field_key !== "string" || !rawRule.form_field_key.trim()) {
4722
+ errors.push(`${pathName}.form_field_key is required when match_method is form.`);
4723
+ }
4724
+ }
4725
+ const superiorType = typeof rawRule.superior_type === "string" ? rawRule.superior_type.trim() : "";
4726
+ if (!FLOW_TEMPLATE_LEADER_SUPERIOR_TYPES.has(superiorType)) {
4727
+ errors.push(`${pathName}.superior_type must be org or direct.`);
4728
+ }
4729
+ const levelsUp = Number(rawRule.levels_up);
4730
+ if (!isPositiveIntegerLike(rawRule.levels_up) || levelsUp > 20) {
4731
+ errors.push(`${pathName}.levels_up must be an integer from 1 to 20.`);
4732
+ }
4733
+ if (rawRule.max_levels_up !== void 0) {
4734
+ const maxLevelsUp = Number(rawRule.max_levels_up);
4735
+ if (!isPositiveIntegerLike(rawRule.max_levels_up) || maxLevelsUp > 20) {
4736
+ errors.push(`${pathName}.max_levels_up must be an integer from 1 to 20 when provided.`);
4737
+ } else if (Number.isFinite(levelsUp) && maxLevelsUp < levelsUp) {
4738
+ errors.push(`${pathName}.max_levels_up must be greater than or equal to levels_up.`);
4739
+ }
4740
+ }
4741
+ }
4742
+ function validateFlowTemplateLeaderRules(node, nodeName, errors) {
4743
+ if (Array.isArray(node.leader_rules) && node.leader_rules.length) {
4744
+ node.leader_rules.forEach((rawRule, ruleIndex) => {
4745
+ validateFlowTemplateLeaderRule(rawRule, `${nodeName}.leader_rules[${ruleIndex}]`, errors);
4746
+ });
4747
+ return;
4748
+ }
4749
+ const hasLegacyLeaderConfig = Boolean(
4750
+ node.leader_match_method || node.auto_range_by_step_owner_group_leader || node.leader_form_source_type || node.leader_form_field_key || node.leader_superior_type || node.leader_levels_up || node.leader_max_levels_up
4751
+ );
4752
+ if (!hasLegacyLeaderConfig) {
4753
+ errors.push(`${nodeName}.leader_rules or legacy leader_* config is required when auto_range_type is leader.`);
4754
+ return;
4755
+ }
4756
+ validateFlowTemplateLeaderRule(
4757
+ {
4758
+ match_method: node.leader_match_method || "owner",
4759
+ step_id: node.auto_range_by_step_owner_group_leader,
4760
+ form_source_type: node.leader_form_source_type,
4761
+ form_field_key: node.leader_form_field_key,
4762
+ superior_type: node.leader_superior_type || "org",
4763
+ levels_up: node.leader_levels_up || 1,
4764
+ max_levels_up: node.leader_max_levels_up
4765
+ },
4766
+ `${nodeName}.legacy_leader_config`,
4767
+ errors
4768
+ );
4769
+ }
4770
+ function validateFlowTemplateContinuousLeader(node, nodeName, errors) {
4771
+ const matchMethod = typeof node.continuous_match_method === "string" ? node.continuous_match_method.trim() : "";
4772
+ if (!FLOW_TEMPLATE_LEADER_MATCH_METHODS.has(matchMethod)) {
4773
+ errors.push(`${nodeName}.continuous_match_method must be owner or form when auto_range_type is continuous_leader.`);
4774
+ } else if (matchMethod === "owner" && (typeof node.continuous_step_id !== "string" || !node.continuous_step_id.trim())) {
4775
+ errors.push(`${nodeName}.continuous_step_id is required when continuous_match_method is owner.`);
4776
+ } else if (matchMethod === "form") {
4777
+ if (typeof node.continuous_form_source_type !== "string" || !node.continuous_form_source_type.trim()) {
4778
+ errors.push(`${nodeName}.continuous_form_source_type is required when continuous_match_method is form.`);
4779
+ }
4780
+ if (typeof node.continuous_form_field_key !== "string" || !node.continuous_form_field_key.trim()) {
4781
+ errors.push(`${nodeName}.continuous_form_field_key is required when continuous_match_method is form.`);
4782
+ }
4783
+ }
4784
+ const superiorType = typeof node.continuous_superior_type === "string" ? node.continuous_superior_type.trim() : "";
4785
+ if (!FLOW_TEMPLATE_LEADER_SUPERIOR_TYPES.has(superiorType)) {
4786
+ errors.push(`${nodeName}.continuous_superior_type must be org or direct.`);
4787
+ }
4788
+ const matchDirection = typeof node.continuous_match_direction === "string" ? node.continuous_match_direction.trim() : "";
4789
+ if (!FLOW_TEMPLATE_CONTINUOUS_DIRECTIONS.has(matchDirection)) {
4790
+ errors.push(`${nodeName}.continuous_match_direction must be up or down.`);
4791
+ }
4792
+ const terminationType = typeof node.continuous_termination_type === "string" ? node.continuous_termination_type.trim() : "";
4793
+ const allowedTerminationTypes = matchDirection === "up" ? /* @__PURE__ */ new Set(["direct", "level"]) : matchDirection === "down" ? /* @__PURE__ */ new Set(["top", "level"]) : /* @__PURE__ */ new Set();
4794
+ if (!allowedTerminationTypes.has(terminationType)) {
4795
+ errors.push(
4796
+ `${nodeName}.continuous_termination_type must be ${matchDirection === "down" ? "top or level" : "direct or level"} for the configured continuous_match_direction.`
4797
+ );
4798
+ }
4799
+ if (terminationType === "level") {
4800
+ const levelCount = Number(node.continuous_termination_level_count);
4801
+ if (!isPositiveIntegerLike(node.continuous_termination_level_count) || levelCount > 20) {
4802
+ errors.push(`${nodeName}.continuous_termination_level_count must be an integer from 1 to 20 when termination type is level.`);
4803
+ }
4804
+ }
4805
+ }
4806
+ function validateFlowTemplateCcShape(node, nodeName, errors) {
4807
+ if (node.cc_type !== void 0 && typeof node.cc_type !== "string") {
4808
+ errors.push(`${nodeName}.cc_type must be a string when provided.`);
4809
+ }
4810
+ const ccType = typeof node.cc_type === "string" ? node.cc_type.trim() : "";
4811
+ if (ccType && !FLOW_TEMPLATE_RUNTIME_CC_TYPES.has(ccType)) {
4812
+ errors.push(
4813
+ `${nodeName}.cc_type must be fieldvalue or matrix; the server CC runtime does not execute role or user configurations.`
4814
+ );
4815
+ }
4816
+ if (ccType === "fieldvalue" && !isUsableFlowTemplateScript(node.cc_user_by_script)) {
4817
+ errors.push(`${nodeName}.cc_user_by_script must be a non-placeholder script when cc_type is fieldvalue.`);
4818
+ }
4819
+ if (ccType === "matrix") {
4820
+ validateFlowTemplateMatrixConfig(node.cc_matrix, `${nodeName}.cc_matrix`, errors);
4821
+ }
4822
+ const triggerMode = typeof node.cc_trigger_mode === "string" ? node.cc_trigger_mode.trim() : "";
4823
+ if (ccType && node.cc_trigger_mode !== void 0) {
4824
+ if (!FLOW_TEMPLATE_CC_TRIGGER_MODES.has(triggerMode)) {
4825
+ errors.push(`${nodeName}.cc_trigger_mode must be all, approve, or refuse when provided.`);
4826
+ }
4827
+ }
4828
+ let normalizedTimings;
4829
+ if (node.cc_trigger_timing !== void 0) {
4830
+ if (!Array.isArray(node.cc_trigger_timing)) {
4831
+ errors.push(`${nodeName}.cc_trigger_timing must be an array containing only step_active or step_finish.`);
4832
+ } else {
4833
+ normalizedTimings = [];
4834
+ node.cc_trigger_timing.forEach((timing, timingIndex) => {
4835
+ if (typeof timing !== "string" || !FLOW_TEMPLATE_CC_TRIGGER_TIMINGS.has(timing.trim())) {
4836
+ errors.push(`${nodeName}.cc_trigger_timing[${timingIndex}] must be step_active or step_finish.`);
4837
+ } else {
4838
+ normalizedTimings?.push(timing.trim());
4839
+ }
4840
+ });
4841
+ if (ccType && !node.cc_trigger_timing.length) {
4842
+ errors.push(`${nodeName}.cc_trigger_timing must not be empty when cc_type is configured.`);
4843
+ }
4844
+ }
4845
+ }
4846
+ if (ccType && normalizedTimings?.includes("step_active") && (triggerMode === "approve" || triggerMode === "refuse")) {
4847
+ errors.push(
4848
+ `${nodeName}.cc_trigger_mode must be all when cc_trigger_timing includes step_active because no approval outcome exists at activation time.`
4849
+ );
4850
+ }
4851
+ }
4852
+ function validateFlowTemplateCompletionThreshold(value, pathName, errors) {
4853
+ if (value === void 0 || value === 0) {
4854
+ return false;
4855
+ }
4856
+ if (value === "all" || isPositiveIntegerLike(value)) {
4857
+ return true;
4858
+ }
4859
+ errors.push(`${pathName} must be 0, all, or a positive integer when provided.`);
4860
+ return false;
4861
+ }
4657
4862
  function validateFlowTemplateOwnerStrategyShape(node, nodeName, errors) {
4658
4863
  const rawType = typeof node.auto_range_type === "string" ? node.auto_range_type.trim() : "";
4864
+ validateFlowTemplateCcShape(node, nodeName, errors);
4865
+ const hasApproveThreshold = validateFlowTemplateCompletionThreshold(
4866
+ node.approve_count_required,
4867
+ `${nodeName}.approve_count_required`,
4868
+ errors
4869
+ );
4870
+ const hasDoneThreshold = validateFlowTemplateCompletionThreshold(
4871
+ node.done_count_required,
4872
+ `${nodeName}.done_count_required`,
4873
+ errors
4874
+ );
4875
+ if (hasApproveThreshold && hasDoneThreshold) {
4876
+ errors.push(`${nodeName}.approve_count_required and done_count_required cannot both define an effective completion threshold.`);
4877
+ }
4659
4878
  if (!rawType) return;
4660
4879
  if (!FLOW_TEMPLATE_OWNER_AUTO_RANGE_TYPES.has(rawType)) {
4661
4880
  errors.push(`${nodeName}.auto_range_type must be one of owner, role, user, leader, continuous_leader, group, fieldvalue, matrix.`);
4662
4881
  return;
4663
4882
  }
4664
- if (rawType === "owner" && typeof node.owner_is_creater !== "boolean") {
4665
- errors.push(`${nodeName}.owner_is_creater must be a boolean when auto_range_type is owner.`);
4883
+ if (rawType === "owner" && node.owner_is_creater !== true) {
4884
+ errors.push(`${nodeName}.owner_is_creater must be true when auto_range_type is owner.`);
4666
4885
  }
4667
- if (rawType === "role" && (!Array.isArray(node.owner_roles) || !node.owner_roles.length) && !node.auto_range_by_role) {
4668
- errors.push(`${nodeName}.owner_roles or auto_range_by_role is required when auto_range_type is role.`);
4886
+ if (rawType === "role") {
4887
+ if (!Array.isArray(node.owner_roles) || !node.owner_roles.length || node.owner_roles.some((role) => typeof role !== "string" || !role.trim())) {
4888
+ errors.push(`${nodeName}.owner_roles must be a non-empty array of role keys when auto_range_type is role.`);
4889
+ }
4890
+ if (!isValidFlowTemplateRoleCount(node.auto_range_by_role)) {
4891
+ errors.push(
4892
+ `${nodeName}.auto_range_by_role must be 0, false, true, all, or a positive integer when provided.`
4893
+ );
4894
+ }
4895
+ if (node.role_logic !== void 0 && node.role_logic !== "or" && node.role_logic !== "and") {
4896
+ errors.push(`${nodeName}.role_logic must be or or and when provided.`);
4897
+ }
4898
+ if (node.auto_range_by_role_range !== void 0) {
4899
+ if (typeof node.auto_range_by_role_range !== "string") {
4900
+ errors.push(`${nodeName}.auto_range_by_role_range must be a script string when provided.`);
4901
+ } else if (node.auto_range_by_role_range.trim() && !isUsableFlowTemplateScript(node.auto_range_by_role_range)) {
4902
+ errors.push(`${nodeName}.auto_range_by_role_range must be a non-placeholder script when provided.`);
4903
+ }
4904
+ }
4669
4905
  }
4670
- if (rawType === "user" && (!Array.isArray(node.auto_range_by_users) || !node.auto_range_by_users.length)) {
4671
- errors.push(`${nodeName}.auto_range_by_users must be a non-empty array when auto_range_type is user.`);
4906
+ if (rawType === "user" && (!Array.isArray(node.auto_range_by_users) || !node.auto_range_by_users.length || node.auto_range_by_users.some((user) => !isNonEmptyFlowTemplateIdentifier(user)))) {
4907
+ errors.push(`${nodeName}.auto_range_by_users must be a non-empty array of user ids when auto_range_type is user.`);
4672
4908
  }
4673
- if (rawType === "group" && (!Array.isArray(node.auto_range_by_groups) || !node.auto_range_by_groups.length)) {
4674
- errors.push(`${nodeName}.auto_range_by_groups must be a non-empty array when auto_range_type is group.`);
4909
+ if (rawType === "group") {
4910
+ if (!Array.isArray(node.auto_range_by_group) || !node.auto_range_by_group.length || node.auto_range_by_group.some((group) => !isNonEmptyFlowTemplateIdentifier(group))) {
4911
+ errors.push(`${nodeName}.auto_range_by_group must be a non-empty array of group ids when auto_range_type is group.`);
4912
+ }
4913
+ if (!isPositiveIntegerLike(node.auto_range_by_group_count)) {
4914
+ errors.push(`${nodeName}.auto_range_by_group_count must be a positive integer when auto_range_type is group.`);
4915
+ }
4675
4916
  }
4676
- if (rawType === "fieldvalue" && (typeof node.auto_range_by_script !== "string" || !node.auto_range_by_script.trim())) {
4677
- errors.push(`${nodeName}.auto_range_by_script is required when auto_range_type is fieldvalue.`);
4917
+ if (rawType === "fieldvalue" && !isUsableFlowTemplateScript(node.auto_range_by_script)) {
4918
+ errors.push(`${nodeName}.auto_range_by_script must be a non-placeholder script when auto_range_type is fieldvalue.`);
4678
4919
  }
4679
- if (rawType === "matrix" && !isRecord3(node.matrix_owner)) {
4680
- errors.push(`${nodeName}.matrix_owner is required when auto_range_type is matrix.`);
4920
+ if (rawType === "matrix") {
4921
+ validateFlowTemplateMatrixConfig(node.matrix_owner, `${nodeName}.matrix_owner`, errors);
4681
4922
  }
4682
4923
  if (rawType === "leader") {
4683
- const hasLegacyLeaderConfig = Boolean(node.leader_match_method || node.auto_range_by_step_owner_group_leader || node.leader_form_field_key || node.leader_rules);
4684
- if (!hasLegacyLeaderConfig) {
4685
- errors.push(`${nodeName}.leader_rules or leader_* config is required when auto_range_type is leader.`);
4686
- }
4924
+ validateFlowTemplateLeaderRules(node, nodeName, errors);
4687
4925
  }
4688
4926
  if (rawType === "continuous_leader") {
4689
- const hasContinuousConfig = Boolean(node.continuous_match_method || node.continuous_step_id || node.continuous_form_field_key);
4690
- if (!hasContinuousConfig) {
4691
- errors.push(`${nodeName}.continuous_* config is required when auto_range_type is continuous_leader.`);
4692
- }
4927
+ validateFlowTemplateContinuousLeader(node, nodeName, errors);
4693
4928
  }
4694
4929
  }
4695
4930
  function validateFlowTemplateApproveActionShape(value, errors) {
@@ -16302,13 +16537,29 @@ function assertProjectSearchBody(value) {
16302
16537
  );
16303
16538
  }
16304
16539
  }
16540
+ function withProjectListPagination(body, options) {
16541
+ const data = { ...body };
16542
+ if (options.pageExplicit || data.page === void 0) {
16543
+ data.page = Number(options.page);
16544
+ }
16545
+ if (options.pageSizeExplicit || data.page_size === void 0) {
16546
+ data.page_size = Number(options.pageSize);
16547
+ }
16548
+ return data;
16549
+ }
16305
16550
 
16306
16551
  // src/commands/es.ts
16307
16552
  function registerEsCommands(program2) {
16308
16553
  const es = program2.command("es").description("Fast ES-backed data queries");
16309
- es.command("project-search").description("Compatibility alias for project search through huanpingtong /api/project/list ES mode").option("--profile <profile>", "Profile name").option("--page <page>", "Page number for project-list payloads", "1").option("--page-size <pageSize>", "Page size for project-list payloads", "20").requiredOption("--body <json>", "Project list body JSON or @file").option("--format <format>", "Output format", "json").action(async (options) => {
16554
+ es.command("project-search").description("Compatibility alias for project search through huanpingtong /api/project/list ES mode").option("--profile <profile>", "Profile name").option("--page <page>", "Page number for project-list payloads", "1").option("--page-size <pageSize>", "Page size for project-list payloads", "20").requiredOption("--body <json>", "Project list body JSON or @file").option("--format <format>", "Output format", "json").action(async (options, command) => {
16310
16555
  const body = await parseJsonInput(options.body, "--body");
16311
16556
  assertProjectSearchBody(body);
16557
+ const data = withProjectListPagination(body, {
16558
+ page: options.page,
16559
+ pageSize: options.pageSize,
16560
+ pageExplicit: command.getOptionValueSource("page") === "cli",
16561
+ pageSizeExplicit: command.getOptionValueSource("pageSize") === "cli"
16562
+ });
16312
16563
  const config = await loadConfig();
16313
16564
  const profile = resolveProfile(config, options.profile);
16314
16565
  const client = createApiClient(profile);
@@ -16317,11 +16568,7 @@ function registerEsCommands(program2) {
16317
16568
  "POST",
16318
16569
  "/project/list",
16319
16570
  {
16320
- params: {
16321
- page: Number(options.page),
16322
- page_size: Number(options.pageSize)
16323
- },
16324
- data: body,
16571
+ data,
16325
16572
  preserveErrorBody: true,
16326
16573
  capability: "project.search"
16327
16574
  }
@@ -18003,9 +18250,15 @@ async function buildApprovalContext(client, projectId, options) {
18003
18250
  }
18004
18251
  function registerProjectCommands(program2) {
18005
18252
  const project = program2.command("project").description("Project commands");
18006
- project.command("search").description("Search projects through huanpingtong /api/project/list ES mode").option("--profile <profile>", "Profile name").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").requiredOption("--body <json>", "Project search body JSON or @file").option("--format <format>", "Output format", "json").action(async (options) => {
18253
+ project.command("search").description("Search projects through huanpingtong /api/project/list ES mode").option("--profile <profile>", "Profile name").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").requiredOption("--body <json>", "Project search body JSON or @file").option("--format <format>", "Output format", "json").action(async (options, command) => {
18007
18254
  const body = await parseJsonInput(options.body, "--body");
18008
18255
  assertProjectSearchBody(body);
18256
+ const data = withProjectListPagination(body, {
18257
+ page: options.page,
18258
+ pageSize: options.pageSize,
18259
+ pageExplicit: command.getOptionValueSource("page") === "cli",
18260
+ pageSizeExplicit: command.getOptionValueSource("pageSize") === "cli"
18261
+ });
18009
18262
  const config = await loadConfig();
18010
18263
  const profile = resolveProfile(config, options.profile);
18011
18264
  const result = await apiRequest(
@@ -18013,31 +18266,27 @@ function registerProjectCommands(program2) {
18013
18266
  "POST",
18014
18267
  "/project/list",
18015
18268
  {
18016
- params: {
18017
- page: Number(options.page),
18018
- page_size: Number(options.pageSize)
18019
- },
18020
- data: body,
18269
+ data,
18021
18270
  preserveErrorBody: true,
18022
18271
  capability: "project.search"
18023
18272
  }
18024
18273
  );
18025
18274
  printResult(options.format, result);
18026
18275
  });
18027
- project.command("list").description("List projects").option("--profile <profile>", "Profile name").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").option("--body <json>", "Project list body JSON", "{}").option("--format <format>", "Output format", "table").action(async (options) => {
18276
+ project.command("list").description("List projects").option("--profile <profile>", "Profile name").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").option("--body <json>", "Project list body JSON", "{}").option("--format <format>", "Output format", "table").action(async (options, command) => {
18028
18277
  const config = await loadConfig();
18029
18278
  const profile = resolveProfile(config, options.profile);
18279
+ const data = withProjectListPagination(await parseProjectJson(options.body, "--body"), {
18280
+ page: options.page,
18281
+ pageSize: options.pageSize,
18282
+ pageExplicit: command.getOptionValueSource("page") === "cli",
18283
+ pageSizeExplicit: command.getOptionValueSource("pageSize") === "cli"
18284
+ });
18030
18285
  const result = await apiRequest(
18031
18286
  createApiClient(profile),
18032
18287
  "POST",
18033
18288
  "/project/list",
18034
- {
18035
- params: {
18036
- page: Number(options.page),
18037
- page_size: Number(options.pageSize)
18038
- },
18039
- data: await parseProjectJson(options.body, "--body")
18040
- }
18289
+ { data }
18041
18290
  );
18042
18291
  printResult(options.format, result);
18043
18292
  });