bpmax-cli 0.2.1-beta.18 → 0.2.1-beta.19

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.2.1-beta.18",
472
+ version: "0.2.1-beta.19",
473
473
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
474
474
  type: "module",
475
475
  bin: {
@@ -6071,6 +6071,103 @@ function validateFormTemplateValueValidateMaps(payload, errors) {
6071
6071
  }
6072
6072
  }
6073
6073
  }
6074
+ function formTemplateControlOptions(rule, value) {
6075
+ const candidates = [
6076
+ rule?.options,
6077
+ isRecord3(rule?.props) ? rule.props.options : void 0,
6078
+ value?.options,
6079
+ isRecord3(value?.value) ? value.value.options : void 0,
6080
+ isRecord3(value?.props) ? value.props.options : void 0
6081
+ ];
6082
+ for (const candidate of candidates) {
6083
+ if (Array.isArray(candidate)) {
6084
+ return candidate;
6085
+ }
6086
+ }
6087
+ return [];
6088
+ }
6089
+ function formTemplateControlValueType(rule, value) {
6090
+ if (value && Object.prototype.hasOwnProperty.call(value, "value_type")) {
6091
+ return value.value_type;
6092
+ }
6093
+ if (rule && Object.prototype.hasOwnProperty.call(rule, "value_type")) {
6094
+ return rule.value_type;
6095
+ }
6096
+ if (value && isRecord3(value.value) && Object.prototype.hasOwnProperty.call(value.value, "value_type")) {
6097
+ return value.value.value_type;
6098
+ }
6099
+ return void 0;
6100
+ }
6101
+ function validateRadioFormTemplateControl(field, rule, value, errors) {
6102
+ const options = formTemplateControlOptions(rule, value);
6103
+ if (!options.length) {
6104
+ errors.push(`form-template radio field ${field} must include non-empty options on rule/value before build/submit.`);
6105
+ }
6106
+ for (const [index, option] of options.entries()) {
6107
+ if (!isRecord3(option)) {
6108
+ errors.push(`form-template radio field ${field} options[${index}] must be an object with label/value.`);
6109
+ continue;
6110
+ }
6111
+ const hasLabel = typeof option.label === "string" && option.label.length > 0 || typeof option.title === "string" && option.title.length > 0;
6112
+ const hasValue = Object.prototype.hasOwnProperty.call(option, "value") || Object.prototype.hasOwnProperty.call(option, "key");
6113
+ if (!hasLabel || !hasValue) {
6114
+ errors.push(`form-template radio field ${field} options[${index}] must include label and value.`);
6115
+ }
6116
+ }
6117
+ const valueType = formTemplateControlValueType(rule, value);
6118
+ if (valueType === void 0) {
6119
+ errors.push(`form-template radio field ${field} must include value_type=string.`);
6120
+ } else if (valueType !== "string") {
6121
+ errors.push(`form-template radio field ${field} value_type must be string.`);
6122
+ }
6123
+ const validateMap = value?.validateMap;
6124
+ if (!isRecord3(validateMap) || !Object.prototype.hasOwnProperty.call(validateMap, "required")) {
6125
+ errors.push(`form-template radio field ${field} must include value.validateMap.required.`);
6126
+ }
6127
+ }
6128
+ function validateFormTemplateControlContracts(payload, errors) {
6129
+ const validatePair = (field, rule, value) => {
6130
+ const type = typeof rule?.type === "string" ? rule.type : typeof value?.field_type === "string" ? value.field_type : "";
6131
+ if (type === "serial_number") {
6132
+ errors.push(`form-template field ${field} uses legacy serial_number; use BPMAX frontend control type sn_number.`);
6133
+ }
6134
+ if (type === "sn_number") {
6135
+ return;
6136
+ }
6137
+ if (type === "radio") {
6138
+ validateRadioFormTemplateControl(field, rule, value, errors);
6139
+ }
6140
+ };
6141
+ if (isRecord3(payload.fields)) {
6142
+ for (const [field, bundle] of Object.entries(payload.fields)) {
6143
+ if (!isRecord3(bundle)) {
6144
+ continue;
6145
+ }
6146
+ validatePair(field, isRecord3(bundle.rule) ? bundle.rule : void 0, isRecord3(bundle.value) ? bundle.value : void 0);
6147
+ }
6148
+ }
6149
+ const rawValueByField = /* @__PURE__ */ new Map();
6150
+ if (Array.isArray(payload.value)) {
6151
+ for (const item of payload.value) {
6152
+ if (isRecord3(item) && typeof item.field === "string" && item.field) {
6153
+ rawValueByField.set(item.field, item);
6154
+ }
6155
+ }
6156
+ }
6157
+ if (Array.isArray(payload.rule)) {
6158
+ for (const row of payload.rule) {
6159
+ if (!Array.isArray(row)) {
6160
+ continue;
6161
+ }
6162
+ for (const item of row) {
6163
+ if (!isRecord3(item) || typeof item.field !== "string" || !item.field) {
6164
+ continue;
6165
+ }
6166
+ validatePair(item.field, item, rawValueByField.get(item.field));
6167
+ }
6168
+ }
6169
+ }
6170
+ }
6074
6171
  var FORM_TEMPLATE_VISUAL_WIDE_TYPES = /* @__PURE__ */ new Set([
6075
6172
  "sub_form",
6076
6173
  "i_textarea",
@@ -6181,6 +6278,7 @@ function validateStructuredFormTemplateVisualReview(payload, errors) {
6181
6278
  function validateFormTemplateWorkLint(payload, errors) {
6182
6279
  validateFormTemplateNameLength(payload, errors);
6183
6280
  validateFormTemplateValueValidateMaps(payload, errors);
6281
+ validateFormTemplateControlContracts(payload, errors);
6184
6282
  validateStructuredFormTemplateVisualReview(payload, errors);
6185
6283
  }
6186
6284
  function stripFormTemplateCreateIds(payload) {
@@ -7478,6 +7576,11 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
7478
7576
  if (!isRecord3(formWork) || formWork.mode !== "create") {
7479
7577
  throw new Error("flow-app create requires form work with mode=create.");
7480
7578
  }
7579
+ const formLintErrors = [];
7580
+ validateFormTemplateWorkLint(formWork, formLintErrors);
7581
+ if (formLintErrors.length) {
7582
+ throw new Error(`form-template lint failed: ${formLintErrors.join("; ")}`);
7583
+ }
7481
7584
  const formPayload = buildDomainSubmitPayload("form-template", formWork);
7482
7585
  const flowWorkRecord = isRecord3(flowWork) ? flowWork : {};
7483
7586
  validateFlowTemplateRemoteTemplateRefs(flowWorkRecord);
@@ -14084,7 +14187,7 @@ function isRiskyFormField(field) {
14084
14187
  const type = field.type?.toLowerCase() ?? "";
14085
14188
  const label = field.label?.toLowerCase() ?? "";
14086
14189
  const key = field.key.toLowerCase();
14087
- return /(serial|sequence|auto[_-]?number|auto[_-]?no|流水|编号)/.test(`${type} ${label} ${key}`) || /(plugin_|selector|upload|rich[_-]?text|editor|relation[_-]?project|relation[_-]?form|associated[_-]?form|sub[_-]?form|table)/.test(type);
14190
+ return type === "sn_number" || /(serial|sequence|auto[_-]?number|auto[_-]?no|流水|编号)/.test(`${type} ${label} ${key}`) || /(plugin_|selector|upload|rich[_-]?text|editor|relation[_-]?project|relation[_-]?form|associated[_-]?form|sub[_-]?form|table)/.test(type);
14088
14191
  }
14089
14192
  function collectHandoffReasons(fields, template) {
14090
14193
  const reasons = /* @__PURE__ */ new Set();