bpmax-cli 0.2.1-beta.46 → 0.2.1-beta.47

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
@@ -496,7 +496,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
496
496
  // package.json
497
497
  var package_default = {
498
498
  name: "bpmax-cli",
499
- version: "0.2.1-beta.46",
499
+ version: "0.2.1-beta.47",
500
500
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
501
501
  type: "module",
502
502
  bin: {
@@ -8231,8 +8231,11 @@ function validateDatasetPayload(payload, mode) {
8231
8231
  if (mode === "create" && payload.id !== void 0 && payload.id !== null && String(payload.id).trim() !== "") {
8232
8232
  throw new Error("dataset create \u7981\u6B62\u643A\u5E26 payload.id\uFF1B\u6570\u636E\u96C6 ID \u5FC5\u987B\u7531\u5E73\u53F0\u751F\u6210\u3002");
8233
8233
  }
8234
- if (!Array.isArray(payload.fields) || payload.fields.length === 0) {
8235
- throw new Error(`dataset ${mode} requires at least one relationFields field key.`);
8234
+ if (!Array.isArray(payload.fields)) {
8235
+ throw new Error(`dataset ${mode} relationFields must be an array.`);
8236
+ }
8237
+ if (mode === "edit" && payload.fields.length === 0) {
8238
+ throw new Error("dataset edit requires at least one relationFields field key.");
8236
8239
  }
8237
8240
  const fieldKeys = payload.fields.filter((field) => typeof field === "string" && field.trim().length > 0);
8238
8241
  if (fieldKeys.length !== payload.fields.length || new Set(fieldKeys).size !== fieldKeys.length) {
@@ -8331,11 +8334,14 @@ function validateDatasetFieldCreatePayload(payload) {
8331
8334
  }
8332
8335
  const missingSource = [
8333
8336
  ["payload.flow_type", payload.flow_type],
8334
- ["payload.data_set_id", payload.data_set_id],
8335
8337
  ["payload.source_table", payload.source_table],
8336
8338
  ["payload.source_field", payload.source_field],
8337
8339
  ["payload.source_fk", payload.source_fk]
8338
8340
  ].filter(([, value]) => typeof value !== "string" || value.trim() === "");
8341
+ const datasetId = payload.data_set_id;
8342
+ if (datasetId === void 0 || datasetId === null || typeof datasetId === "string" && datasetId.trim() === "" || typeof datasetId !== "string" && (typeof datasetId !== "number" || !Number.isFinite(datasetId) || datasetId <= 0)) {
8343
+ missingSource.splice(1, 0, ["payload.data_set_id", datasetId]);
8344
+ }
8339
8345
  if (missingSource.length > 0) {
8340
8346
  throw new Error(`dataset-field create requires dataset and source mapping fields: ${missingSource.map(([key]) => key).join(", ")}.`);
8341
8347
  }
@@ -13895,18 +13901,97 @@ async function runDatasetLifecycleAction(config, profile, action, id, confirm3)
13895
13901
  const currentStatus = isRecord3(current) ? Number(current.status) : NaN;
13896
13902
  const executableOperations = normalizedAction === "refresh" && currentStatus !== 1 && currentStatus !== 3 ? operations.filter((operation) => operation.action !== "pause") : operations;
13897
13903
  const responses = [];
13904
+ let mutationError;
13905
+ let failedOperation;
13898
13906
  for (const operation of executableOperations) {
13899
- responses.push({
13900
- action: operation.action,
13901
- response: await apiRequest(
13902
- client,
13903
- operation.method,
13904
- operation.endpoint,
13905
- { data: {}, capability: operation.capability }
13906
- )
13907
- });
13907
+ try {
13908
+ responses.push({
13909
+ action: operation.action,
13910
+ status: "completed",
13911
+ response: await apiRequest(
13912
+ client,
13913
+ operation.method,
13914
+ operation.endpoint,
13915
+ { data: {}, capability: operation.capability }
13916
+ )
13917
+ });
13918
+ } catch (error) {
13919
+ mutationError = error;
13920
+ failedOperation = operation;
13921
+ responses.push({
13922
+ action: operation.action,
13923
+ status: "request_failed",
13924
+ error: error instanceof Error ? error.message : String(error ?? ""),
13925
+ http_status: errorStatus(error) ?? null
13926
+ });
13927
+ break;
13928
+ }
13929
+ }
13930
+ let readback;
13931
+ let readbackError;
13932
+ try {
13933
+ readback = await readRemoteConfigDomain(profile, "dataset", id, definition);
13934
+ } catch (error) {
13935
+ readbackError = error;
13936
+ }
13937
+ const readbackStatus = isRecord3(readback) ? Number(readback.status) : NaN;
13938
+ const targetConfirmed = Number.isFinite(readbackStatus) && (normalizedAction === "pause" && readbackStatus === 2 || normalizedAction === "cancel-refresh" && readbackStatus !== 3 || (normalizedAction === "publish" || normalizedAction === "refresh") && (readbackStatus === 1 || readbackStatus === 3));
13939
+ if (mutationError) {
13940
+ const evidence = {
13941
+ code: "config_dataset_lifecycle_failed",
13942
+ rule_id: "config.dataset.lifecycle.remote_mutation",
13943
+ domain: "dataset",
13944
+ id,
13945
+ action: commandAction,
13946
+ failed_operation: failedOperation?.action ?? null,
13947
+ operations: executableOperations,
13948
+ operation_responses: responses,
13949
+ remote_write_state: targetConfirmed ? "confirmed" : "uncertain",
13950
+ remote_submitted: targetConfirmed ? true : null,
13951
+ readback_confirmed: targetConfirmed,
13952
+ ...readback === void 0 ? {} : {
13953
+ readback_hash: hashJson(readback),
13954
+ readback
13955
+ },
13956
+ ...readbackError ? {
13957
+ readback_error: readbackError instanceof Error ? readbackError.message : String(readbackError ?? "")
13958
+ } : {},
13959
+ readback_hint: configReadbackHint("dataset", id),
13960
+ suggestion: targetConfirmed ? "\u56DE\u8BFB\u5DF2\u786E\u8BA4\u76EE\u6807\u72B6\u6001\uFF0C\u65E0\u9700\u76F2\u76EE\u91CD\u8BD5\u672C\u6B21\u751F\u547D\u5468\u671F\u547D\u4EE4\u3002" : `\u5148\u6267\u884C bpmax-cli config readback dataset --id ${id} --format json \u5BF9\u8D26\uFF1B\u786E\u8BA4\u5F53\u524D\u72B6\u6001\u540E\u518D\u51B3\u5B9A\u662F\u5426\u7EE7\u7EED\u3002`
13961
+ };
13962
+ if (targetConfirmed) {
13963
+ return {
13964
+ ...executedFields(),
13965
+ status: "reconciled",
13966
+ partial_success: false,
13967
+ ...evidence
13968
+ };
13969
+ }
13970
+ throw configWorkflowError(
13971
+ `dataset ${commandAction} \u8BF7\u6C42\u5931\u8D25\uFF0C\u8FDC\u7AEF\u5199\u5165\u72B6\u6001\u4E0D\u786E\u5B9A\uFF1B\u5728\u5B8C\u6210\u53EA\u8BFB\u56DE\u8BFB\u524D\u4E0D\u8981\u76F2\u76EE\u91CD\u8BD5\u3002`,
13972
+ evidence
13973
+ );
13974
+ }
13975
+ if (readbackError) {
13976
+ throw configWorkflowError(
13977
+ `dataset ${commandAction} \u8BF7\u6C42\u5DF2\u5B8C\u6210\uFF0C\u4F46\u7EC8\u6001\u56DE\u8BFB\u5931\u8D25\uFF1B\u8FDC\u7AEF\u72B6\u6001\u4E0D\u786E\u5B9A\u3002`,
13978
+ {
13979
+ code: "config_dataset_lifecycle_readback_failed",
13980
+ rule_id: "config.dataset.lifecycle.readback",
13981
+ domain: "dataset",
13982
+ id,
13983
+ action: commandAction,
13984
+ operations: executableOperations,
13985
+ operation_responses: responses,
13986
+ remote_write_state: "uncertain",
13987
+ remote_submitted: true,
13988
+ readback_confirmed: false,
13989
+ readback_error: readbackError instanceof Error ? readbackError.message : String(readbackError ?? ""),
13990
+ readback_hint: configReadbackHint("dataset", id),
13991
+ suggestion: `\u5148\u6267\u884C bpmax-cli config readback dataset --id ${id} --format json \u5BF9\u8D26\uFF0C\u4E0D\u8981\u76F4\u63A5\u91CD\u590D\u751F\u547D\u5468\u671F\u547D\u4EE4\u3002`
13992
+ }
13993
+ );
13908
13994
  }
13909
- const readback = await readRemoteConfigDomain(profile, "dataset", id, definition);
13910
13995
  return {
13911
13996
  ...executedFields(),
13912
13997
  domain: "dataset",
@@ -13914,6 +13999,8 @@ async function runDatasetLifecycleAction(config, profile, action, id, confirm3)
13914
13999
  action: commandAction,
13915
14000
  operations: executableOperations,
13916
14001
  operation_responses: responses,
14002
+ remote_write_state: "confirmed",
14003
+ readback_confirmed: true,
13917
14004
  readback_hash: hashJson(readback),
13918
14005
  readback_hint: configReadbackHint("dataset", id),
13919
14006
  readback