bpmax-cli 0.1.20 → 0.1.21

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
@@ -135,10 +135,12 @@ Use `--flow-key` when the target flow has a non-empty key. `--flow-step-id` maps
135
135
  Create a project with an interactive form guide:
136
136
 
137
137
  ```bash
138
- bpmax-cli project create --profile yuanrong --flow-id 123 --interactive --format json
138
+ bpmax-cli project create --profile yuanrong --flow-id 123 --format json
139
139
  ```
140
140
 
141
- During the guide, choose "打开 BPMAX 表单页继续填写" to hand off to the web form. The CLI prints a PC URL and mobile path with the fields already entered encoded in `init_value`.
141
+ `project create` uses the interactive guide by default. During the guide, choose "打开 BPMAX 表单页继续填写" to hand off to the web form. The CLI prints a PC URL and mobile path with the fields already entered encoded in `init_value`.
142
+
143
+ Use `--no-interactive` only for explicit direct-submit automation. If the target form template contains auto-init lambda scripts, the CLI still refuses direct submit and prints a web form handoff URL with `reason: "form_template_auto_init_lambda"`.
142
144
 
143
145
  ## ES fast queries
144
146
 
package/dist/bin.js CHANGED
@@ -812,7 +812,7 @@ function registerFlowCommands(program2) {
812
812
  // package.json
813
813
  var package_default = {
814
814
  name: "bpmax-cli",
815
- version: "0.1.20",
815
+ version: "0.1.21",
816
816
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
817
817
  type: "module",
818
818
  bin: {
@@ -1880,13 +1880,15 @@ function registerProjectCommands(program2) {
1880
1880
  );
1881
1881
  printResult(options.format, result);
1882
1882
  });
1883
- project.command("create").description("Minimal project create shortcut").option("--profile <profile>", "Profile name").option("--flow-id <flowId>", "Flow id").option("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key").option("--name <name>", "Project name").option("--json <json>", "Additional request JSON").option("--body <body>", "Full request body JSON override").option("--interactive", "Guide the user through filling project form fields").option("--allow-form-handoff", "Allow interactive mode to hand off to the BPMAX web create form").option("--skip-form-validation", "Skip local form schema validation before submit").option("--format <format>", "Output format", "pretty").action(async (options) => {
1884
- if (options.body && options.interactive) {
1883
+ project.command("create").description("Minimal project create shortcut").option("--profile <profile>", "Profile name").option("--flow-id <flowId>", "Flow id").option("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key").option("--name <name>", "Project name").option("--json <json>", "Additional request JSON").option("--body <body>", "Full request body JSON override").option("--interactive", "Guide the user through filling project form fields").option("--no-interactive", "Disable the project create guide and submit directly when safe").option("--allow-form-handoff", "Allow interactive mode to hand off to the BPMAX web create form").option("--skip-form-validation", "Skip local form schema validation before submit").option("--format <format>", "Output format", "pretty").action(async (options, command) => {
1884
+ const interactiveSource = command.getOptionValueSource("interactive");
1885
+ if (options.body && options.interactive === true && interactiveSource === "cli") {
1885
1886
  throw new Error("--body and --interactive cannot be used together.");
1886
1887
  }
1887
1888
  const config = await loadConfig();
1888
1889
  const profile = resolveProfile(config, options.profile);
1889
1890
  const client = createApiClient(profile);
1891
+ const useInteractive = !options.body && options.interactive !== false;
1890
1892
  let payload = parseJson2(options.body);
1891
1893
  if (!options.body) {
1892
1894
  const flow = await resolveFlowIdentifiers(client, options);
@@ -1894,10 +1896,16 @@ function registerProjectCommands(program2) {
1894
1896
  const extra = parseJson2(options.json);
1895
1897
  const form = typeof extra.form === "object" && extra.form !== null && !Array.isArray(extra.form) ? extra.form : {};
1896
1898
  let name = options.name;
1897
- let interactiveTemplate;
1898
- if (options.interactive) {
1899
+ let projectFormTemplate;
1900
+ const loadProjectFormTemplate = async () => {
1901
+ if (projectFormTemplate === void 0) {
1902
+ projectFormTemplate = await fetchProjectFormTemplate(client, flowDetail);
1903
+ }
1904
+ return projectFormTemplate;
1905
+ };
1906
+ if (useInteractive) {
1899
1907
  if (!flowDetail) {
1900
- throw new Error("--interactive requires --flow-id so the form schema can be discovered.");
1908
+ throw new Error("Interactive project creation requires --flow-id so the form schema can be discovered.");
1901
1909
  }
1902
1910
  const fields = extractFormFields(flowDetail);
1903
1911
  const promptResult = await promptProjectCreateForm({
@@ -1915,8 +1923,8 @@ function registerProjectCommands(program2) {
1915
1923
  printResult(options.format, { cancelled: true });
1916
1924
  return;
1917
1925
  }
1918
- interactiveTemplate = await fetchProjectFormTemplate(client, flowDetail);
1919
- if (interactiveTemplate && hasAutoInitLambda(interactiveTemplate.template)) {
1926
+ projectFormTemplate = await loadProjectFormTemplate();
1927
+ if (projectFormTemplate && hasAutoInitLambda(projectFormTemplate.template)) {
1920
1928
  printCreateFormHandoff(options.format, profile, flowIdentifiers, {
1921
1929
  name,
1922
1930
  form,
@@ -1940,6 +1948,16 @@ function registerProjectCommands(program2) {
1940
1948
  if (!name) {
1941
1949
  throw new Error("--name is required unless --body is provided.");
1942
1950
  }
1951
+ projectFormTemplate = await loadProjectFormTemplate();
1952
+ if (projectFormTemplate && hasAutoInitLambda(projectFormTemplate.template)) {
1953
+ printCreateFormHandoff(options.format, profile, flowIdentifiers, {
1954
+ name,
1955
+ form,
1956
+ reason: "form_template_auto_init_lambda",
1957
+ message: "\u68C0\u6D4B\u5230\u8868\u5355\u6A21\u677F\u5305\u542B\u81EA\u52A8\u521D\u59CB\u5316\u811A\u672C\uFF0C\u5DF2\u751F\u6210 BPMAX \u521B\u5EFA\u9875\u94FE\u63A5\uFF0C\u8BF7\u70B9\u51FB\u7EE7\u7EED\u586B\u5199\u5E76\u63D0\u4EA4\u3002"
1958
+ });
1959
+ return;
1960
+ }
1943
1961
  const { form: _rawForm, ...projectExtra } = extra;
1944
1962
  const { flow_key: flowKey, ...projectFlowIdentifiers } = flowIdentifiers;
1945
1963
  payload = {
@@ -1948,7 +1966,7 @@ function registerProjectCommands(program2) {
1948
1966
  key: flowKey,
1949
1967
  name,
1950
1968
  workspace: profile.config.workspace,
1951
- ...projectExtra.projectForm ? {} : await buildProjectFormPayload(client, flowDetail, form, interactiveTemplate)
1969
+ ...projectExtra.projectForm ? {} : await buildProjectFormPayload(client, flowDetail, form, projectFormTemplate)
1952
1970
  };
1953
1971
  if (!options.skipFormValidation) {
1954
1972
  await validateCreateForm(client, { flowId: options.flowId, flowDetail, form });