bpmax-cli 0.1.44-beta.15 → 0.1.44-beta.16
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 +413 -59
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-approval-matrix/SKILL.md +7 -0
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +3 -0
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +7 -0
- package/skills/bpmax-project/SKILL.md +4 -0
package/dist/bin.js
CHANGED
|
@@ -337,6 +337,7 @@ function capabilityForRequest(method, path11) {
|
|
|
337
337
|
if (normalizedMethod === "PUT" && /^\/configuration\/[^/]+$/.test(normalizedPath)) return "config.nav_config.submit";
|
|
338
338
|
if (normalizedMethod === "DELETE" && /^\/configuration\/[^/]+$/.test(normalizedPath)) return "config.nav_config.delete";
|
|
339
339
|
if (normalizedMethod === "POST" && normalizedPath === "/project_staging/prefill") return "project.create";
|
|
340
|
+
if (normalizedMethod === "GET" && /^\/project_staging\/prefill\/[^/]+$/.test(normalizedPath)) return "project.create";
|
|
340
341
|
if (normalizedMethod === "POST" && normalizedPath === "/project/search") return "project.search";
|
|
341
342
|
if (normalizedMethod === "POST" && normalizedPath === "/project/list") return "project.list";
|
|
342
343
|
if (normalizedMethod === "POST" && normalizedPath === "/project") return "project.create";
|
|
@@ -448,7 +449,7 @@ function normalizePath2(path11) {
|
|
|
448
449
|
// package.json
|
|
449
450
|
var package_default = {
|
|
450
451
|
name: "bpmax-cli",
|
|
451
|
-
version: "0.1.44-beta.
|
|
452
|
+
version: "0.1.44-beta.16",
|
|
452
453
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
453
454
|
type: "module",
|
|
454
455
|
bin: {
|
|
@@ -3975,6 +3976,19 @@ function normalizeDatasetFieldPayload(work) {
|
|
|
3975
3976
|
payload.source_field = source.field ?? source.sourceField ?? source.source_field ?? "";
|
|
3976
3977
|
payload.source_fk = source.fk ?? source.sourceFk ?? source.source_fk ?? "";
|
|
3977
3978
|
}
|
|
3979
|
+
payload.sourceTable = payload.source_table;
|
|
3980
|
+
payload.sourceField = payload.source_field;
|
|
3981
|
+
payload.sourceFk = payload.source_fk;
|
|
3982
|
+
if (mode === "create") {
|
|
3983
|
+
const missingSource = [
|
|
3984
|
+
["source_table", payload.source_table],
|
|
3985
|
+
["source_field", payload.source_field],
|
|
3986
|
+
["source_fk", payload.source_fk]
|
|
3987
|
+
].filter(([, value]) => typeof value !== "string" || value.trim() === "");
|
|
3988
|
+
if (missingSource.length > 0) {
|
|
3989
|
+
throw new Error(`dataset-field create requires source mapping fields: ${missingSource.map(([key]) => key).join(", ")}.`);
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3978
3992
|
const advanced = isRecord3(work.advanced) ? work.advanced : {};
|
|
3979
3993
|
if (Object.prototype.hasOwnProperty.call(advanced, "sourceComputed")) {
|
|
3980
3994
|
payload.source_computed = normalizeOptionalText(advanced.sourceComputed);
|
|
@@ -7065,6 +7079,51 @@ async function pullLatestConfigEnvironment(env, options) {
|
|
|
7065
7079
|
}
|
|
7066
7080
|
|
|
7067
7081
|
// src/commands/config.ts
|
|
7082
|
+
var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7083
|
+
function stringValue(value) {
|
|
7084
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
7085
|
+
}
|
|
7086
|
+
function arrayValue(value) {
|
|
7087
|
+
return Array.isArray(value) ? value : [];
|
|
7088
|
+
}
|
|
7089
|
+
function flowTemplateNodes(work) {
|
|
7090
|
+
const data = isRecord4(work.data) ? work.data : void 0;
|
|
7091
|
+
return arrayValue(data?.nodes).filter(isRecord4);
|
|
7092
|
+
}
|
|
7093
|
+
function summarizeFlowTemplateWork(work) {
|
|
7094
|
+
if (!isRecord4(work)) {
|
|
7095
|
+
return { available: false, reason: "flow-template work file is not a JSON object" };
|
|
7096
|
+
}
|
|
7097
|
+
const data = isRecord4(work.data) ? work.data : {};
|
|
7098
|
+
const meta = isRecord4(data.meta) ? data.meta : {};
|
|
7099
|
+
const nodes = flowTemplateNodes(work);
|
|
7100
|
+
const matrixOwnerNodes = nodes.filter((node) => JSON.stringify(node).includes("matrix_owner")).map((node) => ({
|
|
7101
|
+
id: stringValue(node.id),
|
|
7102
|
+
name: stringValue(node.name),
|
|
7103
|
+
type: stringValue(node.type)
|
|
7104
|
+
}));
|
|
7105
|
+
const ccMatrixNodes = nodes.filter((node) => JSON.stringify(node).includes("cc_matrix")).map((node) => ({
|
|
7106
|
+
id: stringValue(node.id),
|
|
7107
|
+
name: stringValue(node.name),
|
|
7108
|
+
type: stringValue(node.type)
|
|
7109
|
+
}));
|
|
7110
|
+
const publish = isRecord4(work.publish) ? work.publish : void 0;
|
|
7111
|
+
return {
|
|
7112
|
+
available: true,
|
|
7113
|
+
name: stringValue(work.name),
|
|
7114
|
+
flow_type: stringValue(work.flow_type),
|
|
7115
|
+
key: stringValue(work.key) ?? "",
|
|
7116
|
+
type: stringValue(work.type),
|
|
7117
|
+
status: work.status,
|
|
7118
|
+
publish_status: publish?.status ?? work.publish_status,
|
|
7119
|
+
meta_form_id: work.meta_form_id ?? meta.form_template,
|
|
7120
|
+
node_count: nodes.length,
|
|
7121
|
+
matrix_owner_node_count: matrixOwnerNodes.length,
|
|
7122
|
+
matrix_owner_nodes: matrixOwnerNodes,
|
|
7123
|
+
cc_matrix_node_count: ccMatrixNodes.length,
|
|
7124
|
+
cc_matrix_nodes: ccMatrixNodes
|
|
7125
|
+
};
|
|
7126
|
+
}
|
|
7068
7127
|
async function ensureValue(current, label, placeholder) {
|
|
7069
7128
|
if (current) {
|
|
7070
7129
|
return current;
|
|
@@ -7146,7 +7205,8 @@ function registerConfigCommands(program2) {
|
|
|
7146
7205
|
user: target.user || null
|
|
7147
7206
|
});
|
|
7148
7207
|
});
|
|
7149
|
-
config.command("adapters").description("Show typed config domain adapter coverage and verified API surfaces").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
7208
|
+
config.command("adapters").description("Show typed config domain adapter coverage and verified API surfaces").option("--profile <profile>", "Profile name (accepted for consistency; adapter coverage is local and profile-independent)").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
7209
|
+
void options.profile;
|
|
7150
7210
|
printResult(options.format, configAdapterMatrix());
|
|
7151
7211
|
});
|
|
7152
7212
|
const latest = config.command("latest").description("Sync latest BPMAX sysconfig repositories");
|
|
@@ -7250,11 +7310,21 @@ function registerConfigCommands(program2) {
|
|
|
7250
7310
|
await saveConfig(configData);
|
|
7251
7311
|
printResult(options.format, result);
|
|
7252
7312
|
});
|
|
7253
|
-
domainCommand.command("export").description(`Export remote ${domain} configuration into raw/work/meta files`).requiredOption("--id <id>", "Remote config id").option("--profile <profile>", "Profile name").option("--out <outDir>", "Output directory", `.codex/tmp/${domain}-editor`).option("--work-format <format>", "Work file format for supported domains: raw | structured", "raw").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
7313
|
+
domainCommand.command("export").description(`Export remote ${domain} configuration into raw/work/meta files`).requiredOption("--id <id>", "Remote config id").option("--profile <profile>", "Profile name").option("--out <outDir>", "Output directory", `.codex/tmp/${domain}-editor`).option("--work-format <format>", "Work file format for supported domains: raw | structured", "raw").option("--summary", "For flow-template, include a compact configuration summary in command output").option("--inline", "For flow-template, include the exported work JSON inline in command output").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
7254
7314
|
const configData = await loadConfig();
|
|
7255
7315
|
const resolved = resolveProfile(configData, options.profile);
|
|
7256
7316
|
const workFormat = options.workFormat === "structured" ? "structured" : "raw";
|
|
7257
7317
|
const result = await exportConfigDomain(configData, resolved, domain, options.id, options.out, { workFormat });
|
|
7318
|
+
if (domain === "flow-template" && (options.summary || options.inline)) {
|
|
7319
|
+
const workFile = typeof result.work_file === "string" ? result.work_file : void 0;
|
|
7320
|
+
const work = workFile ? await readJsonFile(workFile) : void 0;
|
|
7321
|
+
if (options.summary) {
|
|
7322
|
+
result.summary = summarizeFlowTemplateWork(work);
|
|
7323
|
+
}
|
|
7324
|
+
if (options.inline) {
|
|
7325
|
+
result.work = work;
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
7258
7328
|
await saveConfig(configData);
|
|
7259
7329
|
printResult(options.format, result);
|
|
7260
7330
|
});
|
|
@@ -7359,11 +7429,11 @@ function registerConfigCommands(program2) {
|
|
|
7359
7429
|
}
|
|
7360
7430
|
|
|
7361
7431
|
// src/core/project-search.ts
|
|
7362
|
-
function
|
|
7432
|
+
function isRecord5(value) {
|
|
7363
7433
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7364
7434
|
}
|
|
7365
7435
|
function hasRawProjectSearchBody(value) {
|
|
7366
|
-
return
|
|
7436
|
+
return isRecord5(value) && Object.prototype.hasOwnProperty.call(value, "body");
|
|
7367
7437
|
}
|
|
7368
7438
|
function assertProjectSearchBody(value) {
|
|
7369
7439
|
if (hasRawProjectSearchBody(value)) {
|
|
@@ -7923,6 +7993,38 @@ function isEmptyApproverValue(value) {
|
|
|
7923
7993
|
function shellQuote6(value) {
|
|
7924
7994
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
7925
7995
|
}
|
|
7996
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7997
|
+
function dataArray(value) {
|
|
7998
|
+
if (Array.isArray(value)) return value;
|
|
7999
|
+
if (isRecord6(value) && Array.isArray(value.data)) return value.data;
|
|
8000
|
+
return [];
|
|
8001
|
+
}
|
|
8002
|
+
function collectMatrixOwnerPaths(value, path11 = "$") {
|
|
8003
|
+
if (Array.isArray(value)) {
|
|
8004
|
+
return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${path11}[${index}]`));
|
|
8005
|
+
}
|
|
8006
|
+
if (!isRecord6(value)) {
|
|
8007
|
+
return [];
|
|
8008
|
+
}
|
|
8009
|
+
const matches = [];
|
|
8010
|
+
Object.entries(value).forEach(([key, child]) => {
|
|
8011
|
+
const childPath = `${path11}.${key}`;
|
|
8012
|
+
if (key.includes("matrix_owner") || typeof child === "string" && child.includes("matrix_owner")) {
|
|
8013
|
+
matches.push({ path: childPath, value: child });
|
|
8014
|
+
}
|
|
8015
|
+
matches.push(...collectMatrixOwnerPaths(child, childPath));
|
|
8016
|
+
});
|
|
8017
|
+
return matches;
|
|
8018
|
+
}
|
|
8019
|
+
function projectFormKeys(project) {
|
|
8020
|
+
const metaForm = isRecord6(project.metaForm) ? project.metaForm : {};
|
|
8021
|
+
const values = dataArray(metaForm.value ?? project.formList);
|
|
8022
|
+
return values.filter(isRecord6).map((item) => String(item.key ?? item.field_key ?? "")).filter(Boolean);
|
|
8023
|
+
}
|
|
8024
|
+
function findFlowNode(flow, nodeId) {
|
|
8025
|
+
const data = isRecord6(flow.data) ? flow.data : {};
|
|
8026
|
+
return dataArray(data.nodes).filter(isRecord6).find((node) => String(node.id ?? node.key ?? node.flow_step_id ?? "") === nodeId);
|
|
8027
|
+
}
|
|
7926
8028
|
function registerMatrixCommands(program2) {
|
|
7927
8029
|
const matrix = program2.command("matrix").description("Plan and validate BPMAX approval matrix operations");
|
|
7928
8030
|
matrix.command("seed <flowType>").description("Validate approval matrix seed rule records and print safe project create commands").requiredOption("--rules <jsonOrFile>", "Seed rule object/array JSON or @file").option("--profile <profile>", "Profile name").option("--approver-field <field...>", "Required approver field key(s) inside each rule form").option("--format <format>", "Output format", "pretty").action(async (flowType, options) => {
|
|
@@ -7975,6 +8077,49 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
7975
8077
|
]
|
|
7976
8078
|
});
|
|
7977
8079
|
});
|
|
8080
|
+
matrix.command("owner-resolve").description("Inspect matrix_owner configuration inputs for one flow node and project").requiredOption("--flow-type <flowType>", "Business flow type").requiredOption("--node <nodeId>", "Flow node id/key to inspect").requiredOption("--project-id <projectId>", "Runtime project id used as matrix input context").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
8081
|
+
const config = await loadConfig();
|
|
8082
|
+
const profile = resolveProfile(config, options.profile);
|
|
8083
|
+
const client = createApiClient(profile);
|
|
8084
|
+
const [project, flow] = await Promise.all([
|
|
8085
|
+
apiRequest(client, "GET", `/project/${encodeURIComponent(options.projectId)}`),
|
|
8086
|
+
apiRequest(client, "GET", "/flow", {
|
|
8087
|
+
params: {
|
|
8088
|
+
flow_type: options.flowType,
|
|
8089
|
+
draft: 0,
|
|
8090
|
+
skip_i18n: true
|
|
8091
|
+
}
|
|
8092
|
+
})
|
|
8093
|
+
]);
|
|
8094
|
+
const node = findFlowNode(flow, options.node);
|
|
8095
|
+
const matrixOwnerConfig = node ? collectMatrixOwnerPaths(node) : [];
|
|
8096
|
+
printResult(options.format, {
|
|
8097
|
+
domain: "approval-matrix",
|
|
8098
|
+
action: "owner-resolve",
|
|
8099
|
+
flow_type: options.flowType,
|
|
8100
|
+
node: options.node,
|
|
8101
|
+
project_id: options.projectId,
|
|
8102
|
+
config_found: matrixOwnerConfig.length > 0,
|
|
8103
|
+
runtime_owner_verified: false,
|
|
8104
|
+
flow_node: node ? {
|
|
8105
|
+
id: node.id,
|
|
8106
|
+
name: node.name,
|
|
8107
|
+
type: node.type
|
|
8108
|
+
} : null,
|
|
8109
|
+
matrix_owner_config: matrixOwnerConfig,
|
|
8110
|
+
project_context: {
|
|
8111
|
+
id: project.id,
|
|
8112
|
+
name: project.name,
|
|
8113
|
+
form_keys: projectFormKeys(project)
|
|
8114
|
+
},
|
|
8115
|
+
notes: [
|
|
8116
|
+
"This command is read-only and does not write matrix rule records.",
|
|
8117
|
+
"If matrix_owner_config is empty, the target node is not configured for matrix owner resolution or the node id is wrong.",
|
|
8118
|
+
"config_found only means matrix_owner-like config exists on the node; it does not prove runtime owner resolution.",
|
|
8119
|
+
"Use bpmax-cli matrix seed to validate rule seed data before creating matrix rule project records."
|
|
8120
|
+
]
|
|
8121
|
+
});
|
|
8122
|
+
});
|
|
7978
8123
|
}
|
|
7979
8124
|
|
|
7980
8125
|
// src/core/form-schema.ts
|
|
@@ -7996,7 +8141,7 @@ var OPTION_NAMES = ["options", "items", "choices", "values"];
|
|
|
7996
8141
|
var REQUIRED_NAMES = ["required", "is_required", "isRequired", "require", "must", "validateRequired"];
|
|
7997
8142
|
var HIDDEN_NAMES = ["hidden", "is_hidden", "isHidden", "hide", "hideInForm"];
|
|
7998
8143
|
var VISIBLE_NAMES = ["visible", "display", "show"];
|
|
7999
|
-
function
|
|
8144
|
+
function isRecord7(value) {
|
|
8000
8145
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8001
8146
|
}
|
|
8002
8147
|
function pickString(source, keys) {
|
|
@@ -8023,10 +8168,10 @@ function pickBoolean(source, keys) {
|
|
|
8023
8168
|
}
|
|
8024
8169
|
const rules = source.rules;
|
|
8025
8170
|
if (Array.isArray(rules)) {
|
|
8026
|
-
return rules.some((rule) =>
|
|
8171
|
+
return rules.some((rule) => isRecord7(rule) && pickBoolean(rule, REQUIRED_NAMES));
|
|
8027
8172
|
}
|
|
8028
8173
|
const validateMap = source.validateMap;
|
|
8029
|
-
if (
|
|
8174
|
+
if (isRecord7(validateMap) && pickBoolean(validateMap, REQUIRED_NAMES)) {
|
|
8030
8175
|
return true;
|
|
8031
8176
|
}
|
|
8032
8177
|
return false;
|
|
@@ -8050,7 +8195,7 @@ function optionValue(option) {
|
|
|
8050
8195
|
if (typeof option === "string" || typeof option === "number") {
|
|
8051
8196
|
return String(option);
|
|
8052
8197
|
}
|
|
8053
|
-
if (!
|
|
8198
|
+
if (!isRecord7(option)) {
|
|
8054
8199
|
return null;
|
|
8055
8200
|
}
|
|
8056
8201
|
return pickString(option, ["value", "key", "id", "name", "label", "title"]) ?? null;
|
|
@@ -8115,7 +8260,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
8115
8260
|
}
|
|
8116
8261
|
return;
|
|
8117
8262
|
}
|
|
8118
|
-
if (!
|
|
8263
|
+
if (!isRecord7(value)) {
|
|
8119
8264
|
return;
|
|
8120
8265
|
}
|
|
8121
8266
|
const field = fieldFromRecord(value);
|
|
@@ -8123,7 +8268,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
8123
8268
|
if (isSubFormField(field)) {
|
|
8124
8269
|
const childFields = /* @__PURE__ */ new Map();
|
|
8125
8270
|
for (const child of Object.values(value)) {
|
|
8126
|
-
if (
|
|
8271
|
+
if (isRecord7(child) || Array.isArray(child)) {
|
|
8127
8272
|
collectFieldCandidates(child, childFields, depth + 1);
|
|
8128
8273
|
}
|
|
8129
8274
|
}
|
|
@@ -8137,7 +8282,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
8137
8282
|
fields.set(field.key, mergeField(fields.get(field.key), field));
|
|
8138
8283
|
}
|
|
8139
8284
|
for (const child of Object.values(value)) {
|
|
8140
|
-
if (
|
|
8285
|
+
if (isRecord7(child) || Array.isArray(child)) {
|
|
8141
8286
|
collectFieldCandidates(child, fields, depth + 1);
|
|
8142
8287
|
}
|
|
8143
8288
|
}
|
|
@@ -8155,7 +8300,7 @@ function validateComplexSelector(field, value) {
|
|
|
8155
8300
|
if (!isComplexSelectorType(type)) {
|
|
8156
8301
|
return null;
|
|
8157
8302
|
}
|
|
8158
|
-
const validObject = (item) =>
|
|
8303
|
+
const validObject = (item) => isRecord7(item);
|
|
8159
8304
|
if (Array.isArray(value)) {
|
|
8160
8305
|
return value.every(validObject) ? null : `${field.key} must contain selector option object(s), not scalar values`;
|
|
8161
8306
|
}
|
|
@@ -8171,7 +8316,7 @@ function isEnumSelectType(type) {
|
|
|
8171
8316
|
return /enum_select/.test(type);
|
|
8172
8317
|
}
|
|
8173
8318
|
function optionComparableValue(value) {
|
|
8174
|
-
if (
|
|
8319
|
+
if (isRecord7(value) && ("value" in value || "label" in value)) {
|
|
8175
8320
|
return value.value ?? value.label;
|
|
8176
8321
|
}
|
|
8177
8322
|
return value;
|
|
@@ -8185,7 +8330,7 @@ function validateType(field, value) {
|
|
|
8185
8330
|
if (!Array.isArray(value)) {
|
|
8186
8331
|
return `${field.key} must be a JSON array of row objects`;
|
|
8187
8332
|
}
|
|
8188
|
-
const invalidRowIndex = value.findIndex((row) => !
|
|
8333
|
+
const invalidRowIndex = value.findIndex((row) => !isRecord7(row));
|
|
8189
8334
|
return invalidRowIndex >= 0 ? `${field.key}[${invalidRowIndex}] must be a row object` : null;
|
|
8190
8335
|
}
|
|
8191
8336
|
const selectorError = validateComplexSelector(field, value);
|
|
@@ -8211,7 +8356,7 @@ function validateType(field, value) {
|
|
|
8211
8356
|
if (/(array|multi|multiple)/.test(type) && !Array.isArray(value)) {
|
|
8212
8357
|
return `${field.key} must be an array`;
|
|
8213
8358
|
}
|
|
8214
|
-
if (isEnumSelectType(type) &&
|
|
8359
|
+
if (isEnumSelectType(type) && isRecord7(value)) {
|
|
8215
8360
|
const optionValue2 = value.value ?? value.label;
|
|
8216
8361
|
return typeof optionValue2 === "string" || typeof optionValue2 === "number" ? null : `${field.key} must be an enum option object with a scalar value`;
|
|
8217
8362
|
}
|
|
@@ -8241,7 +8386,7 @@ function validateFormEntries(form, fields, prefix = "") {
|
|
|
8241
8386
|
}
|
|
8242
8387
|
if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
|
|
8243
8388
|
for (const [index, row] of value.entries()) {
|
|
8244
|
-
if (
|
|
8389
|
+
if (isRecord7(row)) {
|
|
8245
8390
|
errors.push(...validateFormEntries(row, field.children, `${prefix}${field.key}[${index}].`));
|
|
8246
8391
|
}
|
|
8247
8392
|
}
|
|
@@ -8464,15 +8609,15 @@ async function promptProjectCreateForm(input) {
|
|
|
8464
8609
|
}
|
|
8465
8610
|
|
|
8466
8611
|
// src/core/project-form.ts
|
|
8467
|
-
function
|
|
8612
|
+
function isRecord8(value) {
|
|
8468
8613
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8469
8614
|
}
|
|
8470
8615
|
function clone(value) {
|
|
8471
8616
|
return JSON.parse(JSON.stringify(value));
|
|
8472
8617
|
}
|
|
8473
8618
|
function getFlowFormTemplateId(flowDetail) {
|
|
8474
|
-
const data =
|
|
8475
|
-
const meta =
|
|
8619
|
+
const data = isRecord8(flowDetail?.data) ? flowDetail.data : void 0;
|
|
8620
|
+
const meta = isRecord8(data?.meta) ? data.meta : void 0;
|
|
8476
8621
|
const templateId = meta?.form_template;
|
|
8477
8622
|
if (typeof templateId === "number" && Number.isFinite(templateId)) {
|
|
8478
8623
|
return templateId;
|
|
@@ -8497,7 +8642,7 @@ function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
8497
8642
|
if (Array.isArray(value)) {
|
|
8498
8643
|
return value.some((item) => hasAutoInitLambda(item, seen));
|
|
8499
8644
|
}
|
|
8500
|
-
if (!
|
|
8645
|
+
if (!isRecord8(value)) {
|
|
8501
8646
|
return false;
|
|
8502
8647
|
}
|
|
8503
8648
|
if (seen.has(value)) {
|
|
@@ -8512,14 +8657,14 @@ function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
8512
8657
|
function setControlValue(control, value) {
|
|
8513
8658
|
const next = clone(control);
|
|
8514
8659
|
next.value = {
|
|
8515
|
-
...
|
|
8660
|
+
...isRecord8(next.value) ? next.value : {},
|
|
8516
8661
|
type: next.value?.type ?? next.field_type,
|
|
8517
8662
|
value
|
|
8518
8663
|
};
|
|
8519
8664
|
return next;
|
|
8520
8665
|
}
|
|
8521
8666
|
function applyRowValues(rowTemplate, rowValue) {
|
|
8522
|
-
const source =
|
|
8667
|
+
const source = isRecord8(rowValue) ? rowValue : {};
|
|
8523
8668
|
return rowTemplate.map((control) => {
|
|
8524
8669
|
if (control.key && Object.prototype.hasOwnProperty.call(source, control.key)) {
|
|
8525
8670
|
return setControlValue(control, source[control.key]);
|
|
@@ -8581,6 +8726,12 @@ async function parseProjectJson(input, label = "--json") {
|
|
|
8581
8726
|
}
|
|
8582
8727
|
return parseJsonInput(input, label);
|
|
8583
8728
|
}
|
|
8729
|
+
function errorMessage2(error) {
|
|
8730
|
+
return error instanceof Error ? error.message : String(error || "");
|
|
8731
|
+
}
|
|
8732
|
+
function isUnsupportedPrefillStatusError(message) {
|
|
8733
|
+
return /(^|[^0-9])404([^0-9]|$)/.test(message) || /not found/i.test(message) || /unsupported/i.test(message) || /Cannot GET \/api\/project_staging\/prefill/i.test(message);
|
|
8734
|
+
}
|
|
8584
8735
|
async function resolveFlowIdentifiers(client, options, resolveOptions = {}) {
|
|
8585
8736
|
if (options.flowType) {
|
|
8586
8737
|
const flowKey = options.flowKey ?? "";
|
|
@@ -8802,8 +8953,8 @@ function fieldsForValidation(flowDetail, projectFormTemplate) {
|
|
|
8802
8953
|
}));
|
|
8803
8954
|
}
|
|
8804
8955
|
function metaUsesTemplateProjectName(flowDetail) {
|
|
8805
|
-
const data =
|
|
8806
|
-
const meta =
|
|
8956
|
+
const data = isRecord9(flowDetail?.data) ? flowDetail.data : void 0;
|
|
8957
|
+
const meta = isRecord9(data?.meta) ? data.meta : void 0;
|
|
8807
8958
|
const hideFields = Array.isArray(meta?.hide_fields) ? meta.hide_fields.map(String) : [];
|
|
8808
8959
|
return meta?.use_template_project_name === true || hideFields.includes("project.name");
|
|
8809
8960
|
}
|
|
@@ -8893,7 +9044,7 @@ function collectPrefillContextForFields(fields, form, result, options = {}) {
|
|
|
8893
9044
|
result.filled_fields.push(contextField(field, "prefilled", fieldOptions));
|
|
8894
9045
|
if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
|
|
8895
9046
|
value.forEach((row, index) => {
|
|
8896
|
-
if (
|
|
9047
|
+
if (isRecord9(row)) {
|
|
8897
9048
|
collectPrefillContextForFields(field.children ?? [], row, result, {
|
|
8898
9049
|
prefix: `${field.key}[${index}]`,
|
|
8899
9050
|
rootKey: field.key,
|
|
@@ -8920,7 +9071,7 @@ function buildPrefillContext(fields, form) {
|
|
|
8920
9071
|
}
|
|
8921
9072
|
};
|
|
8922
9073
|
}
|
|
8923
|
-
function
|
|
9074
|
+
function isRecord9(value) {
|
|
8924
9075
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8925
9076
|
}
|
|
8926
9077
|
function isEndedStep(step) {
|
|
@@ -8943,7 +9094,7 @@ function stepIdOf(step) {
|
|
|
8943
9094
|
function pickStepFormPayload(step) {
|
|
8944
9095
|
const formList = Array.isArray(step.formList) ? step.formList : [];
|
|
8945
9096
|
const forms = Array.isArray(step.forms) ? step.forms : [];
|
|
8946
|
-
const metaForm =
|
|
9097
|
+
const metaForm = isRecord9(step.metaForm) ? step.metaForm : void 0;
|
|
8947
9098
|
return {
|
|
8948
9099
|
step_id: step.id,
|
|
8949
9100
|
flow_step_id: step.flow_step_id,
|
|
@@ -8960,7 +9111,7 @@ function pickStepFormPayload(step) {
|
|
|
8960
9111
|
}
|
|
8961
9112
|
async function buildApprovalContext(client, projectId, options) {
|
|
8962
9113
|
const projectDetail = await apiRequest(client, "GET", `/project/${projectId}`);
|
|
8963
|
-
const steps = Array.isArray(projectDetail.steps) ? projectDetail.steps.filter(
|
|
9114
|
+
const steps = Array.isArray(projectDetail.steps) ? projectDetail.steps.filter(isRecord9) : [];
|
|
8964
9115
|
const targetStepIds = /* @__PURE__ */ new Set();
|
|
8965
9116
|
for (const step of steps) {
|
|
8966
9117
|
const id = stepIdOf(step);
|
|
@@ -8986,7 +9137,7 @@ async function buildApprovalContext(client, projectId, options) {
|
|
|
8986
9137
|
}
|
|
8987
9138
|
return {
|
|
8988
9139
|
project: projectDetail,
|
|
8989
|
-
project_form:
|
|
9140
|
+
project_form: isRecord9(projectDetail.metaForm) ? projectDetail.metaForm : null,
|
|
8990
9141
|
inspected_step_count: stepForms.length,
|
|
8991
9142
|
step_forms: stepForms,
|
|
8992
9143
|
failed_steps: failedSteps
|
|
@@ -9042,13 +9193,14 @@ function registerProjectCommands(program2) {
|
|
|
9042
9193
|
);
|
|
9043
9194
|
printResult(options.format, attachProjectDetailUrl(profile, result));
|
|
9044
9195
|
});
|
|
9045
|
-
project.command("my-step").description("List my pending project steps").option("--profile <profile>", "Profile name").option("--finished <finished>", "Finished flag", "0").option("--flow-type <flowType>", "Flow type filter").option("--flow-key <flowKey>", "Flow key filter").option("--key-of-flow-node <keyOfFlowNode>", "Flow/node filter, e.g. flow_type:flow_key or flow_type:flow_key:node_id").option("--flow-step-id <flowStepId>", "Flow node id filter").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
9196
|
+
project.command("my-step").description("List my pending project steps").option("--profile <profile>", "Profile name").option("--finished <finished>", "Finished flag", "0").option("--flow-type <flowType>", "Flow type filter").option("--flow-key <flowKey>", "Flow key filter").option("--key-of-flow-node <keyOfFlowNode>", "Flow/node filter, e.g. flow_type:flow_key or flow_type:flow_key:node_id").option("--flow-step-id <flowStepId>", "Flow node id filter").option("--workspace <workspace>", "Workspace filter, defaults to the active profile workspace").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
9046
9197
|
const config = await loadConfig();
|
|
9047
9198
|
const profile = resolveProfile(config, options.profile);
|
|
9048
9199
|
const params = {
|
|
9049
9200
|
finished: options.finished,
|
|
9050
9201
|
page: Number(options.page),
|
|
9051
|
-
page_size: Number(options.pageSize)
|
|
9202
|
+
page_size: Number(options.pageSize),
|
|
9203
|
+
$workspace: normalizeWorkspaceForApi(options.workspace ?? profile.config.workspace)
|
|
9052
9204
|
};
|
|
9053
9205
|
if (options.flowType) {
|
|
9054
9206
|
params.flow_type = options.flowType;
|
|
@@ -9083,7 +9235,44 @@ function registerProjectCommands(program2) {
|
|
|
9083
9235
|
project: attachProjectDetailUrl(profile, context.project)
|
|
9084
9236
|
});
|
|
9085
9237
|
});
|
|
9086
|
-
|
|
9238
|
+
const handoff = project.command("handoff").description("Inspect BPMAX project create-page handoff state");
|
|
9239
|
+
handoff.command("status").description("Check whether a create-page prefill token is still readable by the platform").requiredOption("--prefill-token <token>", "Prefill token returned by project create handoff output").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
9240
|
+
const config = await loadConfig();
|
|
9241
|
+
const profile = resolveProfile(config, options.profile);
|
|
9242
|
+
const client = createApiClient(profile);
|
|
9243
|
+
const token = options.prefillToken.trim();
|
|
9244
|
+
if (!token) {
|
|
9245
|
+
throw new Error("--prefill-token cannot be empty.");
|
|
9246
|
+
}
|
|
9247
|
+
try {
|
|
9248
|
+
const result = await apiRequest(
|
|
9249
|
+
client,
|
|
9250
|
+
"GET",
|
|
9251
|
+
`/project_staging/prefill/${encodeURIComponent(token)}`
|
|
9252
|
+
);
|
|
9253
|
+
printResult(options.format, {
|
|
9254
|
+
ok: true,
|
|
9255
|
+
prefill_token: token,
|
|
9256
|
+
supported: true,
|
|
9257
|
+
browser_verified: false,
|
|
9258
|
+
result,
|
|
9259
|
+
next_action: "Token lookup only proves the prefill payload is readable; open the returned handoff URL in a real browser page before claiming creation succeeded."
|
|
9260
|
+
});
|
|
9261
|
+
} catch (error) {
|
|
9262
|
+
const message = errorMessage2(error);
|
|
9263
|
+
if (!isUnsupportedPrefillStatusError(message)) {
|
|
9264
|
+
throw error;
|
|
9265
|
+
}
|
|
9266
|
+
printResult(options.format, {
|
|
9267
|
+
ok: false,
|
|
9268
|
+
prefill_token: token,
|
|
9269
|
+
supported: false,
|
|
9270
|
+
error: message,
|
|
9271
|
+
next_action: "If this platform does not expose prefill token status, verify the returned handoff URL in a real browser page before claiming creation succeeded."
|
|
9272
|
+
});
|
|
9273
|
+
}
|
|
9274
|
+
});
|
|
9275
|
+
project.command("create").description("Minimal project create shortcut").option("--profile <profile>", "Profile name").option("--flow-id <flowId>", "Flow id").option("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key", "").option("--name <name>", "Project name").option("--json <json>", "Additional request JSON").option("--body <body>", "Full request body JSON override").option("--unsafe-direct-create", "Allow raw --body direct project creation without form-template safety checks").option("--interactive", "Guide the user through filling project form fields").option("--no-interactive", "Disable the project create guide and submit directly when safe").option("--allow-form-handoff", "Allow interactive mode to hand off to the BPMAX web create form").option("--handoff-only", "Return a prefilled BPMAX create-page handoff URL without prompting or direct project creation").option("--skip-form-validation", "Skip local form schema validation before submit").option("--format <format>", "Output format", "pretty").action(async (options, command) => {
|
|
9087
9276
|
const interactiveSource = command.getOptionValueSource("interactive");
|
|
9088
9277
|
if (options.body && options.interactive === true && interactiveSource === "cli") {
|
|
9089
9278
|
throw new Error("--body and --interactive cannot be used together.");
|
|
@@ -9118,6 +9307,19 @@ function registerProjectCommands(program2) {
|
|
|
9118
9307
|
return projectFormTemplate;
|
|
9119
9308
|
};
|
|
9120
9309
|
const usesTemplateProjectName = metaUsesTemplateProjectName(flowDetail);
|
|
9310
|
+
if (options.handoffOnly) {
|
|
9311
|
+
projectFormTemplate = await loadProjectFormTemplate();
|
|
9312
|
+
const handoffFields2 = fieldsForValidation(flowDetail, projectFormTemplate);
|
|
9313
|
+
assertHandoffFormCompatible(handoffFields2, form);
|
|
9314
|
+
await printCreateFormHandoff(client, options.format, profile, flowIdentifiers, {
|
|
9315
|
+
name: name ?? "",
|
|
9316
|
+
form,
|
|
9317
|
+
fields: handoffFields2,
|
|
9318
|
+
reason: "handoff_only",
|
|
9319
|
+
message: "\u5DF2\u751F\u6210 BPMAX \u521B\u5EFA\u9875\u94FE\u63A5\uFF0C\u8BF7\u70B9\u51FB\u7EE7\u7EED\u586B\u5199\u5E76\u63D0\u4EA4\u3002"
|
|
9320
|
+
});
|
|
9321
|
+
return;
|
|
9322
|
+
}
|
|
9121
9323
|
if (useInteractive) {
|
|
9122
9324
|
if (!flowDetail) {
|
|
9123
9325
|
throw new Error("Interactive project creation requires --flow-id so the form schema can be discovered.");
|
|
@@ -9265,7 +9467,7 @@ function getRecipesDir(options) {
|
|
|
9265
9467
|
const workspaceDirName = normalizeWorkspaceForPath(options.workspace || DEFAULT_WORKSPACE);
|
|
9266
9468
|
return path7.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
|
|
9267
9469
|
}
|
|
9268
|
-
function
|
|
9470
|
+
function isRecord10(value) {
|
|
9269
9471
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9270
9472
|
}
|
|
9271
9473
|
function asString(value, fieldName) {
|
|
@@ -9275,7 +9477,7 @@ function asString(value, fieldName) {
|
|
|
9275
9477
|
return value;
|
|
9276
9478
|
}
|
|
9277
9479
|
function parseRecipeDefinition(input) {
|
|
9278
|
-
if (!
|
|
9480
|
+
if (!isRecord10(input)) {
|
|
9279
9481
|
throw new Error("recipe.json must be a JSON object.");
|
|
9280
9482
|
}
|
|
9281
9483
|
if (input.version !== 1) {
|
|
@@ -9283,7 +9485,7 @@ function parseRecipeDefinition(input) {
|
|
|
9283
9485
|
}
|
|
9284
9486
|
const name = asString(input.name, "recipe.name");
|
|
9285
9487
|
assertSafeName("Recipe name", name);
|
|
9286
|
-
if (!
|
|
9488
|
+
if (!isRecord10(input.command)) {
|
|
9287
9489
|
throw new Error("recipe.command must be an object.");
|
|
9288
9490
|
}
|
|
9289
9491
|
const argv = input.command.argv;
|
|
@@ -9291,7 +9493,7 @@ function parseRecipeDefinition(input) {
|
|
|
9291
9493
|
throw new Error("recipe.command.argv must be a non-empty string array.");
|
|
9292
9494
|
}
|
|
9293
9495
|
const variables = Array.isArray(input.variables) ? input.variables.map((item, index) => {
|
|
9294
|
-
if (!
|
|
9496
|
+
if (!isRecord10(item)) {
|
|
9295
9497
|
throw new Error(`recipe.variables[${index}] must be an object.`);
|
|
9296
9498
|
}
|
|
9297
9499
|
const variableName = asString(item.name, `recipe.variables[${index}].name`);
|
|
@@ -9367,7 +9569,7 @@ function parseVarsJson(input) {
|
|
|
9367
9569
|
return {};
|
|
9368
9570
|
}
|
|
9369
9571
|
const parsed = JSON.parse(input);
|
|
9370
|
-
if (!
|
|
9572
|
+
if (!isRecord10(parsed)) {
|
|
9371
9573
|
throw new Error("--vars must be a JSON object.");
|
|
9372
9574
|
}
|
|
9373
9575
|
const variables = {};
|
|
@@ -9866,10 +10068,10 @@ function registerSetupCommand(program2, deps = {}) {
|
|
|
9866
10068
|
}
|
|
9867
10069
|
|
|
9868
10070
|
// src/commands/step.ts
|
|
9869
|
-
function
|
|
10071
|
+
function isRecord11(value) {
|
|
9870
10072
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9871
10073
|
}
|
|
9872
|
-
function
|
|
10074
|
+
function stringValue2(value) {
|
|
9873
10075
|
if (value === void 0 || value === null) {
|
|
9874
10076
|
return void 0;
|
|
9875
10077
|
}
|
|
@@ -9877,7 +10079,7 @@ function stringValue(value) {
|
|
|
9877
10079
|
return next ? next : void 0;
|
|
9878
10080
|
}
|
|
9879
10081
|
function idValue(value) {
|
|
9880
|
-
const next =
|
|
10082
|
+
const next = stringValue2(value);
|
|
9881
10083
|
return next && /^\d+$/.test(next) ? next : void 0;
|
|
9882
10084
|
}
|
|
9883
10085
|
function hasMeaningfulValue(value) {
|
|
@@ -9893,7 +10095,7 @@ function hasMeaningfulValue(value) {
|
|
|
9893
10095
|
if (Array.isArray(value)) {
|
|
9894
10096
|
return value.some(hasMeaningfulValue);
|
|
9895
10097
|
}
|
|
9896
|
-
if (
|
|
10098
|
+
if (isRecord11(value)) {
|
|
9897
10099
|
return Object.values(value).some(hasMeaningfulValue);
|
|
9898
10100
|
}
|
|
9899
10101
|
return false;
|
|
@@ -9902,11 +10104,11 @@ function isEmptyValue2(value) {
|
|
|
9902
10104
|
return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
9903
10105
|
}
|
|
9904
10106
|
function projectIdOfStep(step) {
|
|
9905
|
-
const nestedProjectId =
|
|
10107
|
+
const nestedProjectId = isRecord11(step.project) ? step.project.id : void 0;
|
|
9906
10108
|
return idValue(step.project_id ?? step.projectId ?? nestedProjectId);
|
|
9907
10109
|
}
|
|
9908
10110
|
function stepFlowNodeId(step) {
|
|
9909
|
-
return
|
|
10111
|
+
return stringValue2(step.flow_step_id ?? step.flowStepId ?? step.flow_node_id ?? step.flowNodeId);
|
|
9910
10112
|
}
|
|
9911
10113
|
function isStepFinished(step) {
|
|
9912
10114
|
if (step.real_end_time || step.end_time) {
|
|
@@ -9930,18 +10132,18 @@ function collectRecords(value, output = [], seen = /* @__PURE__ */ new Set()) {
|
|
|
9930
10132
|
value.forEach((item) => collectRecords(item, output, seen));
|
|
9931
10133
|
return output;
|
|
9932
10134
|
}
|
|
9933
|
-
if (!
|
|
10135
|
+
if (!isRecord11(value)) {
|
|
9934
10136
|
return output;
|
|
9935
10137
|
}
|
|
9936
10138
|
output.push(value);
|
|
9937
10139
|
for (const child of Object.values(value)) {
|
|
9938
|
-
if (Array.isArray(child) ||
|
|
10140
|
+
if (Array.isArray(child) || isRecord11(child)) {
|
|
9939
10141
|
collectRecords(child, output, seen);
|
|
9940
10142
|
}
|
|
9941
10143
|
}
|
|
9942
10144
|
return output;
|
|
9943
10145
|
}
|
|
9944
|
-
function
|
|
10146
|
+
function findFlowNode2(project, step) {
|
|
9945
10147
|
const flowStepId = stepFlowNodeId(step);
|
|
9946
10148
|
if (!flowStepId) {
|
|
9947
10149
|
return null;
|
|
@@ -9957,7 +10159,7 @@ function findFlowNode(project, step) {
|
|
|
9957
10159
|
project.config
|
|
9958
10160
|
];
|
|
9959
10161
|
for (const candidate of candidates) {
|
|
9960
|
-
const match = collectRecords(candidate).find((item) =>
|
|
10162
|
+
const match = collectRecords(candidate).find((item) => stringValue2(item.id) === flowStepId);
|
|
9961
10163
|
if (match) {
|
|
9962
10164
|
return match;
|
|
9963
10165
|
}
|
|
@@ -10019,7 +10221,7 @@ function formListOfStep(step) {
|
|
|
10019
10221
|
return values.filter(hasMeaningfulValue);
|
|
10020
10222
|
}
|
|
10021
10223
|
function unwrapFormValue(value) {
|
|
10022
|
-
if (!
|
|
10224
|
+
if (!isRecord11(value)) {
|
|
10023
10225
|
return value;
|
|
10024
10226
|
}
|
|
10025
10227
|
if ("value" in value && Object.keys(value).length <= 3) {
|
|
@@ -10036,10 +10238,10 @@ function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set())
|
|
|
10036
10238
|
value.forEach((item) => collectFormValues(item, output, seen));
|
|
10037
10239
|
return output;
|
|
10038
10240
|
}
|
|
10039
|
-
if (!
|
|
10241
|
+
if (!isRecord11(value)) {
|
|
10040
10242
|
return output;
|
|
10041
10243
|
}
|
|
10042
|
-
const key =
|
|
10244
|
+
const key = stringValue2(value.key ?? value.field_key ?? value.fieldKey ?? value.name);
|
|
10043
10245
|
if (key && "value" in value) {
|
|
10044
10246
|
const nextValue = unwrapFormValue(value.value);
|
|
10045
10247
|
if (hasMeaningfulValue(nextValue)) {
|
|
@@ -10047,7 +10249,7 @@ function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set())
|
|
|
10047
10249
|
}
|
|
10048
10250
|
}
|
|
10049
10251
|
for (const child of Object.values(value)) {
|
|
10050
|
-
if (Array.isArray(child) ||
|
|
10252
|
+
if (Array.isArray(child) || isRecord11(child)) {
|
|
10051
10253
|
collectFormValues(child, output, seen);
|
|
10052
10254
|
}
|
|
10053
10255
|
}
|
|
@@ -10094,7 +10296,7 @@ function collectMissingRequiredInputs(fields, values) {
|
|
|
10094
10296
|
continue;
|
|
10095
10297
|
}
|
|
10096
10298
|
value.forEach((row, index) => {
|
|
10097
|
-
if (!
|
|
10299
|
+
if (!isRecord11(row)) {
|
|
10098
10300
|
return;
|
|
10099
10301
|
}
|
|
10100
10302
|
for (const child of field.children ?? []) {
|
|
@@ -10149,7 +10351,7 @@ function ownerIdsFromStep(step) {
|
|
|
10149
10351
|
];
|
|
10150
10352
|
const ids = /* @__PURE__ */ new Set();
|
|
10151
10353
|
for (const owner of owners) {
|
|
10152
|
-
if (
|
|
10354
|
+
if (isRecord11(owner)) {
|
|
10153
10355
|
const id = idValue(owner.owner_id ?? owner.user_id ?? owner.id);
|
|
10154
10356
|
if (id) {
|
|
10155
10357
|
ids.add(id);
|
|
@@ -10163,6 +10365,47 @@ function ownerIdsFromStep(step) {
|
|
|
10163
10365
|
}
|
|
10164
10366
|
return [...ids];
|
|
10165
10367
|
}
|
|
10368
|
+
function ownerDiagnosticsFromStep(step, currentUser) {
|
|
10369
|
+
const sources = [
|
|
10370
|
+
{ source: "owner_id", value: step.owner_id },
|
|
10371
|
+
{ source: "ownerId", value: step.ownerId },
|
|
10372
|
+
{ source: "user_id", value: step.user_id },
|
|
10373
|
+
{ source: "userId", value: step.userId },
|
|
10374
|
+
{ source: "owners", value: step.owners },
|
|
10375
|
+
{ source: "owner_list", value: step.owner_list },
|
|
10376
|
+
{ source: "step_owners", value: step.step_owners }
|
|
10377
|
+
];
|
|
10378
|
+
const ownerIds = /* @__PURE__ */ new Set();
|
|
10379
|
+
const ownerSources = /* @__PURE__ */ new Set();
|
|
10380
|
+
const emptyOwnerArrays = [];
|
|
10381
|
+
for (const { source, value } of sources) {
|
|
10382
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
10383
|
+
emptyOwnerArrays.push(source);
|
|
10384
|
+
}
|
|
10385
|
+
const values = Array.isArray(value) ? value : [value];
|
|
10386
|
+
for (const item of values) {
|
|
10387
|
+
let id;
|
|
10388
|
+
if (isRecord11(item)) {
|
|
10389
|
+
id = idValue(item.owner_id ?? item.user_id ?? item.id);
|
|
10390
|
+
} else {
|
|
10391
|
+
id = idValue(item);
|
|
10392
|
+
}
|
|
10393
|
+
if (id) {
|
|
10394
|
+
ownerIds.add(id);
|
|
10395
|
+
ownerSources.add(source);
|
|
10396
|
+
}
|
|
10397
|
+
}
|
|
10398
|
+
}
|
|
10399
|
+
const currentUserId = currentUser ? idValue(currentUser.id ?? currentUser.user_id ?? currentUser.owner_id) : void 0;
|
|
10400
|
+
return {
|
|
10401
|
+
explicit_owner_ids: [...ownerIds],
|
|
10402
|
+
owner_sources: [...ownerSources],
|
|
10403
|
+
...currentUserId ? { current_user_id: currentUserId } : {},
|
|
10404
|
+
current_user_matched_explicit_owner: currentUserId ? ownerIds.has(currentUserId) : null,
|
|
10405
|
+
empty_owner_arrays: emptyOwnerArrays,
|
|
10406
|
+
...ownerIds.size === 0 ? { note: "No explicit step owner ids were returned; processability may come from admin fallback, permission fallback, or unresolved matrix owner behavior." } : {}
|
|
10407
|
+
};
|
|
10408
|
+
}
|
|
10166
10409
|
function checkCurrentUserCanProcess(step, currentUser) {
|
|
10167
10410
|
const ownerIds = ownerIdsFromStep(step);
|
|
10168
10411
|
if (ownerIds.length === 0) {
|
|
@@ -10193,11 +10436,12 @@ async function buildStepContext(profile, client, stepId, projectId) {
|
|
|
10193
10436
|
if (actualProjectId && actualProjectId !== projectId) {
|
|
10194
10437
|
throw new Error(`Step ${stepId} belongs to project ${actualProjectId}, not project ${projectId}.`);
|
|
10195
10438
|
}
|
|
10196
|
-
const flowNode =
|
|
10439
|
+
const flowNode = findFlowNode2(project, step);
|
|
10197
10440
|
const formSummary = buildFormSummary(project, step);
|
|
10198
10441
|
const requirements = buildStepRequirements(step, flowNode);
|
|
10199
10442
|
const identityUnverified = !formSummary.has_identity_evidence;
|
|
10200
10443
|
const userCheck = checkCurrentUserCanProcess(step, currentUser);
|
|
10444
|
+
const ownerDiagnostics = ownerDiagnosticsFromStep(step, currentUser);
|
|
10201
10445
|
const stepFinished = isStepFinished(step);
|
|
10202
10446
|
const riskWarnings = [];
|
|
10203
10447
|
if (identityUnverified) {
|
|
@@ -10222,6 +10466,7 @@ async function buildStepContext(profile, client, stepId, projectId) {
|
|
|
10222
10466
|
url: buildBpmaxUrl(profile, "project-step", { projectId, stepId }).url,
|
|
10223
10467
|
current_user: currentUser,
|
|
10224
10468
|
...userCheck,
|
|
10469
|
+
owner_diagnostics: ownerDiagnostics,
|
|
10225
10470
|
step_finished: stepFinished,
|
|
10226
10471
|
form_summary: formSummary,
|
|
10227
10472
|
requirements,
|
|
@@ -10252,12 +10497,12 @@ function extractSubmitInputValues(data) {
|
|
|
10252
10497
|
const candidates = [data.form, data.form_data, data.formData, data.fields, data.values];
|
|
10253
10498
|
const values = {};
|
|
10254
10499
|
for (const candidate of candidates) {
|
|
10255
|
-
if (
|
|
10500
|
+
if (isRecord11(candidate)) {
|
|
10256
10501
|
Object.assign(values, candidate);
|
|
10257
10502
|
}
|
|
10258
10503
|
}
|
|
10259
10504
|
for (const [key, value] of Object.entries(data)) {
|
|
10260
|
-
if (!SUBMIT_NON_FORM_KEYS.has(key) && !
|
|
10505
|
+
if (!SUBMIT_NON_FORM_KEYS.has(key) && !isRecord11(value) && !Array.isArray(value)) {
|
|
10261
10506
|
values[key] = value;
|
|
10262
10507
|
}
|
|
10263
10508
|
}
|
|
@@ -11858,6 +12103,7 @@ async function setupNotices(argv = process.argv) {
|
|
|
11858
12103
|
|
|
11859
12104
|
// src/bin.ts
|
|
11860
12105
|
var program = new Command();
|
|
12106
|
+
program.exitOverride();
|
|
11861
12107
|
function configDirFromArgv(argv) {
|
|
11862
12108
|
const option = "--config-dir";
|
|
11863
12109
|
for (let index = 0; index < argv.length; index += 1) {
|
|
@@ -11871,7 +12117,111 @@ function configDirFromArgv(argv) {
|
|
|
11871
12117
|
}
|
|
11872
12118
|
return void 0;
|
|
11873
12119
|
}
|
|
12120
|
+
function formatFromArgv(argv) {
|
|
12121
|
+
const option = "--format";
|
|
12122
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
12123
|
+
const arg = argv[index];
|
|
12124
|
+
if (arg === option) {
|
|
12125
|
+
return argv[index + 1];
|
|
12126
|
+
}
|
|
12127
|
+
if (arg.startsWith(`${option}=`)) {
|
|
12128
|
+
return arg.slice(option.length + 1);
|
|
12129
|
+
}
|
|
12130
|
+
}
|
|
12131
|
+
return void 0;
|
|
12132
|
+
}
|
|
12133
|
+
var OPTIONS_WITH_VALUES = /* @__PURE__ */ new Set([
|
|
12134
|
+
"--action-key",
|
|
12135
|
+
"--config-dir",
|
|
12136
|
+
"--confirm",
|
|
12137
|
+
"--execution-token",
|
|
12138
|
+
"--format",
|
|
12139
|
+
"--id",
|
|
12140
|
+
"--out",
|
|
12141
|
+
"--payload",
|
|
12142
|
+
"--profile",
|
|
12143
|
+
"--session-key",
|
|
12144
|
+
"--trace-id",
|
|
12145
|
+
"--work-format"
|
|
12146
|
+
]);
|
|
12147
|
+
function commandTokensFromArgv(argv) {
|
|
12148
|
+
const tokens = [];
|
|
12149
|
+
const args = argv.slice(2);
|
|
12150
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
12151
|
+
const arg = args[index];
|
|
12152
|
+
if (arg === "--") {
|
|
12153
|
+
break;
|
|
12154
|
+
}
|
|
12155
|
+
if (arg.startsWith("--")) {
|
|
12156
|
+
const [option] = arg.split("=", 1);
|
|
12157
|
+
if (!arg.includes("=") && OPTIONS_WITH_VALUES.has(option)) {
|
|
12158
|
+
index += 1;
|
|
12159
|
+
}
|
|
12160
|
+
continue;
|
|
12161
|
+
}
|
|
12162
|
+
tokens.push(arg);
|
|
12163
|
+
}
|
|
12164
|
+
return tokens;
|
|
12165
|
+
}
|
|
12166
|
+
function commandDomainFromArgv(argv) {
|
|
12167
|
+
const args = commandTokensFromArgv(argv);
|
|
12168
|
+
if (args[0] === "config" && args[1]) {
|
|
12169
|
+
return args[1];
|
|
12170
|
+
}
|
|
12171
|
+
return args[0];
|
|
12172
|
+
}
|
|
12173
|
+
function commandEndpointHint(argv) {
|
|
12174
|
+
const args = commandTokensFromArgv(argv);
|
|
12175
|
+
if (args[0] === "config" && args[2] === "create" && args[1]) {
|
|
12176
|
+
const endpointByDomain = {
|
|
12177
|
+
"dataset-field": "/data_set_field",
|
|
12178
|
+
dataset: "/data_set",
|
|
12179
|
+
workspace: "/workspace",
|
|
12180
|
+
"form-template": "/form_template",
|
|
12181
|
+
"list-template": "/flow_page_template",
|
|
12182
|
+
"filter-template": "/flow_page_template",
|
|
12183
|
+
"project-detail-template": "/flow_page_template",
|
|
12184
|
+
"console-template": "/flow_page_template"
|
|
12185
|
+
};
|
|
12186
|
+
return endpointByDomain[args[1]];
|
|
12187
|
+
}
|
|
12188
|
+
return void 0;
|
|
12189
|
+
}
|
|
12190
|
+
function printCommandError(error) {
|
|
12191
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
12192
|
+
if (formatFromArgv(process.argv) === "json") {
|
|
12193
|
+
console.log(JSON.stringify({
|
|
12194
|
+
ok: false,
|
|
12195
|
+
error: message,
|
|
12196
|
+
...commandDomainFromArgv(process.argv) ? { domain: commandDomainFromArgv(process.argv) } : {},
|
|
12197
|
+
...commandEndpointHint(process.argv) ? { endpoint: commandEndpointHint(process.argv) } : {}
|
|
12198
|
+
}, null, 2));
|
|
12199
|
+
return;
|
|
12200
|
+
}
|
|
12201
|
+
console.error(message);
|
|
12202
|
+
}
|
|
12203
|
+
function commanderExitCode(error) {
|
|
12204
|
+
if (typeof error === "object" && error !== null && "exitCode" in error && typeof error.exitCode === "number") {
|
|
12205
|
+
return error.exitCode;
|
|
12206
|
+
}
|
|
12207
|
+
return void 0;
|
|
12208
|
+
}
|
|
12209
|
+
function isCommanderDisplayOnlyExit(error) {
|
|
12210
|
+
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
12211
|
+
return false;
|
|
12212
|
+
}
|
|
12213
|
+
const code = error.code;
|
|
12214
|
+
return code === "commander.helpDisplayed" || code === "commander.version";
|
|
12215
|
+
}
|
|
11874
12216
|
program.name(CLI_NAME).description("BPMAX multi-environment CLI").version(VERSION).option("--config-dir <dir>", "Root directory for bpmax-cli local state").option("--execution-token <token>", "Short-lived BPMAX AI execution token").option("--action-key <actionKey>", "AI action key for execution audit").option("--session-key <sessionKey>", "AI conversation session key").option("--trace-id <traceId>", "AI execution trace id");
|
|
12217
|
+
program.configureOutput({
|
|
12218
|
+
writeErr: (str) => {
|
|
12219
|
+
if (formatFromArgv(process.argv) === "json") {
|
|
12220
|
+
return;
|
|
12221
|
+
}
|
|
12222
|
+
process.stderr.write(str);
|
|
12223
|
+
}
|
|
12224
|
+
});
|
|
11875
12225
|
program.hook("preAction", (thisCommand) => {
|
|
11876
12226
|
const options = thisCommand.optsWithGlobals();
|
|
11877
12227
|
setConfigDir(options.configDir);
|
|
@@ -11916,9 +12266,13 @@ registerUpdateCommands(program);
|
|
|
11916
12266
|
var isCompletion = process.argv.includes("completion") || process.argv.includes("__complete");
|
|
11917
12267
|
setConfigDir(configDirFromArgv(process.argv));
|
|
11918
12268
|
(isCompletion ? Promise.resolve() : setupNotices()).then(() => program.parseAsync(process.argv)).catch((error) => {
|
|
12269
|
+
if (isCommanderDisplayOnlyExit(error)) {
|
|
12270
|
+
process.exitCode = commanderExitCode(error) ?? 0;
|
|
12271
|
+
return;
|
|
12272
|
+
}
|
|
11919
12273
|
finishCommandAuditScope("failed", error).catch(() => void 0).finally(() => {
|
|
11920
|
-
|
|
11921
|
-
process.exitCode = 1;
|
|
12274
|
+
printCommandError(error);
|
|
12275
|
+
process.exitCode = commanderExitCode(error) ?? 1;
|
|
11922
12276
|
});
|
|
11923
12277
|
});
|
|
11924
12278
|
//# sourceMappingURL=bin.js.map
|