bpmax-cli 0.1.44-beta.21 → 0.1.44-beta.22

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
@@ -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.1.44-beta.21",
472
+ version: "0.1.44-beta.22",
473
473
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
474
474
  type: "module",
475
475
  bin: {
@@ -5386,6 +5386,25 @@ function parseMaybeJsonObject(value, fallback) {
5386
5386
  }
5387
5387
  return fallback;
5388
5388
  }
5389
+ function parseNavConfigContent(type, value) {
5390
+ if (isRecord3(value)) {
5391
+ return value;
5392
+ }
5393
+ if (typeof value === "string") {
5394
+ const raw = value.trim();
5395
+ if (!raw) {
5396
+ return {};
5397
+ }
5398
+ try {
5399
+ const parsed = JSON.parse(raw);
5400
+ if (isRecord3(parsed)) {
5401
+ return parsed;
5402
+ }
5403
+ } catch {
5404
+ }
5405
+ }
5406
+ throw new Error(`nav-config ${type} content must be a JSON object or a JSON object string.`);
5407
+ }
5389
5408
  function extractListData(value) {
5390
5409
  if (Array.isArray(value)) {
5391
5410
  return value.filter(isRecord3);
@@ -5732,7 +5751,7 @@ async function collectApiPlatformAggregate(profile, id) {
5732
5751
  function extractNavConfigDetail(type, response) {
5733
5752
  const records = extractListData(response);
5734
5753
  const detail = records.find((item) => item.type === type) || records[0] || {};
5735
- const content = isRecord3(detail.content) ? detail.content : {};
5754
+ const content = detail.content === void 0 || detail.content === null ? {} : parseNavConfigContent(type, detail.content);
5736
5755
  const contentKey = NAV_CONTENT_KEY_BY_TYPE[type];
5737
5756
  const items = Array.isArray(content[contentKey]) ? content[contentKey] : [];
5738
5757
  return {
@@ -5750,7 +5769,7 @@ function extractNavConfigDetail(type, response) {
5750
5769
  }
5751
5770
  function navConfigItemsForType(type, config) {
5752
5771
  const contentKey = NAV_CONTENT_KEY_BY_TYPE[type];
5753
- const content = isRecord3(config.content) ? config.content : {};
5772
+ const content = config.content === void 0 || config.content === null ? {} : parseNavConfigContent(type, config.content);
5754
5773
  const hasItems = Array.isArray(config.items);
5755
5774
  const hasContentItems = Array.isArray(content[contentKey]);
5756
5775
  if (hasItems && hasContentItems && JSON.stringify(config.items) !== JSON.stringify(content[contentKey])) {
@@ -5800,6 +5819,7 @@ function buildNavConfigSubmitPayload(work, raw, options = {}) {
5800
5819
  type,
5801
5820
  method: hasId ? "PUT" : "POST",
5802
5821
  path: hasId ? `/configuration/${payload.id}?is_default_action=1` : "/configuration?is_default_action=1",
5822
+ params: work.workspace ? { $workspace: work.workspace } : void 0,
5803
5823
  id: hasId ? payload.id : null,
5804
5824
  payload
5805
5825
  };
@@ -6272,12 +6292,50 @@ async function submitOperationPlan(profile, capabilityPrefix, operations) {
6272
6292
  op.path,
6273
6293
  {
6274
6294
  data: op.method === "DELETE" ? void 0 : op.payload,
6295
+ params: isRecord3(op.params) ? op.params : void 0,
6275
6296
  capability: op.method === "POST" ? `${capabilityPrefix}.create` : op.method === "DELETE" ? `${capabilityPrefix}.delete` : `${capabilityPrefix}.submit`
6276
6297
  }
6277
6298
  ));
6278
6299
  }
6279
6300
  return responses;
6280
6301
  }
6302
+ function navConfigComparable(value) {
6303
+ return {
6304
+ type: value.type,
6305
+ name: value.name,
6306
+ content: value.content
6307
+ };
6308
+ }
6309
+ function navConfigItemCount(value) {
6310
+ const type = value.type;
6311
+ if (!NAV_CONFIG_TYPES.includes(type)) {
6312
+ return 0;
6313
+ }
6314
+ const contentKey = NAV_CONTENT_KEY_BY_TYPE[type];
6315
+ const content = isRecord3(value.content) ? value.content : {};
6316
+ return Array.isArray(content[contentKey]) ? content[contentKey].length : 0;
6317
+ }
6318
+ function assertNavConfigReadbackMatchesOperations(submitPayload, readbackRaw) {
6319
+ const operations = Array.isArray(submitPayload.operations) ? submitPayload.operations : [];
6320
+ const readbackConfigs = isRecord3(readbackRaw.configs) ? readbackRaw.configs : {};
6321
+ for (const op of operations) {
6322
+ if (!isRecord3(op) || op.method === "DELETE") {
6323
+ continue;
6324
+ }
6325
+ const type = op.type;
6326
+ if (!NAV_CONFIG_TYPES.includes(type) || !isRecord3(op.payload)) {
6327
+ continue;
6328
+ }
6329
+ const navType = type;
6330
+ const actualConfig = isRecord3(readbackConfigs[navType]) ? readbackConfigs[navType] : {};
6331
+ const actualPayload = navConfigToSubmitRecord(navType, actualConfig);
6332
+ if (hashJson(navConfigComparable(actualPayload)) !== hashJson(navConfigComparable(op.payload))) {
6333
+ throw new Error(
6334
+ `nav-config submit verification failed for ${navType}: readback content does not match submitted payload (expected items=${navConfigItemCount(op.payload)}, actual items=${navConfigItemCount(actualPayload)}). Re-export before retrying; do not continue submitting this payload.`
6335
+ );
6336
+ }
6337
+ }
6338
+ }
6281
6339
  async function submitAggregateConfigDomain(profile, domain, id, submit) {
6282
6340
  const payload = submit.payload;
6283
6341
  if (!isRecord3(payload) || !Array.isArray(payload.operations)) {
@@ -6291,6 +6349,9 @@ async function submitAggregateConfigDomain(profile, domain, id, submit) {
6291
6349
  };
6292
6350
  }
6293
6351
  const current = domain === "api-platform" ? await collectApiPlatformAggregate(profile, id) : await collectNavConfigAggregate(profile, id);
6352
+ if (domain === "nav-config") {
6353
+ assertNavConfigReadbackMatchesOperations(payload, current.raw);
6354
+ }
6294
6355
  return {
6295
6356
  operation_responses: responses,
6296
6357
  readback_hash: hashJson(current.raw)