bpmax-cli 0.2.1-beta.32 → 0.2.1-beta.33
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
|
@@ -492,7 +492,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
|
|
|
492
492
|
// package.json
|
|
493
493
|
var package_default = {
|
|
494
494
|
name: "bpmax-cli",
|
|
495
|
-
version: "0.2.1-beta.
|
|
495
|
+
version: "0.2.1-beta.33",
|
|
496
496
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
497
497
|
type: "module",
|
|
498
498
|
bin: {
|
|
@@ -4281,6 +4281,7 @@ var NAV_DEFAULT_NAME_BY_TYPE = {
|
|
|
4281
4281
|
shortcut_mobile: "\u79FB\u52A8\u5FEB\u6377\u5165\u53E3"
|
|
4282
4282
|
};
|
|
4283
4283
|
var MAX_FORM_TEMPLATE_NAME_LENGTH = 20;
|
|
4284
|
+
var MAX_FORM_TEMPLATE_FIELD_LENGTH = 20;
|
|
4284
4285
|
var MAX_DATASET_CUSTOM_KEY_LENGTH = 20;
|
|
4285
4286
|
var MAX_PAGE_TEMPLATE_NAME_LENGTH = 20;
|
|
4286
4287
|
var FORM_TEMPLATE_ID_CONST_PATTERN = /\b(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:FORM|Form|form)[A-Za-z0-9_$]*(?:TEMPLATE|Template|template)[A-Za-z0-9_$]*(?:ID|Id|id)\s*=\s*\d+\b/;
|
|
@@ -5024,7 +5025,7 @@ async function lintFlowAppWorkFiles(formWorkFile, flowWorkFile, options = {}) {
|
|
|
5024
5025
|
} else if (formWork.mode !== "create") {
|
|
5025
5026
|
formErrors.push("flow-app create requires form work with mode=create.");
|
|
5026
5027
|
} else {
|
|
5027
|
-
validateFormTemplateWorkLint(formWork, formErrors);
|
|
5028
|
+
validateFormTemplateWorkLint(formWork, formErrors, warnings, "create");
|
|
5028
5029
|
}
|
|
5029
5030
|
if (!isRecord3(flowWork)) {
|
|
5030
5031
|
flowErrors.push("flow-app create requires flow work to be a JSON object.");
|
|
@@ -8307,34 +8308,50 @@ function formTemplateControlValueType(rule, value) {
|
|
|
8307
8308
|
}
|
|
8308
8309
|
return void 0;
|
|
8309
8310
|
}
|
|
8310
|
-
function validateRadioFormTemplateControl(field, rule, value, errors) {
|
|
8311
|
+
function validateRadioFormTemplateControl(field, rule, value, errors, warnings, mode) {
|
|
8311
8312
|
const options = formTemplateControlOptions(rule, value);
|
|
8312
8313
|
if (!options.length) {
|
|
8313
|
-
errors.push(`form
|
|
8314
|
+
errors.push(`[form.radio.options_required] \u5355\u9009\u5B57\u6BB5 ${field} \u5FC5\u987B\u5728 rule/value \u4E2D\u914D\u7F6E\u975E\u7A7A options\uFF0C\u624D\u80FD build/submit\u3002`);
|
|
8314
8315
|
}
|
|
8315
8316
|
for (const [index, option] of options.entries()) {
|
|
8316
8317
|
if (!isRecord3(option)) {
|
|
8317
|
-
errors.push(`form
|
|
8318
|
+
errors.push(`[form.radio.option_object] \u5355\u9009\u5B57\u6BB5 ${field} \u7684 options[${index}] \u5FC5\u987B\u662F\u5305\u542B label/value \u7684\u5BF9\u8C61\u3002`);
|
|
8318
8319
|
continue;
|
|
8319
8320
|
}
|
|
8320
8321
|
const hasLabel = typeof option.label === "string" && option.label.length > 0 || typeof option.title === "string" && option.title.length > 0;
|
|
8321
8322
|
const hasValue = Object.prototype.hasOwnProperty.call(option, "value") || Object.prototype.hasOwnProperty.call(option, "key");
|
|
8322
8323
|
if (!hasLabel || !hasValue) {
|
|
8323
|
-
errors.push(`form
|
|
8324
|
+
errors.push(`[form.radio.option_shape] \u5355\u9009\u5B57\u6BB5 ${field} \u7684 options[${index}] \u5FC5\u987B\u540C\u65F6\u5305\u542B label \u548C value\u3002`);
|
|
8324
8325
|
}
|
|
8325
8326
|
}
|
|
8326
8327
|
const valueType = formTemplateControlValueType(rule, value);
|
|
8327
8328
|
if (valueType === void 0) {
|
|
8328
|
-
errors.push(`form
|
|
8329
|
+
errors.push(`[form.radio.value_type_required] \u5355\u9009\u5B57\u6BB5 ${field} \u5FC5\u987B\u663E\u5F0F\u914D\u7F6E value_type=string\u3002`);
|
|
8329
8330
|
} else if (valueType !== "string") {
|
|
8330
|
-
errors.push(`form
|
|
8331
|
+
errors.push(`[form.radio.value_type] \u5355\u9009\u5B57\u6BB5 ${field} \u7684 value_type \u5FC5\u987B\u662F string\u3002`);
|
|
8331
8332
|
}
|
|
8332
8333
|
const validateMap = value?.validateMap;
|
|
8333
8334
|
if (!isRecord3(validateMap) || !Object.prototype.hasOwnProperty.call(validateMap, "required")) {
|
|
8334
|
-
errors.push(`form
|
|
8335
|
+
errors.push(`[form.radio.validate_required] \u5355\u9009\u5B57\u6BB5 ${field} \u5FC5\u987B\u914D\u7F6E value.validateMap.required\u3002`);
|
|
8336
|
+
}
|
|
8337
|
+
if (!rule || rule._fc_drag_tag !== "radio" || rule.name !== "radio") {
|
|
8338
|
+
errors.push(
|
|
8339
|
+
`[form.radio.runtime_contract] \u5355\u9009\u5B57\u6BB5 ${field} \u5FC5\u987B\u914D\u7F6E rule._fc_drag_tag=radio \u548C rule.name=radio\uFF1B\u7F3A\u5C11\u63A7\u4EF6\u8EAB\u4EFD\u65F6\u8FD0\u884C\u6001\u4F1A\u9519\u8BEF\u6E32\u67D3\u4E3A\u6587\u672C\u6846\u3002`
|
|
8340
|
+
);
|
|
8341
|
+
}
|
|
8342
|
+
if (rule?.defaultValueType !== "option") {
|
|
8343
|
+
const message = `[form.radio.default_value_type] \u5355\u9009\u5B57\u6BB5 ${field} \u5EFA\u8BAE\u914D\u7F6E rule.defaultValueType=option\uFF1B\u68C0\u6D4B\u5230 ${String(rule?.defaultValueType ?? "\u7F3A\u5931")}\u3002`;
|
|
8344
|
+
if (mode === "create") errors.push(message);
|
|
8345
|
+
else warnings.push(`${message} \u5386\u53F2 edit \u6A21\u677F\u6682\u4E0D\u963B\u65AD\uFF1B\u4FEE\u6539\u8BE5\u5B57\u6BB5\u65F6\u5E94\u540C\u6B65\u8FC1\u79FB\u3002`);
|
|
8346
|
+
}
|
|
8347
|
+
const persistedValue = value?.value;
|
|
8348
|
+
if (!isRecord3(persistedValue) || persistedValue.type !== "radio") {
|
|
8349
|
+
const message = `[form.radio.value_shape] \u5355\u9009\u5B57\u6BB5 ${field} \u5EFA\u8BAE\u5C06 value \u6301\u4E45\u5316\u4E3A { type: "radio", value?: <option> }\uFF1B\u68C0\u6D4B\u5230\u5386\u53F2\u6807\u91CF\u6216\u7A7A\u503C\u7ED3\u6784\u3002`;
|
|
8350
|
+
if (mode === "create") errors.push(message);
|
|
8351
|
+
else warnings.push(`${message} \u5386\u53F2 edit \u6A21\u677F\u6682\u4E0D\u963B\u65AD\uFF1B\u4FEE\u6539\u8BE5\u5B57\u6BB5\u65F6\u5E94\u540C\u6B65\u8FC1\u79FB\u3002`);
|
|
8335
8352
|
}
|
|
8336
8353
|
}
|
|
8337
|
-
function validateFormTemplateControlContracts(payload, errors) {
|
|
8354
|
+
function validateFormTemplateControlContracts(payload, errors, warnings, mode) {
|
|
8338
8355
|
const validatePair = (field, rule, value) => {
|
|
8339
8356
|
const type = typeof rule?.type === "string" ? rule.type : value ? formTemplateValueFieldType(value) : "";
|
|
8340
8357
|
if (type === "serial_number") {
|
|
@@ -8344,7 +8361,7 @@ function validateFormTemplateControlContracts(payload, errors) {
|
|
|
8344
8361
|
return;
|
|
8345
8362
|
}
|
|
8346
8363
|
if (type === "radio") {
|
|
8347
|
-
validateRadioFormTemplateControl(field, rule, value, errors);
|
|
8364
|
+
validateRadioFormTemplateControl(field, rule, value, errors, warnings, mode);
|
|
8348
8365
|
}
|
|
8349
8366
|
if (rule?.lambda === "ctx.userInfo?.name || ''") {
|
|
8350
8367
|
const props = isRecord3(rule.props) ? rule.props : {};
|
|
@@ -8533,13 +8550,392 @@ function validateStructuredFormTemplateVisualReview(payload, errors) {
|
|
|
8533
8550
|
}
|
|
8534
8551
|
}
|
|
8535
8552
|
}
|
|
8536
|
-
|
|
8553
|
+
var FORM_TEMPLATE_DYNAMIC_STATE_SPECS = [
|
|
8554
|
+
{
|
|
8555
|
+
kind: "visibility",
|
|
8556
|
+
enabledKey: "hasVisibilityCondition",
|
|
8557
|
+
configKey: "visibilityCondition",
|
|
8558
|
+
label: "\u52A8\u6001\u663E\u9690"
|
|
8559
|
+
},
|
|
8560
|
+
{
|
|
8561
|
+
kind: "disabled",
|
|
8562
|
+
enabledKey: "hasDisabledCondition",
|
|
8563
|
+
configKey: "disabledCondition",
|
|
8564
|
+
label: "\u52A8\u6001\u53EA\u8BFB"
|
|
8565
|
+
},
|
|
8566
|
+
{
|
|
8567
|
+
kind: "required",
|
|
8568
|
+
enabledKey: "hasRequiredCondition",
|
|
8569
|
+
configKey: "requiredCondition",
|
|
8570
|
+
label: "\u52A8\u6001\u5FC5\u586B"
|
|
8571
|
+
}
|
|
8572
|
+
];
|
|
8573
|
+
var FORM_TEMPLATE_CONDITION_LOGICS = /* @__PURE__ */ new Set(["AND", "OR"]);
|
|
8574
|
+
var FORM_TEMPLATE_CONDITION_OPERATORS = /* @__PURE__ */ new Set([
|
|
8575
|
+
"eq",
|
|
8576
|
+
"ne",
|
|
8577
|
+
"gt",
|
|
8578
|
+
"gte",
|
|
8579
|
+
"lt",
|
|
8580
|
+
"lte",
|
|
8581
|
+
"contains",
|
|
8582
|
+
"isEmpty",
|
|
8583
|
+
"isNotEmpty"
|
|
8584
|
+
]);
|
|
8585
|
+
var FORM_TEMPLATE_CONDITION_LEFT_TYPES = /* @__PURE__ */ new Set(["field", "variable"]);
|
|
8586
|
+
var FORM_TEMPLATE_CONDITION_RIGHT_TYPES = /* @__PURE__ */ new Set(["field", "variable", "constant"]);
|
|
8587
|
+
var FORM_TEMPLATE_CONDITION_UNARY_OPERATORS = /* @__PURE__ */ new Set(["isEmpty", "isNotEmpty"]);
|
|
8588
|
+
var FORM_TEMPLATE_DYNAMIC_REQUIRED_UNSUPPORTED_TYPES = /* @__PURE__ */ new Set([
|
|
8589
|
+
"raw",
|
|
8590
|
+
"label",
|
|
8591
|
+
"divider",
|
|
8592
|
+
"i_button",
|
|
8593
|
+
"button"
|
|
8594
|
+
]);
|
|
8595
|
+
function collectFormTemplateRuleEntries(payload) {
|
|
8596
|
+
const entries = [];
|
|
8597
|
+
const visited = /* @__PURE__ */ new Set();
|
|
8598
|
+
const visit = (value, pathName) => {
|
|
8599
|
+
if (Array.isArray(value)) {
|
|
8600
|
+
value.forEach((item, index) => visit(item, `${pathName}[${index}]`));
|
|
8601
|
+
return;
|
|
8602
|
+
}
|
|
8603
|
+
if (!isRecord3(value) || visited.has(value)) {
|
|
8604
|
+
return;
|
|
8605
|
+
}
|
|
8606
|
+
visited.add(value);
|
|
8607
|
+
const field = typeof value.field === "string" ? value.field.trim() : "";
|
|
8608
|
+
if (field) {
|
|
8609
|
+
entries.push({ field, path: pathName, rule: value });
|
|
8610
|
+
}
|
|
8611
|
+
for (const [key, child] of Object.entries(value)) {
|
|
8612
|
+
if (key === "visibilityCondition" || key === "disabledCondition" || key === "requiredCondition") {
|
|
8613
|
+
continue;
|
|
8614
|
+
}
|
|
8615
|
+
if (Array.isArray(child) || isRecord3(child)) {
|
|
8616
|
+
visit(child, `${pathName}.${key}`);
|
|
8617
|
+
}
|
|
8618
|
+
}
|
|
8619
|
+
};
|
|
8620
|
+
if (isRecord3(payload.fields)) {
|
|
8621
|
+
for (const [field, bundle] of Object.entries(payload.fields)) {
|
|
8622
|
+
if (!isRecord3(bundle) || !isRecord3(bundle.rule)) {
|
|
8623
|
+
continue;
|
|
8624
|
+
}
|
|
8625
|
+
visit(bundle.rule, `fields.${field}.rule`);
|
|
8626
|
+
}
|
|
8627
|
+
} else if (Array.isArray(payload.rule)) {
|
|
8628
|
+
visit(payload.rule, "rule");
|
|
8629
|
+
}
|
|
8630
|
+
return entries;
|
|
8631
|
+
}
|
|
8632
|
+
function formTemplateStaticRequiredFields(payload) {
|
|
8633
|
+
const required = /* @__PURE__ */ new Set();
|
|
8634
|
+
const addValue = (value) => {
|
|
8635
|
+
if (!isRecord3(value) || typeof value.field !== "string" || !isRecord3(value.validateMap)) {
|
|
8636
|
+
return;
|
|
8637
|
+
}
|
|
8638
|
+
if (value.validateMap.required === true) {
|
|
8639
|
+
required.add(value.field);
|
|
8640
|
+
}
|
|
8641
|
+
};
|
|
8642
|
+
if (Array.isArray(payload.value)) {
|
|
8643
|
+
payload.value.forEach(addValue);
|
|
8644
|
+
}
|
|
8645
|
+
if (isRecord3(payload.fields)) {
|
|
8646
|
+
Object.values(payload.fields).forEach((bundle) => {
|
|
8647
|
+
if (isRecord3(bundle)) {
|
|
8648
|
+
addValue(bundle.value);
|
|
8649
|
+
}
|
|
8650
|
+
});
|
|
8651
|
+
}
|
|
8652
|
+
if (isRecord3(payload.preserve) && Array.isArray(payload.preserve.value)) {
|
|
8653
|
+
payload.preserve.value.forEach(addValue);
|
|
8654
|
+
}
|
|
8655
|
+
return required;
|
|
8656
|
+
}
|
|
8657
|
+
function formTemplateConditionFieldReferences(expression) {
|
|
8658
|
+
const fields = /* @__PURE__ */ new Set();
|
|
8659
|
+
const pattern = /\$(?:formField|formDisplayField)(?:\[['"]([^'"]+)['"]\]|\.([A-Za-z0-9_]+))/g;
|
|
8660
|
+
let match;
|
|
8661
|
+
while ((match = pattern.exec(expression)) !== null) {
|
|
8662
|
+
const field = match[1] || match[2];
|
|
8663
|
+
if (field) {
|
|
8664
|
+
fields.add(field);
|
|
8665
|
+
}
|
|
8666
|
+
}
|
|
8667
|
+
return Array.from(fields);
|
|
8668
|
+
}
|
|
8669
|
+
function isSupportedFormTemplateConditionVariable(expression) {
|
|
8670
|
+
return /^\$(?:MOMENT|userInfo|formField|formDisplayField|RANGE)(?:\b|\.|\[|\()/.test(expression.trim());
|
|
8671
|
+
}
|
|
8672
|
+
function formTemplateConditionConfigSignature(value) {
|
|
8673
|
+
if (!isRecord3(value) || !isRecord3(value.condition) || typeof value.action !== "boolean") {
|
|
8674
|
+
return null;
|
|
8675
|
+
}
|
|
8676
|
+
const canonicalize = (input) => {
|
|
8677
|
+
if (Array.isArray(input)) {
|
|
8678
|
+
return input.map(canonicalize);
|
|
8679
|
+
}
|
|
8680
|
+
if (!isRecord3(input)) {
|
|
8681
|
+
return input;
|
|
8682
|
+
}
|
|
8683
|
+
const normalized = Object.fromEntries(
|
|
8684
|
+
Object.keys(input).sort().map((key) => [key, canonicalize(input[key])])
|
|
8685
|
+
);
|
|
8686
|
+
if ((normalized.logic === "AND" || normalized.logic === "OR") && Array.isArray(normalized.conditions)) {
|
|
8687
|
+
normalized.conditions = [...normalized.conditions].sort(
|
|
8688
|
+
(left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right))
|
|
8689
|
+
);
|
|
8690
|
+
}
|
|
8691
|
+
return normalized;
|
|
8692
|
+
};
|
|
8693
|
+
return JSON.stringify(canonicalize({ condition: value.condition, action: value.action }));
|
|
8694
|
+
}
|
|
8695
|
+
function validateFormTemplateConditionVariable(expression, reference, side, pathName, knownFields, dependencies, errors) {
|
|
8696
|
+
if (typeof expression !== "string" || !expression.trim()) {
|
|
8697
|
+
errors.push(`[form.dynamic_condition.variable_required] ${pathName}.${side}Value \u5FC5\u987B\u662F\u975E\u7A7A\u53D8\u91CF\u8868\u8FBE\u5F0F\u3002`);
|
|
8698
|
+
return;
|
|
8699
|
+
}
|
|
8700
|
+
if (!isSupportedFormTemplateConditionVariable(expression)) {
|
|
8701
|
+
errors.push(`[form.dynamic_condition.variable_root] ${pathName}.${side}Value \u4F7F\u7528\u4E86\u4E0D\u652F\u6301\u7684\u53D8\u91CF\uFF1B\u4EC5\u5141\u8BB8 $MOMENT\u3001$userInfo\u3001$formField\u3001$formDisplayField\u3001$RANGE\u3002`);
|
|
8702
|
+
return;
|
|
8703
|
+
}
|
|
8704
|
+
const expressionFields = formTemplateConditionFieldReferences(expression);
|
|
8705
|
+
const needsFieldSubscription = expressionFields.length > 0;
|
|
8706
|
+
if (needsFieldSubscription && (typeof reference !== "string" || !reference.trim())) {
|
|
8707
|
+
errors.push(`[form.dynamic_condition.variable_ref_required] ${pathName}.${side}Value \u5F15\u7528\u4E86\u8868\u5355\u5B57\u6BB5\uFF0C\u5FC5\u987B\u540C\u65F6\u63D0\u4F9B ${side}ValueRef \u4EE5\u8BA2\u9605\u5B57\u6BB5\u53D8\u5316\u3002`);
|
|
8708
|
+
}
|
|
8709
|
+
if (reference !== void 0 && reference !== null) {
|
|
8710
|
+
if (typeof reference !== "string" || !reference.trim() || !isSupportedFormTemplateConditionVariable(reference)) {
|
|
8711
|
+
errors.push(`[form.dynamic_condition.variable_ref_invalid] ${pathName}.${side}ValueRef \u5FC5\u987B\u662F\u53D7\u652F\u6301\u7684\u53D8\u91CF\u5F15\u7528\u3002`);
|
|
8712
|
+
}
|
|
8713
|
+
}
|
|
8714
|
+
const referencedFields = /* @__PURE__ */ new Set([
|
|
8715
|
+
...expressionFields,
|
|
8716
|
+
...typeof reference === "string" ? formTemplateConditionFieldReferences(reference) : []
|
|
8717
|
+
]);
|
|
8718
|
+
for (const field of referencedFields) {
|
|
8719
|
+
if (!knownFields.has(field)) {
|
|
8720
|
+
errors.push(`[form.dynamic_condition.field_not_found] ${pathName}.${side}Value \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 ${field}\uFF1B\u8FD0\u884C\u65F6\u6309 rule.field \u53D6\u503C\uFF0C\u4E0D\u80FD\u4F7F\u7528\u4E1A\u52A1 key \u4EE3\u66FF\u3002`);
|
|
8721
|
+
} else {
|
|
8722
|
+
dependencies.add(field);
|
|
8723
|
+
}
|
|
8724
|
+
}
|
|
8725
|
+
}
|
|
8726
|
+
function validateFormTemplateConditionField(fieldValue, subField, side, pathName, knownFields, dependencies, errors) {
|
|
8727
|
+
if (typeof fieldValue !== "string" || !fieldValue.trim()) {
|
|
8728
|
+
errors.push(`[form.dynamic_condition.field_required] ${pathName}.${side}Value \u5FC5\u987B\u586B\u5199\u5B9E\u9645 rule.field\u3002`);
|
|
8729
|
+
return;
|
|
8730
|
+
}
|
|
8731
|
+
const field = fieldValue.trim();
|
|
8732
|
+
if (!knownFields.has(field)) {
|
|
8733
|
+
errors.push(`[form.dynamic_condition.field_not_found] ${pathName}.${side}Value \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 ${field}\uFF1B\u8FD0\u884C\u65F6\u6309 rule.field \u53D6\u503C\uFF0C\u4E0D\u80FD\u4F7F\u7528\u4E1A\u52A1 key \u4EE3\u66FF\u3002`);
|
|
8734
|
+
} else {
|
|
8735
|
+
dependencies.add(field);
|
|
8736
|
+
}
|
|
8737
|
+
if (subField !== void 0 && subField !== null && (typeof subField !== "string" || !subField.trim())) {
|
|
8738
|
+
errors.push(`[form.dynamic_condition.subfield_invalid] ${pathName}.${side}SubField \u63D0\u4F9B\u65F6\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002`);
|
|
8739
|
+
}
|
|
8740
|
+
}
|
|
8741
|
+
function validateFormTemplateConditionItem(item, pathName, knownFields, dependencies, errors) {
|
|
8742
|
+
const leftType = item.leftValueType;
|
|
8743
|
+
const rightType = item.rightValueType;
|
|
8744
|
+
const operator = item.operator;
|
|
8745
|
+
if (typeof leftType !== "string" || !FORM_TEMPLATE_CONDITION_LEFT_TYPES.has(leftType)) {
|
|
8746
|
+
errors.push(`[form.dynamic_condition.left_type] ${pathName}.leftValueType \u53EA\u80FD\u662F field \u6216 variable\u3002`);
|
|
8747
|
+
} else if (leftType === "field") {
|
|
8748
|
+
validateFormTemplateConditionField(item.leftValue, item.leftSubField, "left", pathName, knownFields, dependencies, errors);
|
|
8749
|
+
} else {
|
|
8750
|
+
validateFormTemplateConditionVariable(item.leftValue, item.leftValueRef, "left", pathName, knownFields, dependencies, errors);
|
|
8751
|
+
}
|
|
8752
|
+
if (Object.prototype.hasOwnProperty.call(item, "subField") && typeof item.subField === "string" && item.subField.trim()) {
|
|
8753
|
+
errors.push(`[form.dynamic_condition.legacy_subfield] ${pathName}.subField \u4E0D\u4F1A\u88AB\u5F53\u524D\u8868\u5355\u8FD0\u884C\u65F6\u8BFB\u53D6\uFF1B\u5DE6\u4FA7\u8BF7\u6539\u4E3A leftSubField\uFF0C\u53F3\u4FA7\u8BF7\u4F7F\u7528 rightSubField\u3002`);
|
|
8754
|
+
}
|
|
8755
|
+
if (typeof operator !== "string" || !FORM_TEMPLATE_CONDITION_OPERATORS.has(operator)) {
|
|
8756
|
+
errors.push(`[form.dynamic_condition.operator] ${pathName}.operator \u4E0D\u53D7\u652F\u6301\uFF1B\u5141\u8BB8 eq/ne/gt/gte/lt/lte/contains/isEmpty/isNotEmpty\u3002`);
|
|
8757
|
+
return;
|
|
8758
|
+
}
|
|
8759
|
+
if (FORM_TEMPLATE_CONDITION_UNARY_OPERATORS.has(operator)) {
|
|
8760
|
+
if (rightType !== void 0 && (typeof rightType !== "string" || !FORM_TEMPLATE_CONDITION_RIGHT_TYPES.has(rightType))) {
|
|
8761
|
+
errors.push(`[form.dynamic_condition.right_type] ${pathName}.rightValueType \u53EA\u80FD\u662F field\u3001variable \u6216 constant\u3002`);
|
|
8762
|
+
}
|
|
8763
|
+
return;
|
|
8764
|
+
}
|
|
8765
|
+
if (typeof rightType !== "string" || !FORM_TEMPLATE_CONDITION_RIGHT_TYPES.has(rightType)) {
|
|
8766
|
+
errors.push(`[form.dynamic_condition.right_type] ${pathName}.rightValueType \u53EA\u80FD\u662F field\u3001variable \u6216 constant\u3002`);
|
|
8767
|
+
return;
|
|
8768
|
+
}
|
|
8769
|
+
if (rightType === "field") {
|
|
8770
|
+
validateFormTemplateConditionField(item.rightValue, item.rightSubField, "right", pathName, knownFields, dependencies, errors);
|
|
8771
|
+
} else if (rightType === "variable") {
|
|
8772
|
+
validateFormTemplateConditionVariable(item.rightValue, item.rightValueRef, "right", pathName, knownFields, dependencies, errors);
|
|
8773
|
+
} else if (!Object.prototype.hasOwnProperty.call(item, "rightValue")) {
|
|
8774
|
+
errors.push(`[form.dynamic_condition.constant_required] ${pathName}.rightValueType=constant \u65F6\u5FC5\u987B\u663E\u5F0F\u63D0\u4F9B rightValue\u3002`);
|
|
8775
|
+
}
|
|
8776
|
+
}
|
|
8777
|
+
function validateFormTemplateConditionGroup(group, pathName, knownFields, dependencies, errors) {
|
|
8778
|
+
if (typeof group.logic !== "string" || !FORM_TEMPLATE_CONDITION_LOGICS.has(group.logic)) {
|
|
8779
|
+
errors.push(`[form.dynamic_condition.logic] ${pathName}.logic \u53EA\u80FD\u662F AND \u6216 OR\u3002`);
|
|
8780
|
+
}
|
|
8781
|
+
if (!Array.isArray(group.conditions) || group.conditions.length === 0) {
|
|
8782
|
+
errors.push(`[form.dynamic_condition.conditions_required] ${pathName}.conditions \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4\u3002`);
|
|
8783
|
+
return;
|
|
8784
|
+
}
|
|
8785
|
+
group.conditions.forEach((condition, index) => {
|
|
8786
|
+
const itemPath = `${pathName}.conditions[${index}]`;
|
|
8787
|
+
if (!isRecord3(condition)) {
|
|
8788
|
+
errors.push(`[form.dynamic_condition.item_object] ${itemPath} \u5FC5\u987B\u662F\u6761\u4EF6\u5BF9\u8C61\u6216\u6761\u4EF6\u7EC4\u3002`);
|
|
8789
|
+
return;
|
|
8790
|
+
}
|
|
8791
|
+
if (Object.prototype.hasOwnProperty.call(condition, "logic") || Object.prototype.hasOwnProperty.call(condition, "conditions")) {
|
|
8792
|
+
validateFormTemplateConditionGroup(condition, itemPath, knownFields, dependencies, errors);
|
|
8793
|
+
} else {
|
|
8794
|
+
validateFormTemplateConditionItem(condition, itemPath, knownFields, dependencies, errors);
|
|
8795
|
+
}
|
|
8796
|
+
});
|
|
8797
|
+
}
|
|
8798
|
+
function validateFormTemplateDynamicStateConfig(entry, spec, knownFields, graph, errors, warnings) {
|
|
8799
|
+
const enabled = entry.rule[spec.enabledKey];
|
|
8800
|
+
const config = entry.rule[spec.configKey];
|
|
8801
|
+
if (enabled !== void 0 && typeof enabled !== "boolean") {
|
|
8802
|
+
errors.push(`[form.dynamic_condition.enabled_boolean] ${entry.path}.${spec.enabledKey} \u5FC5\u987B\u662F boolean\u3002`);
|
|
8803
|
+
return;
|
|
8804
|
+
}
|
|
8805
|
+
if (enabled !== true) {
|
|
8806
|
+
if (config !== void 0 && config !== null) {
|
|
8807
|
+
warnings.push(`[form.dynamic_condition.stale_config] ${entry.path}.${spec.configKey} \u5DF2\u4FDD\u7559\u4F46 ${spec.enabledKey} \u672A\u542F\u7528\uFF1B\u8BE5\u914D\u7F6E\u4E0D\u4F1A\u6267\u884C\u3002`);
|
|
8808
|
+
}
|
|
8809
|
+
return;
|
|
8810
|
+
}
|
|
8811
|
+
if (!isRecord3(config)) {
|
|
8812
|
+
errors.push(`[form.dynamic_condition.config_required] \u5B57\u6BB5 ${entry.field} \u5DF2\u542F\u7528${spec.label}\uFF0C\u5FC5\u987B\u63D0\u4F9B ${spec.configKey} \u5BF9\u8C61\u3002`);
|
|
8813
|
+
return;
|
|
8814
|
+
}
|
|
8815
|
+
if (typeof config.action !== "boolean") {
|
|
8816
|
+
errors.push(`[form.dynamic_condition.action_boolean] ${entry.path}.${spec.configKey}.action \u5FC5\u987B\u662F boolean\uFF1Btrue \u8868\u793A\u6761\u4EF6\u6210\u7ACB\u65F6\u6267\u884C\u201C${spec.label.replace("\u52A8\u6001", "")}\u201D\u52A8\u4F5C\u3002`);
|
|
8817
|
+
}
|
|
8818
|
+
if (!isRecord3(config.condition)) {
|
|
8819
|
+
errors.push(`[form.dynamic_condition.condition_required] ${entry.path}.${spec.configKey}.condition \u5FC5\u987B\u662F\u975E\u7A7A\u6761\u4EF6\u7EC4\u3002`);
|
|
8820
|
+
return;
|
|
8821
|
+
}
|
|
8822
|
+
if (!Object.prototype.hasOwnProperty.call(config.condition, "logic") && Object.prototype.hasOwnProperty.call(config.condition, "leftValueType")) {
|
|
8823
|
+
errors.push(`[form.dynamic_condition.legacy_single_item] ${entry.path}.${spec.configKey}.condition \u4ECD\u662F\u65E7\u7684\u5355\u6761\u4EF6\u5BF9\u8C61\uFF1B\u5F53\u524D\u8FD0\u884C\u65F6\u4F1A\u628A\u5B83\u5F53\u7A7A\u6761\u4EF6\uFF0C\u5FC5\u987B\u8FC1\u79FB\u4E3A { logic, conditions: [...] }\u3002`);
|
|
8824
|
+
return;
|
|
8825
|
+
}
|
|
8826
|
+
const dependencies = graph.get(entry.field) ?? /* @__PURE__ */ new Set();
|
|
8827
|
+
graph.set(entry.field, dependencies);
|
|
8828
|
+
validateFormTemplateConditionGroup(
|
|
8829
|
+
config.condition,
|
|
8830
|
+
`${entry.path}.${spec.configKey}.condition`,
|
|
8831
|
+
knownFields,
|
|
8832
|
+
dependencies,
|
|
8833
|
+
errors
|
|
8834
|
+
);
|
|
8835
|
+
}
|
|
8836
|
+
function validateFormTemplateDynamicConditionCycles(graph, errors) {
|
|
8837
|
+
const visited = /* @__PURE__ */ new Set();
|
|
8838
|
+
const active = /* @__PURE__ */ new Set();
|
|
8839
|
+
const stack = [];
|
|
8840
|
+
const reported = /* @__PURE__ */ new Set();
|
|
8841
|
+
const visit = (field) => {
|
|
8842
|
+
if (active.has(field)) {
|
|
8843
|
+
const start = stack.indexOf(field);
|
|
8844
|
+
const cycle = [...stack.slice(start), field];
|
|
8845
|
+
const signature = cycle.join(" -> ");
|
|
8846
|
+
if (!reported.has(signature)) {
|
|
8847
|
+
reported.add(signature);
|
|
8848
|
+
errors.push(`[form.dynamic_condition.cycle] \u52A8\u6001\u5B57\u6BB5\u72B6\u6001\u5B58\u5728\u5FAA\u73AF\u4F9D\u8D56\uFF1A${signature}\u3002`);
|
|
8849
|
+
}
|
|
8850
|
+
return;
|
|
8851
|
+
}
|
|
8852
|
+
if (visited.has(field)) {
|
|
8853
|
+
return;
|
|
8854
|
+
}
|
|
8855
|
+
visited.add(field);
|
|
8856
|
+
active.add(field);
|
|
8857
|
+
stack.push(field);
|
|
8858
|
+
for (const dependency of graph.get(field) ?? []) {
|
|
8859
|
+
if (graph.has(dependency)) {
|
|
8860
|
+
visit(dependency);
|
|
8861
|
+
} else if (dependency === field) {
|
|
8862
|
+
visit(dependency);
|
|
8863
|
+
}
|
|
8864
|
+
}
|
|
8865
|
+
stack.pop();
|
|
8866
|
+
active.delete(field);
|
|
8867
|
+
};
|
|
8868
|
+
for (const field of graph.keys()) {
|
|
8869
|
+
visit(field);
|
|
8870
|
+
}
|
|
8871
|
+
}
|
|
8872
|
+
function validateFormTemplateDynamicStateConflicts(entry, staticRequiredFields, errors) {
|
|
8873
|
+
const rule = entry.rule;
|
|
8874
|
+
const visibilityEnabled = rule.hasVisibilityCondition === true && isRecord3(rule.visibilityCondition);
|
|
8875
|
+
const disabledEnabled = rule.hasDisabledCondition === true && isRecord3(rule.disabledCondition);
|
|
8876
|
+
const requiredEnabled = rule.hasRequiredCondition === true && isRecord3(rule.requiredCondition);
|
|
8877
|
+
const props = isRecord3(rule.props) ? rule.props : {};
|
|
8878
|
+
const permanentlyHidden = (rule.hidden === true || rule.display === false) && !visibilityEnabled;
|
|
8879
|
+
const permanentlyDisabled = (rule.disabled === true || props.disabled === true) && !disabledEnabled;
|
|
8880
|
+
if (requiredEnabled && permanentlyHidden) {
|
|
8881
|
+
errors.push(`[form.dynamic_condition.required_hidden] \u5B57\u6BB5 ${entry.field} \u542F\u7528\u4E86\u52A8\u6001\u5FC5\u586B\uFF0C\u4F46\u5B57\u6BB5\u88AB\u9759\u6001\u9690\u85CF\u4E14\u6CA1\u6709\u52A8\u6001\u663E\u9690\u6062\u590D\u8DEF\u5F84\u3002`);
|
|
8882
|
+
}
|
|
8883
|
+
if (requiredEnabled && permanentlyDisabled) {
|
|
8884
|
+
errors.push(`[form.dynamic_condition.required_disabled] \u5B57\u6BB5 ${entry.field} \u542F\u7528\u4E86\u52A8\u6001\u5FC5\u586B\uFF0C\u4F46\u5B57\u6BB5\u88AB\u9759\u6001\u7981\u7528\u4E14\u6CA1\u6709\u52A8\u6001\u53EA\u8BFB\u6062\u590D\u8DEF\u5F84\u3002`);
|
|
8885
|
+
}
|
|
8886
|
+
if (requiredEnabled) {
|
|
8887
|
+
const requiredSignature = formTemplateConditionConfigSignature(rule.requiredCondition);
|
|
8888
|
+
const visibilitySignature = visibilityEnabled ? formTemplateConditionConfigSignature(rule.visibilityCondition) : null;
|
|
8889
|
+
const disabledSignature = disabledEnabled ? formTemplateConditionConfigSignature(rule.disabledCondition) : null;
|
|
8890
|
+
if (requiredSignature && requiredSignature === visibilitySignature) {
|
|
8891
|
+
errors.push(`[form.dynamic_condition.required_visibility_conflict] \u5B57\u6BB5 ${entry.field} \u5728\u540C\u4E00\u6761\u4EF6\u5206\u652F\u540C\u65F6\u201C\u9690\u85CF\u201D\u548C\u201C\u5FC5\u586B\u201D\uFF1B\u8BF7\u8BA9\u663E\u9690\u6761\u4EF6\u4E0E\u5FC5\u586B\u6761\u4EF6\u4E92\u65A5\u3002`);
|
|
8892
|
+
}
|
|
8893
|
+
if (requiredSignature && requiredSignature === disabledSignature) {
|
|
8894
|
+
errors.push(`[form.dynamic_condition.required_disabled_conflict] \u5B57\u6BB5 ${entry.field} \u5728\u540C\u4E00\u6761\u4EF6\u5206\u652F\u540C\u65F6\u201C\u7981\u7528\u201D\u548C\u201C\u5FC5\u586B\u201D\uFF1B\u8BF7\u8BA9\u53EA\u8BFB\u6761\u4EF6\u4E0E\u5FC5\u586B\u6761\u4EF6\u4E92\u65A5\u3002`);
|
|
8895
|
+
}
|
|
8896
|
+
}
|
|
8897
|
+
if (staticRequiredFields.has(entry.field) && (visibilityEnabled || disabledEnabled) && !requiredEnabled) {
|
|
8898
|
+
errors.push(`[form.dynamic_condition.static_required_conflict] \u5B57\u6BB5 ${entry.field} \u662F\u9759\u6001\u5FC5\u586B\uFF0C\u4F46\u53C8\u53EF\u80FD\u88AB\u52A8\u6001\u9690\u85CF\u6216\u7981\u7528\uFF1B\u5FC5\u987B\u589E\u52A0\u4E92\u65A5\u7684 requiredCondition\uFF0C\u4E0D\u80FD\u4FDD\u7559\u6C38\u4E45\u5FC5\u586B\u3002`);
|
|
8899
|
+
}
|
|
8900
|
+
const type = typeof rule.type === "string" ? rule.type : "";
|
|
8901
|
+
if (requiredEnabled && FORM_TEMPLATE_DYNAMIC_REQUIRED_UNSUPPORTED_TYPES.has(type)) {
|
|
8902
|
+
errors.push(`[form.dynamic_condition.required_control_type] \u5B57\u6BB5 ${entry.field} type=${type} \u662F\u5C55\u793A/\u547D\u4EE4\u63A7\u4EF6\uFF0C\u4E0D\u80FD\u914D\u7F6E\u52A8\u6001\u5FC5\u586B\u3002`);
|
|
8903
|
+
}
|
|
8904
|
+
}
|
|
8905
|
+
function validateFormTemplateDynamicFieldStates(payload, errors, warnings) {
|
|
8906
|
+
const entries = collectFormTemplateRuleEntries(payload);
|
|
8907
|
+
if (!entries.length) {
|
|
8908
|
+
return;
|
|
8909
|
+
}
|
|
8910
|
+
const knownFields = new Set(entries.map((entry) => entry.field));
|
|
8911
|
+
const graph = /* @__PURE__ */ new Map();
|
|
8912
|
+
const staticRequiredFields = formTemplateStaticRequiredFields(payload);
|
|
8913
|
+
for (const entry of entries) {
|
|
8914
|
+
for (const spec of FORM_TEMPLATE_DYNAMIC_STATE_SPECS) {
|
|
8915
|
+
validateFormTemplateDynamicStateConfig(entry, spec, knownFields, graph, errors, warnings);
|
|
8916
|
+
}
|
|
8917
|
+
validateFormTemplateDynamicStateConflicts(entry, staticRequiredFields, errors);
|
|
8918
|
+
}
|
|
8919
|
+
validateFormTemplateDynamicConditionCycles(graph, errors);
|
|
8920
|
+
}
|
|
8921
|
+
function validateFormTemplateFieldIdentifiers(payload, errors) {
|
|
8922
|
+
for (const entry of collectFormTemplateRuleEntries(payload)) {
|
|
8923
|
+
if (entry.field.length > MAX_FORM_TEMPLATE_FIELD_LENGTH) {
|
|
8924
|
+
errors.push(
|
|
8925
|
+
`[form.field.max_length] ${entry.path}.field \u957F\u5EA6\u4E3A ${entry.field.length}\uFF0C\u8D85\u8FC7\u5E73\u53F0 think_form_rule.field \u4E0A\u9650 ${MAX_FORM_TEMPLATE_FIELD_LENGTH}\uFF1B\u8BF7\u7F29\u77ED\u5B57\u6BB5\u6807\u8BC6\uFF0C\u4E1A\u52A1\u8BED\u4E49\u653E\u5728 key/title\u3002`
|
|
8926
|
+
);
|
|
8927
|
+
}
|
|
8928
|
+
}
|
|
8929
|
+
}
|
|
8930
|
+
function validateFormTemplateWorkLint(payload, errors, warnings = [], mode = payload.mode === "create" ? "create" : "edit") {
|
|
8537
8931
|
validateFormTemplateNameLength(payload, errors);
|
|
8932
|
+
validateFormTemplateFieldIdentifiers(payload, errors);
|
|
8538
8933
|
validateFormTemplateValueValidateMaps(payload, errors);
|
|
8539
8934
|
validateStructuredFormTemplateFieldTypes(payload, errors);
|
|
8540
|
-
validateFormTemplateControlContracts(payload, errors);
|
|
8935
|
+
validateFormTemplateControlContracts(payload, errors, warnings, mode);
|
|
8541
8936
|
validateFormTemplateHeaderContract(payload, errors);
|
|
8542
8937
|
validateStructuredFormTemplateVisualReview(payload, errors);
|
|
8938
|
+
validateFormTemplateDynamicFieldStates(payload, errors, warnings);
|
|
8543
8939
|
}
|
|
8544
8940
|
function stripFormTemplateCreateIds(payload) {
|
|
8545
8941
|
const next = { ...payload };
|
|
@@ -11633,6 +12029,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
11633
12029
|
throw new Error("Config build requires a meta file produced by `bpmax-cli config <domain> export`.");
|
|
11634
12030
|
}
|
|
11635
12031
|
const raw = typeof meta.raw_file === "string" ? await readJsonFile(meta.raw_file) : void 0;
|
|
12032
|
+
let formTemplateWarnings = [];
|
|
11636
12033
|
let stepDetailReferenceAudit;
|
|
11637
12034
|
let stepDetailAnalysis;
|
|
11638
12035
|
if (domain === "flow-template" && isRecord3(work)) {
|
|
@@ -11649,7 +12046,8 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
11649
12046
|
}
|
|
11650
12047
|
if (domain === "form-template" && isRecord3(work)) {
|
|
11651
12048
|
const errors = [];
|
|
11652
|
-
|
|
12049
|
+
formTemplateWarnings = [];
|
|
12050
|
+
validateFormTemplateWorkLint(work, errors, formTemplateWarnings, createMode ? "create" : "edit");
|
|
11653
12051
|
if (errors.length) {
|
|
11654
12052
|
throw new Error(`form-template lint failed: ${errors.join("; ")}`);
|
|
11655
12053
|
}
|
|
@@ -11689,6 +12087,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
11689
12087
|
meta: submitMeta,
|
|
11690
12088
|
base_hash: createMode ? null : typeof meta.base_hash === "string" ? meta.base_hash : null,
|
|
11691
12089
|
payload,
|
|
12090
|
+
...formTemplateWarnings.length ? { form_template_warnings: formTemplateWarnings } : {},
|
|
11692
12091
|
...stepDetailReferenceAudit ? {
|
|
11693
12092
|
step_detail_references: stepDetailReferenceAudit.references,
|
|
11694
12093
|
step_detail_warnings: stepDetailReferenceAudit.warnings,
|
|
@@ -11707,6 +12106,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
11707
12106
|
work_file: workFile,
|
|
11708
12107
|
submit_file: outFile,
|
|
11709
12108
|
payload_keys: Object.keys(payload),
|
|
12109
|
+
...formTemplateWarnings.length ? { warnings: formTemplateWarnings } : {},
|
|
11710
12110
|
...stepDetailReferenceAudit ? {
|
|
11711
12111
|
step_detail_references: stepDetailReferenceAudit.references,
|
|
11712
12112
|
warnings: stepDetailReferenceAudit.warnings,
|
|
@@ -11841,7 +12241,8 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
11841
12241
|
}
|
|
11842
12242
|
const shouldLintFormTemplate = options.domain ? options.domain === "form-template" : looksLikeFormTemplateWork(value);
|
|
11843
12243
|
if (shouldLintFormTemplate) {
|
|
11844
|
-
|
|
12244
|
+
const formMode = options.mode ?? (value.mode === "create" ? "create" : "edit");
|
|
12245
|
+
validateFormTemplateWorkLint(value, errors, warnings, formMode);
|
|
11845
12246
|
}
|
|
11846
12247
|
if (options.domain === "filter-template") {
|
|
11847
12248
|
lintFilterTemplateWork(value, errors);
|