bpmax-cli 0.1.37 → 0.1.38
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/README.md +4 -2
- package/dist/bin.js +168 -2
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-cli/SKILL.md +1 -1
- package/skills/bpmax-project/SKILL.md +5 -2
package/README.md
CHANGED
|
@@ -133,9 +133,10 @@ Before advancing or rejecting a step, inspect the safe context and available act
|
|
|
133
133
|
```bash
|
|
134
134
|
bpmax-cli step context 15690 --project-id 13097 --format json
|
|
135
135
|
bpmax-cli step actions 15690 --project-id 13097 --format json
|
|
136
|
+
bpmax-cli step requirements 15690 --project-id 13097 --format json
|
|
136
137
|
```
|
|
137
138
|
|
|
138
|
-
`step context` reports the project/step URL, current user ownership, parsed actions, form evidence, and `identity_unverified`. If project and step form values are empty, do not advance from an ES keyword or attachment-text match alone.
|
|
139
|
+
`step context` reports the project/step URL, current user ownership, parsed actions, current-step input requirements, form evidence, and `identity_unverified`. `step requirements` focuses on current-step bound form fields, required inputs, existing values, missing required inputs, and a submit payload template. If project and step form values are empty, do not advance from an ES keyword or attachment-text match alone.
|
|
139
140
|
|
|
140
141
|
Submit step actions through a dry-run first:
|
|
141
142
|
|
|
@@ -144,11 +145,12 @@ bpmax-cli step submit 15690 \
|
|
|
144
145
|
--project-id 13097 \
|
|
145
146
|
--action approve \
|
|
146
147
|
--label "通过" \
|
|
148
|
+
--data '{"form":{"manager_opinion":"同意"}}' \
|
|
147
149
|
--comments "确认推进" \
|
|
148
150
|
--format json
|
|
149
151
|
```
|
|
150
152
|
|
|
151
|
-
The command only calls `PUT /api/step/:id?action=<action>` when `--confirm <text>` is present and safety checks pass.
|
|
153
|
+
The command only calls `PUT /api/step/:id?action=<action>` when `--confirm <text>` is present and safety checks pass. Confirmed submits are refused when current-step required inputs are missing.
|
|
152
154
|
|
|
153
155
|
Filter pending steps at the API query level instead of pulling all pages locally:
|
|
154
156
|
|
package/dist/bin.js
CHANGED
|
@@ -733,7 +733,7 @@ import { readFile as readFile5 } from "fs/promises";
|
|
|
733
733
|
// package.json
|
|
734
734
|
var package_default = {
|
|
735
735
|
name: "bpmax-cli",
|
|
736
|
-
version: "0.1.
|
|
736
|
+
version: "0.1.38",
|
|
737
737
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
738
738
|
type: "module",
|
|
739
739
|
bin: {
|
|
@@ -3647,6 +3647,7 @@ var schemaEntries = [
|
|
|
3647
3647
|
{ name: "step.get", description: "Get step detail.", method: "GET", path: "/api/step/:id" },
|
|
3648
3648
|
{ name: "step.context", description: "Get safe step processing context before mutation.", method: "GET", path: "/api/project/:id + /api/step/:id + /api/user/current" },
|
|
3649
3649
|
{ name: "step.actions", description: "List safe step actions parsed from the flow node.", method: "GET", path: "/api/project/:id + /api/step/:id" },
|
|
3650
|
+
{ name: "step.requirements", description: "List required step inputs before submitting.", method: "GET", path: "/api/project/:id + /api/step/:id" },
|
|
3650
3651
|
{ name: "step.submit", description: "Dry-run or submit a step action with safety checks.", method: "PUT", path: "/api/step/:id?action=:action" },
|
|
3651
3652
|
{ name: "bbs.list", description: "List BPMAX Business Skills.", method: "GET", path: "/api/business_skill" },
|
|
3652
3653
|
{ name: "bbs.create", description: "Create a BPMAX Business Skill from a standard skill zip.", method: "POST", path: "/api/business_skill" },
|
|
@@ -3785,6 +3786,9 @@ function hasMeaningfulValue(value) {
|
|
|
3785
3786
|
}
|
|
3786
3787
|
return false;
|
|
3787
3788
|
}
|
|
3789
|
+
function isEmptyValue2(value) {
|
|
3790
|
+
return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
3791
|
+
}
|
|
3788
3792
|
function projectIdOfStep(step) {
|
|
3789
3793
|
const nestedProjectId = isRecord7(step.project) ? step.project.id : void 0;
|
|
3790
3794
|
return idValue(step.project_id ?? step.projectId ?? nestedProjectId);
|
|
@@ -3902,6 +3906,116 @@ function formListOfStep(step) {
|
|
|
3902
3906
|
const values = [step.formList, step.forms, step.metaForm];
|
|
3903
3907
|
return values.filter(hasMeaningfulValue);
|
|
3904
3908
|
}
|
|
3909
|
+
function unwrapFormValue(value) {
|
|
3910
|
+
if (!isRecord7(value)) {
|
|
3911
|
+
return value;
|
|
3912
|
+
}
|
|
3913
|
+
if ("value" in value && Object.keys(value).length <= 3) {
|
|
3914
|
+
return unwrapFormValue(value.value);
|
|
3915
|
+
}
|
|
3916
|
+
return value;
|
|
3917
|
+
}
|
|
3918
|
+
function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set()) {
|
|
3919
|
+
if (!value || seen.has(value)) {
|
|
3920
|
+
return output;
|
|
3921
|
+
}
|
|
3922
|
+
seen.add(value);
|
|
3923
|
+
if (Array.isArray(value)) {
|
|
3924
|
+
value.forEach((item) => collectFormValues(item, output, seen));
|
|
3925
|
+
return output;
|
|
3926
|
+
}
|
|
3927
|
+
if (!isRecord7(value)) {
|
|
3928
|
+
return output;
|
|
3929
|
+
}
|
|
3930
|
+
const key = stringValue(value.key ?? value.field_key ?? value.fieldKey ?? value.name);
|
|
3931
|
+
if (key && "value" in value) {
|
|
3932
|
+
const nextValue = unwrapFormValue(value.value);
|
|
3933
|
+
if (hasMeaningfulValue(nextValue)) {
|
|
3934
|
+
output[key] = nextValue;
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
for (const child of Object.values(value)) {
|
|
3938
|
+
if (Array.isArray(child) || isRecord7(child)) {
|
|
3939
|
+
collectFormValues(child, output, seen);
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
return output;
|
|
3943
|
+
}
|
|
3944
|
+
function stepRequirementSource(step, flowNode) {
|
|
3945
|
+
return {
|
|
3946
|
+
step_form_template: step.form_template ?? step.formTemplate ?? step.form_template_data ?? step.formTemplateData,
|
|
3947
|
+
step_form_schema: step.form_schema ?? step.formSchema,
|
|
3948
|
+
step_forms: step.forms ?? step.formList ?? step.metaForm,
|
|
3949
|
+
flow_node_step_form_template: flowNode?.form_template ?? flowNode?.formTemplate ?? flowNode?.step_form_template ?? flowNode?.stepFormTemplate,
|
|
3950
|
+
flow_node_form_schema: flowNode?.form_schema ?? flowNode?.formSchema
|
|
3951
|
+
};
|
|
3952
|
+
}
|
|
3953
|
+
function buildSubmitPayloadTemplate(fields) {
|
|
3954
|
+
const template = {};
|
|
3955
|
+
for (const field of fields) {
|
|
3956
|
+
if (field.hidden) {
|
|
3957
|
+
continue;
|
|
3958
|
+
}
|
|
3959
|
+
template[field.key] = isSubFormField(field) ? [
|
|
3960
|
+
Object.fromEntries((field.children ?? []).filter((child) => !child.hidden).map((child) => [child.key, null]))
|
|
3961
|
+
] : null;
|
|
3962
|
+
}
|
|
3963
|
+
return template;
|
|
3964
|
+
}
|
|
3965
|
+
function fieldWithValue(field, value) {
|
|
3966
|
+
const missing = Boolean(field.required && !field.hidden && isEmptyValue2(value));
|
|
3967
|
+
return {
|
|
3968
|
+
...field,
|
|
3969
|
+
...value !== void 0 ? { value } : {},
|
|
3970
|
+
missing
|
|
3971
|
+
};
|
|
3972
|
+
}
|
|
3973
|
+
function collectMissingRequiredInputs(fields, values) {
|
|
3974
|
+
const missing = [];
|
|
3975
|
+
for (const field of fields) {
|
|
3976
|
+
const value = values[field.key];
|
|
3977
|
+
if (field.required && !field.hidden && isEmptyValue2(value)) {
|
|
3978
|
+
missing.push(fieldWithValue(field, value));
|
|
3979
|
+
continue;
|
|
3980
|
+
}
|
|
3981
|
+
if (!isSubFormField(field) || !Array.isArray(value) || !field.children?.length) {
|
|
3982
|
+
continue;
|
|
3983
|
+
}
|
|
3984
|
+
value.forEach((row, index) => {
|
|
3985
|
+
if (!isRecord7(row)) {
|
|
3986
|
+
return;
|
|
3987
|
+
}
|
|
3988
|
+
for (const child of field.children ?? []) {
|
|
3989
|
+
const childValue = row[child.key];
|
|
3990
|
+
if (child.required && !child.hidden && isEmptyValue2(childValue)) {
|
|
3991
|
+
missing.push(fieldWithValue({ ...child, key: `${field.key}[${index}].${child.key}` }, childValue));
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
});
|
|
3995
|
+
}
|
|
3996
|
+
return missing;
|
|
3997
|
+
}
|
|
3998
|
+
function buildStepRequirements(step, flowNode, submitData = {}) {
|
|
3999
|
+
const fields = extractFormFields(stepRequirementSource(step, flowNode));
|
|
4000
|
+
const providedValues = {
|
|
4001
|
+
...collectFormValues(step.formList),
|
|
4002
|
+
...collectFormValues(step.forms),
|
|
4003
|
+
...collectFormValues(step.metaForm),
|
|
4004
|
+
...extractSubmitInputValues(submitData)
|
|
4005
|
+
};
|
|
4006
|
+
const requirementFields = fields.map((field) => fieldWithValue(field, providedValues[field.key]));
|
|
4007
|
+
const missingRequiredInputs = collectMissingRequiredInputs(fields, providedValues);
|
|
4008
|
+
return {
|
|
4009
|
+
fields: requirementFields,
|
|
4010
|
+
required_inputs: requirementFields.filter((field) => field.required && !field.hidden),
|
|
4011
|
+
optional_inputs: requirementFields.filter((field) => !field.required && !field.hidden),
|
|
4012
|
+
missing_required_inputs: missingRequiredInputs,
|
|
4013
|
+
provided_values: providedValues,
|
|
4014
|
+
submit_payload_template: buildSubmitPayloadTemplate(fields),
|
|
4015
|
+
can_submit: missingRequiredInputs.length === 0,
|
|
4016
|
+
blocking_reasons: missingRequiredInputs.length > 0 ? ["missing_required_step_inputs"] : []
|
|
4017
|
+
};
|
|
4018
|
+
}
|
|
3905
4019
|
function buildFormSummary(project, step) {
|
|
3906
4020
|
const projectFormEmpty = !hasMeaningfulValue(project.metaForm ?? project.project_form ?? project.projectForm);
|
|
3907
4021
|
const stepFormsEmpty = formListOfStep(step).length === 0;
|
|
@@ -3969,6 +4083,7 @@ async function buildStepContext(profile, client, stepId, projectId) {
|
|
|
3969
4083
|
}
|
|
3970
4084
|
const flowNode = findFlowNode(project, step);
|
|
3971
4085
|
const formSummary = buildFormSummary(project, step);
|
|
4086
|
+
const requirements = buildStepRequirements(step, flowNode);
|
|
3972
4087
|
const identityUnverified = !formSummary.has_identity_evidence;
|
|
3973
4088
|
const userCheck = checkCurrentUserCanProcess(step, currentUser);
|
|
3974
4089
|
const stepFinished = isStepFinished(step);
|
|
@@ -3982,6 +4097,9 @@ async function buildStepContext(profile, client, stepId, projectId) {
|
|
|
3982
4097
|
if (userCheck.current_user_can_process === false) {
|
|
3983
4098
|
riskWarnings.push(userCheck.current_user_reason);
|
|
3984
4099
|
}
|
|
4100
|
+
if (!requirements.can_submit) {
|
|
4101
|
+
riskWarnings.push(`Missing required step input(s): ${requirements.missing_required_inputs.map((field) => field.key).join(", ")}`);
|
|
4102
|
+
}
|
|
3985
4103
|
return {
|
|
3986
4104
|
project_id: projectId,
|
|
3987
4105
|
step_id: stepId,
|
|
@@ -3994,6 +4112,7 @@ async function buildStepContext(profile, client, stepId, projectId) {
|
|
|
3994
4112
|
...userCheck,
|
|
3995
4113
|
step_finished: stepFinished,
|
|
3996
4114
|
form_summary: formSummary,
|
|
4115
|
+
requirements,
|
|
3997
4116
|
identity_unverified: identityUnverified,
|
|
3998
4117
|
risk_warnings: riskWarnings
|
|
3999
4118
|
};
|
|
@@ -4004,6 +4123,34 @@ async function loadSubmitData(data) {
|
|
|
4004
4123
|
}
|
|
4005
4124
|
return parseJsonInput(data, "--data");
|
|
4006
4125
|
}
|
|
4126
|
+
var SUBMIT_NON_FORM_KEYS = /* @__PURE__ */ new Set([
|
|
4127
|
+
"project_id",
|
|
4128
|
+
"projectId",
|
|
4129
|
+
"target_step",
|
|
4130
|
+
"targetStep",
|
|
4131
|
+
"action",
|
|
4132
|
+
"action_label",
|
|
4133
|
+
"actionLabel",
|
|
4134
|
+
"step_comments",
|
|
4135
|
+
"stepComments",
|
|
4136
|
+
"comments",
|
|
4137
|
+
"urgency"
|
|
4138
|
+
]);
|
|
4139
|
+
function extractSubmitInputValues(data) {
|
|
4140
|
+
const candidates = [data.form, data.form_data, data.formData, data.fields, data.values];
|
|
4141
|
+
const values = {};
|
|
4142
|
+
for (const candidate of candidates) {
|
|
4143
|
+
if (isRecord7(candidate)) {
|
|
4144
|
+
Object.assign(values, candidate);
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4147
|
+
for (const [key, value] of Object.entries(data)) {
|
|
4148
|
+
if (!SUBMIT_NON_FORM_KEYS.has(key) && !isRecord7(value) && !Array.isArray(value)) {
|
|
4149
|
+
values[key] = value;
|
|
4150
|
+
}
|
|
4151
|
+
}
|
|
4152
|
+
return values;
|
|
4153
|
+
}
|
|
4007
4154
|
function registerStepCommands(program2) {
|
|
4008
4155
|
const step = program2.command("step").description("Step commands");
|
|
4009
4156
|
step.command("get <id>").description("Get step detail").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (id, options) => {
|
|
@@ -4037,12 +4184,27 @@ function registerStepCommands(program2) {
|
|
|
4037
4184
|
risk_warnings: context.risk_warnings
|
|
4038
4185
|
});
|
|
4039
4186
|
});
|
|
4187
|
+
step.command("requirements <id>").description("List required step inputs before submitting").requiredOption("--project-id <projectId>", "Project id").option("--data <json>", "Additional submit payload JSON or @file").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (id, options) => {
|
|
4188
|
+
const config = await loadConfig();
|
|
4189
|
+
const profile = resolveProfile(config, options.profile);
|
|
4190
|
+
const client = createApiClient(profile);
|
|
4191
|
+
const context = await buildStepContext(profile, client, id, options.projectId);
|
|
4192
|
+
const data = await loadSubmitData(options.data);
|
|
4193
|
+
const requirements = buildStepRequirements(context.step, context.current_flow_node, data);
|
|
4194
|
+
printResult(options.format, {
|
|
4195
|
+
project_id: context.project_id,
|
|
4196
|
+
step_id: context.step_id,
|
|
4197
|
+
url: context.url,
|
|
4198
|
+
requirements
|
|
4199
|
+
});
|
|
4200
|
+
});
|
|
4040
4201
|
step.command("submit <id>").description("Safely submit a step action").requiredOption("--project-id <projectId>", "Project id").requiredOption("--action <action>", "Step action, e.g. approve/refuse").option("--label <label>", "Action label").option("--target-step <targetStep>", "Target flow step id").option("--data <json>", "Additional submit payload JSON or @file").option("--comments <comments>", "Step comments").option("--urgency <urgency>", "Urgency value", "1").option("--confirm <confirmation>", "Actually submit the step action").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (id, options) => {
|
|
4041
4202
|
const config = await loadConfig();
|
|
4042
4203
|
const profile = resolveProfile(config, options.profile);
|
|
4043
4204
|
const client = createApiClient(profile);
|
|
4044
4205
|
const context = await buildStepContext(profile, client, id, options.projectId);
|
|
4045
4206
|
const data = await loadSubmitData(options.data);
|
|
4207
|
+
const requirements = buildStepRequirements(context.step, context.current_flow_node, data);
|
|
4046
4208
|
const payload = {
|
|
4047
4209
|
...data,
|
|
4048
4210
|
project_id: Number(options.projectId),
|
|
@@ -4071,9 +4233,10 @@ function registerStepCommands(program2) {
|
|
|
4071
4233
|
identity_unverified: context.identity_unverified,
|
|
4072
4234
|
current_user_can_process: context.current_user_can_process,
|
|
4073
4235
|
step_finished: context.step_finished,
|
|
4236
|
+
requirements,
|
|
4074
4237
|
risk_warnings: context.risk_warnings
|
|
4075
4238
|
},
|
|
4076
|
-
next_command_hint: "Re-run with --confirm after verifying project identity, target action, and payload."
|
|
4239
|
+
next_command_hint: requirements.can_submit ? "Re-run with --confirm after verifying project identity, target action, and payload." : "Fill missing required step input(s) in --data before confirming."
|
|
4077
4240
|
});
|
|
4078
4241
|
return;
|
|
4079
4242
|
}
|
|
@@ -4086,6 +4249,9 @@ function registerStepCommands(program2) {
|
|
|
4086
4249
|
if (context.current_user_can_process === false) {
|
|
4087
4250
|
throw new Error(`Refusing to submit: ${context.current_user_reason}`);
|
|
4088
4251
|
}
|
|
4252
|
+
if (!requirements.can_submit) {
|
|
4253
|
+
throw new Error(`Refusing to submit: missing required step input(s): ${requirements.missing_required_inputs.map((field) => field.key).join(", ")}`);
|
|
4254
|
+
}
|
|
4089
4255
|
const result = await apiRequest(client, "PUT", `/step/${id}`, {
|
|
4090
4256
|
params: { action: options.action },
|
|
4091
4257
|
data: payload
|