bpmax-cli 0.1.22 → 0.1.24

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/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.22",
815
+ version: "0.1.24",
816
816
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
817
817
  type: "module",
818
818
  bin: {
@@ -1803,23 +1803,53 @@ async function validateCreateForm(client, options) {
1803
1803
  }
1804
1804
  }
1805
1805
  function printCreateFormHandoff(format, profile, flowIdentifiers, options) {
1806
+ const initValue = {
1807
+ project: { name: options.name },
1808
+ key_to_value: options.form
1809
+ };
1806
1810
  const url = buildBpmaxUrl(profile, "project-create", {
1807
1811
  flowType: flowIdentifiers.flow_type,
1808
1812
  flowKey: flowIdentifiers.flow_key,
1809
- initValue: {
1810
- project: { name: options.name },
1811
- key_to_value: options.form
1812
- }
1813
+ initValue
1813
1814
  });
1815
+ assertCreateFormHandoffUrl(url, initValue, Object.keys(options.form));
1814
1816
  printResult(format, {
1815
1817
  handoff: true,
1816
1818
  ...options.reason ? { reason: options.reason } : {},
1817
1819
  url: url.url,
1818
1820
  pc_url: url.pc_url,
1819
1821
  mobile_path: url.mobile_path,
1822
+ init_value: initValue,
1823
+ init_value_keys: Object.keys(options.form),
1820
1824
  message: options.message
1821
1825
  });
1822
1826
  }
1827
+ function parseInitValueFromUrl(rawUrl) {
1828
+ const base = rawUrl.startsWith("http") ? void 0 : "https://bpmax.local";
1829
+ const initValue = new URL(rawUrl, base).searchParams.get("init_value");
1830
+ if (!initValue) {
1831
+ return void 0;
1832
+ }
1833
+ return JSON.parse(initValue);
1834
+ }
1835
+ function assertCreateFormHandoffUrl(url, expectedInitValue, expectedFormKeys) {
1836
+ const targets = [url.url, url.pc_url, url.mobile_path].filter((item) => Boolean(item));
1837
+ for (const target of targets) {
1838
+ const initValue = parseInitValueFromUrl(target);
1839
+ const keyToValue = initValue?.key_to_value;
1840
+ if (!initValue || typeof keyToValue !== "object" || keyToValue === null || Array.isArray(keyToValue)) {
1841
+ throw new Error("Generated project create handoff URL is missing init_value.key_to_value; refusing to output an un-prefilled link.");
1842
+ }
1843
+ const missingKeys = expectedFormKeys.filter((key) => !Object.prototype.hasOwnProperty.call(keyToValue, key));
1844
+ if (missingKeys.length > 0) {
1845
+ throw new Error(`Generated project create handoff URL is missing prefilled form keys: ${missingKeys.join(", ")}`);
1846
+ }
1847
+ }
1848
+ const encoded = JSON.stringify(expectedInitValue);
1849
+ if (!url.url.includes("init_value=") || !url.pc_url?.includes("init_value=") || !url.mobile_path?.includes("init_value=")) {
1850
+ throw new Error(`Generated project create handoff URL did not include init_value (${encoded.length} bytes).`);
1851
+ }
1852
+ }
1823
1853
  function isEmptyFormValue(value) {
1824
1854
  return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
1825
1855
  }