bpmax-cli 0.1.44-beta.4 → 0.1.44-beta.6
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 +595 -19
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +26 -1
- package/skills/bpmax-flow-template-editor/SKILL.md +21 -8
- package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +17 -2
- package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +2 -0
- package/skills/bpmax-form-template-editor/SKILL.md +28 -5
- package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +15 -5
- package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +1 -1
package/dist/bin.js
CHANGED
|
@@ -279,11 +279,18 @@ function capabilityForRequest(method, path9) {
|
|
|
279
279
|
if (normalizedMethod === "PUT" && /^\/cli\/memory\/[^/]+$/.test(normalizedPath)) return "memory.update";
|
|
280
280
|
if (normalizedMethod === "DELETE" && /^\/cli\/memory\/[^/]+$/.test(normalizedPath)) return "memory.delete";
|
|
281
281
|
if (normalizedMethod === "GET" && normalizedPath === "/user/current") return "user.current";
|
|
282
|
-
if (normalizedMethod === "GET" && normalizedPath === "/workspace/by_key") return "
|
|
282
|
+
if (normalizedMethod === "GET" && normalizedPath === "/workspace/by_key") return "config.workspace_flow.export";
|
|
283
283
|
if (normalizedMethod === "GET" && normalizedPath === "/flow/flow_type") return "flow.list";
|
|
284
|
+
if (normalizedMethod === "POST" && normalizedPath === "/flow/flow_type") return "config.flow_template.create";
|
|
284
285
|
if (normalizedMethod === "GET" && normalizedPath === "/flow/options") return "flow.options";
|
|
286
|
+
if (normalizedMethod === "GET" && normalizedPath === "/flow") return "config.flow_template.export";
|
|
287
|
+
if (normalizedMethod === "PUT" && normalizedPath === "/flow") return "config.flow_template.submit";
|
|
285
288
|
if (normalizedMethod === "POST" && normalizedPath === "/flow/batch_get") return "flow.get";
|
|
286
|
-
if (normalizedMethod === "GET" && normalizedPath.startsWith("/form_template/")) return "
|
|
289
|
+
if (normalizedMethod === "GET" && normalizedPath.startsWith("/form_template/")) return "config.form_template.export";
|
|
290
|
+
if (normalizedMethod === "POST" && normalizedPath === "/form_template") return "config.form_template.create";
|
|
291
|
+
if (normalizedMethod === "PUT" && /^\/form_template\/[^/]+$/.test(normalizedPath)) return "config.form_template.submit";
|
|
292
|
+
if (normalizedMethod === "POST" && normalizedPath === "/form_template/publish") return "config.form_template.submit";
|
|
293
|
+
if (normalizedMethod === "PUT" && normalizedPath === "/workspace/workspace_flow") return "config.workspace_flow.submit";
|
|
287
294
|
if (normalizedMethod === "POST" && normalizedPath === "/project_staging/prefill") return "project.create";
|
|
288
295
|
if (normalizedMethod === "POST" && normalizedPath === "/project/search") return "project.search";
|
|
289
296
|
if (normalizedMethod === "POST" && normalizedPath === "/project/list") return "project.list";
|
|
@@ -382,7 +389,7 @@ function normalizePath2(path9) {
|
|
|
382
389
|
// package.json
|
|
383
390
|
var package_default = {
|
|
384
391
|
name: "bpmax-cli",
|
|
385
|
-
version: "0.1.44-beta.
|
|
392
|
+
version: "0.1.44-beta.6",
|
|
386
393
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
387
394
|
type: "module",
|
|
388
395
|
bin: {
|
|
@@ -2587,8 +2594,8 @@ var CONFIG_DOMAINS = {
|
|
|
2587
2594
|
submitPath: (id) => `/form_template/${id}`,
|
|
2588
2595
|
submitMethod: "PUT",
|
|
2589
2596
|
readEndpoints: ["GET /api/form_template/:id"],
|
|
2590
|
-
writeEndpoints: ["PUT /api/form_template/:id", "POST /api/form_template/publish"],
|
|
2591
|
-
notes: ["Edit
|
|
2597
|
+
writeEndpoints: ["POST /api/form_template", "PUT /api/form_template/:id", "POST /api/form_template/publish"],
|
|
2598
|
+
notes: ["Supports edit and create modes. Edit updates the draft/current template and publishes after update; create posts a new draft and publishes it through the typed adapter."]
|
|
2592
2599
|
},
|
|
2593
2600
|
"flow-template": {
|
|
2594
2601
|
capability: "config.flow_template",
|
|
@@ -2599,8 +2606,20 @@ var CONFIG_DOMAINS = {
|
|
|
2599
2606
|
submitPath: (id) => `/flow?${flowIdentityQuery(parseFlowIdentity(id), { publish: 2 })}`,
|
|
2600
2607
|
submitMethod: "PUT",
|
|
2601
2608
|
readEndpoints: ["GET /api/flow?flow_type=:flow_type&draft=1", "GET /api/flow?key=:key&draft=1", "POST /api/flow/batch_get"],
|
|
2602
|
-
writeEndpoints: ["PUT /api/flow?flow_type=:flow_type&publish=2", "PUT /api/flow?key=:key&publish=2", "PUT /api/flow?flow_type=:flow_type&publish=1", "PUT /api/flow?key=:key&publish=1"],
|
|
2603
|
-
notes: ["Flow config is keyed by flow_type for main flows or key for subflows. Export id format: flow_type, flow_type:<type>, or key:<subflowKey>. Submit writes draft by default and only publishes when payload.publish_live=true."]
|
|
2609
|
+
writeEndpoints: ["POST /api/flow/flow_type", "PUT /api/flow?flow_type=:flow_type&publish=2", "PUT /api/flow?key=:key&publish=2", "PUT /api/flow?flow_type=:flow_type&publish=1", "PUT /api/flow?key=:key&publish=1"],
|
|
2610
|
+
notes: ["Flow config is keyed by flow_type for main flows or key for subflows. Export id format: flow_type, flow_type:<type>, or key:<subflowKey>. Submit writes draft by default and only publishes when payload.publish_live=true. Create first asks the platform for a flow<number> and never accepts a hand-authored main flow_type."]
|
|
2611
|
+
},
|
|
2612
|
+
"workspace-flow": {
|
|
2613
|
+
capability: "config.workspace_flow",
|
|
2614
|
+
exportPath: (id) => `/workspace/by_key?key=${encodeURIComponent(normalizeWorkspaceKey(id))}`,
|
|
2615
|
+
exportStatus: "supported",
|
|
2616
|
+
buildStatus: "supported",
|
|
2617
|
+
submitStatus: "supported",
|
|
2618
|
+
submitPath: () => "/workspace/workspace_flow",
|
|
2619
|
+
submitMethod: "PUT",
|
|
2620
|
+
readEndpoints: ["GET /api/workspace/by_key?key=:workspace"],
|
|
2621
|
+
writeEndpoints: ["PUT /api/workspace/workspace_flow"],
|
|
2622
|
+
notes: ["Workspace flow submit replaces the workspace_flow relation list for one workspace, then verifies by /workspace/by_key."]
|
|
2604
2623
|
},
|
|
2605
2624
|
"list-template": {
|
|
2606
2625
|
capability: "config.list_template",
|
|
@@ -2737,6 +2756,34 @@ function pickDefined(source, keys) {
|
|
|
2737
2756
|
}
|
|
2738
2757
|
return result;
|
|
2739
2758
|
}
|
|
2759
|
+
function normalizeWorkspaceKey(workspace) {
|
|
2760
|
+
const nextWorkspace = workspace.trim().replace(/^\/+|\/+$/g, "");
|
|
2761
|
+
return nextWorkspace.startsWith("w:") ? nextWorkspace.slice(2) : nextWorkspace;
|
|
2762
|
+
}
|
|
2763
|
+
function numericId(value) {
|
|
2764
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
2765
|
+
return value;
|
|
2766
|
+
}
|
|
2767
|
+
if (typeof value === "string" && /^\d+$/.test(value)) {
|
|
2768
|
+
return Number(value);
|
|
2769
|
+
}
|
|
2770
|
+
return void 0;
|
|
2771
|
+
}
|
|
2772
|
+
function formTemplateDetail(value) {
|
|
2773
|
+
if (isRecord3(value) && isRecord3(value.data)) {
|
|
2774
|
+
return value.data;
|
|
2775
|
+
}
|
|
2776
|
+
return isRecord3(value) ? value : {};
|
|
2777
|
+
}
|
|
2778
|
+
function assertFormTemplateDraftId(id, data, action) {
|
|
2779
|
+
const detail = formTemplateDetail(data);
|
|
2780
|
+
const originTemplateId = numericId(detail.origin_template_id);
|
|
2781
|
+
if (originTemplateId && originTemplateId > 0) {
|
|
2782
|
+
throw new Error(
|
|
2783
|
+
`Refusing to ${action} published form-template id ${id}. Use draft id ${originTemplateId}; published ids are readback-only and must not be used for export/submit/publish.`
|
|
2784
|
+
);
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2740
2787
|
function jsonPointerSegment(value) {
|
|
2741
2788
|
return value.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
2742
2789
|
}
|
|
@@ -3055,6 +3102,30 @@ function normalizeFlowTemplatePayload(work) {
|
|
|
3055
3102
|
}
|
|
3056
3103
|
return payload;
|
|
3057
3104
|
}
|
|
3105
|
+
function buildWorkspaceFlowBindingKey(flowType, flowKey) {
|
|
3106
|
+
return `${String(flowType || "default")}:${String(flowKey || "")}`;
|
|
3107
|
+
}
|
|
3108
|
+
function normalizeWorkspaceFlowItems(value) {
|
|
3109
|
+
if (!Array.isArray(value)) {
|
|
3110
|
+
return [];
|
|
3111
|
+
}
|
|
3112
|
+
return value.filter((item) => isRecord3(item)).map((item) => ({
|
|
3113
|
+
flow_type: String(item.flow_type || "default"),
|
|
3114
|
+
flow_key: String(item.flow_key || ""),
|
|
3115
|
+
only_in_workspace: normalizeInt(item.only_in_workspace ?? 0)
|
|
3116
|
+
}));
|
|
3117
|
+
}
|
|
3118
|
+
function buildWorkspaceFlowSubmitPayload(work) {
|
|
3119
|
+
const workspace = normalizeWorkspaceKey(String(work.workspace || work.key || ""));
|
|
3120
|
+
if (!workspace) {
|
|
3121
|
+
throw new Error("workspace-flow work requires workspace.");
|
|
3122
|
+
}
|
|
3123
|
+
const workspaceFlow = normalizeWorkspaceFlowItems(work.workspace_flow ?? work.flows);
|
|
3124
|
+
return {
|
|
3125
|
+
workspace,
|
|
3126
|
+
workspace_flow: workspaceFlow
|
|
3127
|
+
};
|
|
3128
|
+
}
|
|
3058
3129
|
function normalizeDatasetPayload(work) {
|
|
3059
3130
|
const mode = work.mode;
|
|
3060
3131
|
if (mode !== void 0 && mode !== "edit") {
|
|
@@ -3196,6 +3267,17 @@ function refreshSettingToSubmit(value) {
|
|
|
3196
3267
|
stop_refresh_count: normalizeInt(value.stopRefreshCount ?? value.stop_refresh_count ?? fallback.stop_refresh_count)
|
|
3197
3268
|
};
|
|
3198
3269
|
}
|
|
3270
|
+
var FORM_RULE_ID_KEYS = /* @__PURE__ */ new Set(["form_rule_id", "form_template_id", "id"]);
|
|
3271
|
+
var FORM_VALUE_ID_KEYS = /* @__PURE__ */ new Set(["template_id", "id"]);
|
|
3272
|
+
function stripKeys(source, keys) {
|
|
3273
|
+
const result = {};
|
|
3274
|
+
for (const [key, value] of Object.entries(source)) {
|
|
3275
|
+
if (!keys.has(key)) {
|
|
3276
|
+
result[key] = value;
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
return result;
|
|
3280
|
+
}
|
|
3199
3281
|
function normalizeRemovedFields(value) {
|
|
3200
3282
|
if (!Array.isArray(value)) {
|
|
3201
3283
|
return /* @__PURE__ */ new Set();
|
|
@@ -3204,8 +3286,8 @@ function normalizeRemovedFields(value) {
|
|
|
3204
3286
|
}
|
|
3205
3287
|
function buildStructuredFormTemplatePayload(work) {
|
|
3206
3288
|
const mode = work.mode;
|
|
3207
|
-
if (mode !== "edit") {
|
|
3208
|
-
throw new Error("form-template structured work
|
|
3289
|
+
if (mode !== "edit" && mode !== "create") {
|
|
3290
|
+
throw new Error("form-template structured work requires mode edit or create.");
|
|
3209
3291
|
}
|
|
3210
3292
|
if (!isRecord3(work.basic)) {
|
|
3211
3293
|
throw new Error("form-template structured work requires basic object.");
|
|
@@ -3246,8 +3328,8 @@ function buildStructuredFormTemplatePayload(work) {
|
|
|
3246
3328
|
if (bundle.value.field_type !== bundle.rule.type) {
|
|
3247
3329
|
throw new Error(`form-template field_type mismatch for ${ref}.`);
|
|
3248
3330
|
}
|
|
3249
|
-
const rule = { ...bundle.rule };
|
|
3250
|
-
const value = { ...bundle.value };
|
|
3331
|
+
const rule = mode === "create" ? stripKeys(bundle.rule, FORM_RULE_ID_KEYS) : { ...bundle.rule };
|
|
3332
|
+
const value = mode === "create" ? stripKeys(bundle.value, FORM_VALUE_ID_KEYS) : { ...bundle.value };
|
|
3251
3333
|
submitRow.push(rule);
|
|
3252
3334
|
valueItems.push(value);
|
|
3253
3335
|
seen.add(ref);
|
|
@@ -3275,6 +3357,16 @@ function buildStructuredFormTemplatePayload(work) {
|
|
|
3275
3357
|
value: valueItems
|
|
3276
3358
|
};
|
|
3277
3359
|
}
|
|
3360
|
+
function stripFormTemplateCreateIds(payload) {
|
|
3361
|
+
const next = { ...payload };
|
|
3362
|
+
if (Array.isArray(next.rule)) {
|
|
3363
|
+
next.rule = next.rule.map((row) => Array.isArray(row) ? row.map((item) => isRecord3(item) ? stripKeys(item, FORM_RULE_ID_KEYS) : item) : row);
|
|
3364
|
+
}
|
|
3365
|
+
if (Array.isArray(next.value)) {
|
|
3366
|
+
next.value = next.value.map((item) => isRecord3(item) ? stripKeys(item, FORM_VALUE_ID_KEYS) : item);
|
|
3367
|
+
}
|
|
3368
|
+
return next;
|
|
3369
|
+
}
|
|
3278
3370
|
function formTemplateRawToStructured(raw) {
|
|
3279
3371
|
const ruleRows = Array.isArray(raw.rule) ? raw.rule : [];
|
|
3280
3372
|
const values = Array.isArray(raw.value) ? raw.value : [];
|
|
@@ -3936,11 +4028,15 @@ function buildDomainSubmitPayload(domain, work, options = {}, raw) {
|
|
|
3936
4028
|
if (isRecord3(work.basic) && Array.isArray(work.layout) && isRecord3(work.fields)) {
|
|
3937
4029
|
return buildStructuredFormTemplatePayload(work);
|
|
3938
4030
|
}
|
|
3939
|
-
|
|
4031
|
+
const payload = pickDefined(work, ["name", "desc", "category", "option", "rule", "value"]);
|
|
4032
|
+
return work.mode === "create" ? stripFormTemplateCreateIds(payload) : payload;
|
|
3940
4033
|
}
|
|
3941
4034
|
if (domain === "flow-template") {
|
|
3942
4035
|
return normalizeFlowTemplatePayload(work);
|
|
3943
4036
|
}
|
|
4037
|
+
if (domain === "workspace-flow") {
|
|
4038
|
+
return buildWorkspaceFlowSubmitPayload(work);
|
|
4039
|
+
}
|
|
3944
4040
|
if (domain === "dataset") {
|
|
3945
4041
|
return normalizeDatasetPayload(work);
|
|
3946
4042
|
}
|
|
@@ -3971,6 +4067,27 @@ function responseDataId(response) {
|
|
|
3971
4067
|
}
|
|
3972
4068
|
return void 0;
|
|
3973
4069
|
}
|
|
4070
|
+
function responseValue(response, keys) {
|
|
4071
|
+
if (!isRecord3(response)) {
|
|
4072
|
+
return void 0;
|
|
4073
|
+
}
|
|
4074
|
+
for (const key of keys) {
|
|
4075
|
+
if (response[key] !== void 0) return response[key];
|
|
4076
|
+
}
|
|
4077
|
+
if (isRecord3(response.data)) {
|
|
4078
|
+
for (const key of keys) {
|
|
4079
|
+
if (response.data[key] !== void 0) return response.data[key];
|
|
4080
|
+
}
|
|
4081
|
+
}
|
|
4082
|
+
return void 0;
|
|
4083
|
+
}
|
|
4084
|
+
function responseFlowType(response) {
|
|
4085
|
+
const flowType = responseValue(response, ["flow_type", "flowType"]);
|
|
4086
|
+
if (typeof flowType !== "string" || !STANDARD_MAIN_FLOW_TYPE.test(flowType)) {
|
|
4087
|
+
throw new Error(`flow-template create did not return a platform flow_type; got ${String(flowType)}.`);
|
|
4088
|
+
}
|
|
4089
|
+
return flowType;
|
|
4090
|
+
}
|
|
3974
4091
|
async function submitRoleOperations(profile, id, submit) {
|
|
3975
4092
|
const definition = CONFIG_DOMAINS.role;
|
|
3976
4093
|
const current = await collectRoleAggregate(profile, id);
|
|
@@ -4064,8 +4181,279 @@ async function submitAggregateConfigDomain(profile, domain, id, submit) {
|
|
|
4064
4181
|
readback_hash: hashJson(current.raw)
|
|
4065
4182
|
};
|
|
4066
4183
|
}
|
|
4184
|
+
async function createFlowTemplateFromWork(config, profile, workFile, confirm3, options = {}) {
|
|
4185
|
+
void config;
|
|
4186
|
+
const definition = CONFIG_DOMAINS["flow-template"];
|
|
4187
|
+
await ensureConfigCapability(profile, `${definition.capability}.create`);
|
|
4188
|
+
await ensureConfigCapability(profile, `${definition.capability}.submit`);
|
|
4189
|
+
const work = await readJsonFile(workFile);
|
|
4190
|
+
if (!isRecord3(work)) {
|
|
4191
|
+
throw new Error("flow-template create requires a work JSON object.");
|
|
4192
|
+
}
|
|
4193
|
+
const createShell = {
|
|
4194
|
+
name: String(work.name || ""),
|
|
4195
|
+
category: work.category || "system",
|
|
4196
|
+
data: {
|
|
4197
|
+
nodes: [],
|
|
4198
|
+
periods: []
|
|
4199
|
+
}
|
|
4200
|
+
};
|
|
4201
|
+
if (!createShell.name) {
|
|
4202
|
+
throw new Error("flow-template create requires name.");
|
|
4203
|
+
}
|
|
4204
|
+
const expectedConfirm = `create flow-template ${createShell.name}`;
|
|
4205
|
+
if (confirm3 !== expectedConfirm) {
|
|
4206
|
+
return {
|
|
4207
|
+
dry_run: true,
|
|
4208
|
+
domain: "flow-template",
|
|
4209
|
+
create_endpoint: "/flow/flow_type",
|
|
4210
|
+
create_payload: createShell,
|
|
4211
|
+
draft_endpoint: "/flow?flow_type=<platform-flow-type>&publish=2",
|
|
4212
|
+
...options.publishLive ? { live_endpoint: "/flow?flow_type=<platform-flow-type>&publish=1" } : {},
|
|
4213
|
+
next: `Run again with --confirm "${expectedConfirm}" to create.`
|
|
4214
|
+
};
|
|
4215
|
+
}
|
|
4216
|
+
const client = createApiClient(profile);
|
|
4217
|
+
const createResponse = await apiRequest(
|
|
4218
|
+
client,
|
|
4219
|
+
"POST",
|
|
4220
|
+
"/flow/flow_type",
|
|
4221
|
+
{ data: createShell, capability: `${definition.capability}.create` }
|
|
4222
|
+
);
|
|
4223
|
+
const flowType = responseFlowType(createResponse);
|
|
4224
|
+
const payload = normalizeFlowTemplatePayload({
|
|
4225
|
+
...work,
|
|
4226
|
+
flow_type: flowType,
|
|
4227
|
+
key: "",
|
|
4228
|
+
type: work.type || "main"
|
|
4229
|
+
});
|
|
4230
|
+
const updateTime = payload.update_time;
|
|
4231
|
+
delete payload.publish_live;
|
|
4232
|
+
delete payload.update_time;
|
|
4233
|
+
const draftEndpoint = `/flow?${flowIdentityQuery({ kind: "flow_type", flowType }, {
|
|
4234
|
+
publish: 2,
|
|
4235
|
+
...updateTime !== void 0 && updateTime !== null && updateTime !== "" ? { update_time: String(updateTime) } : {}
|
|
4236
|
+
})}`;
|
|
4237
|
+
const draftResponse = await apiRequest(
|
|
4238
|
+
client,
|
|
4239
|
+
"PUT",
|
|
4240
|
+
draftEndpoint,
|
|
4241
|
+
{ data: payload, capability: `${definition.capability}.submit` }
|
|
4242
|
+
);
|
|
4243
|
+
let liveResponse = null;
|
|
4244
|
+
let liveEndpoint = null;
|
|
4245
|
+
if (options.publishLive) {
|
|
4246
|
+
liveEndpoint = `/flow?${flowIdentityQuery({ kind: "flow_type", flowType }, {
|
|
4247
|
+
publish: 1,
|
|
4248
|
+
...updateTime !== void 0 && updateTime !== null && updateTime !== "" ? { update_time: String(updateTime) } : {}
|
|
4249
|
+
})}`;
|
|
4250
|
+
liveResponse = await apiRequest(
|
|
4251
|
+
client,
|
|
4252
|
+
"PUT",
|
|
4253
|
+
liveEndpoint,
|
|
4254
|
+
{ data: payload, capability: `${definition.capability}.submit` }
|
|
4255
|
+
);
|
|
4256
|
+
}
|
|
4257
|
+
const readback = await apiRequest(
|
|
4258
|
+
client,
|
|
4259
|
+
"GET",
|
|
4260
|
+
`/flow?${flowIdentityQuery({ kind: "flow_type", flowType }, { draft: 1, skip_i18n: "true" })}`,
|
|
4261
|
+
{ capability: `${definition.capability}.export` }
|
|
4262
|
+
);
|
|
4263
|
+
return {
|
|
4264
|
+
dry_run: false,
|
|
4265
|
+
domain: "flow-template",
|
|
4266
|
+
flow_type: flowType,
|
|
4267
|
+
create_response: createResponse,
|
|
4268
|
+
draft_endpoint: draftEndpoint,
|
|
4269
|
+
draft_response: draftResponse,
|
|
4270
|
+
...liveEndpoint ? { live_endpoint: liveEndpoint, live_response: liveResponse } : {},
|
|
4271
|
+
readback_hash: hashJson(readback)
|
|
4272
|
+
};
|
|
4273
|
+
}
|
|
4274
|
+
async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile, confirm3, options = { workspace: "", name: "" }) {
|
|
4275
|
+
void config;
|
|
4276
|
+
const formDefinition = CONFIG_DOMAINS["form-template"];
|
|
4277
|
+
const flowDefinition = CONFIG_DOMAINS["flow-template"];
|
|
4278
|
+
const workspaceDefinition = CONFIG_DOMAINS["workspace-flow"];
|
|
4279
|
+
await ensureConfigCapability(profile, "config.flow_app.create");
|
|
4280
|
+
await ensureConfigCapability(profile, `${formDefinition.capability}.create`);
|
|
4281
|
+
await ensureConfigCapability(profile, `${formDefinition.capability}.submit`);
|
|
4282
|
+
await ensureConfigCapability(profile, `${formDefinition.capability}.export`);
|
|
4283
|
+
await ensureConfigCapability(profile, `${flowDefinition.capability}.create`);
|
|
4284
|
+
await ensureConfigCapability(profile, `${flowDefinition.capability}.submit`);
|
|
4285
|
+
await ensureConfigCapability(profile, `${flowDefinition.capability}.export`);
|
|
4286
|
+
await ensureConfigCapability(profile, `${workspaceDefinition.capability}.submit`);
|
|
4287
|
+
await ensureConfigCapability(profile, `${workspaceDefinition.capability}.export`);
|
|
4288
|
+
const workspace = normalizeWorkspaceKey(options.workspace || profile.config.workspace);
|
|
4289
|
+
const name = options.name.trim();
|
|
4290
|
+
if (!workspace) {
|
|
4291
|
+
throw new Error("flow-app create requires workspace.");
|
|
4292
|
+
}
|
|
4293
|
+
if (!name) {
|
|
4294
|
+
throw new Error("flow-app create requires name.");
|
|
4295
|
+
}
|
|
4296
|
+
const formWork = await readJsonFile(formWorkFile);
|
|
4297
|
+
const flowWork = await readJsonFile(flowWorkFile);
|
|
4298
|
+
if (!isRecord3(formWork) || formWork.mode !== "create") {
|
|
4299
|
+
throw new Error("flow-app create requires form work with mode=create.");
|
|
4300
|
+
}
|
|
4301
|
+
const formPayload = buildDomainSubmitPayload("form-template", formWork);
|
|
4302
|
+
const flowWorkRecord = isRecord3(flowWork) ? flowWork : {};
|
|
4303
|
+
const flowShell = {
|
|
4304
|
+
name: String(flowWorkRecord.name || name),
|
|
4305
|
+
category: flowWorkRecord.category || "system",
|
|
4306
|
+
data: {
|
|
4307
|
+
nodes: [],
|
|
4308
|
+
periods: []
|
|
4309
|
+
}
|
|
4310
|
+
};
|
|
4311
|
+
const expectedConfirm = `create flow-app ${name} in ${workspace}`;
|
|
4312
|
+
const dryRunPlan = {
|
|
4313
|
+
operations: [
|
|
4314
|
+
{ step: "create_form_template", method: "POST", path: "/form_template", payload: formPayload },
|
|
4315
|
+
{ step: "publish_form_template", method: "POST", path: "/form_template/publish", payload: { id: "<draft-form-id>" } },
|
|
4316
|
+
{ step: "create_flow_template", method: "POST", path: "/flow/flow_type", payload: flowShell },
|
|
4317
|
+
{ step: "save_flow_draft", method: "PUT", path: "/flow?flow_type=<platform-flow-type>&publish=2" },
|
|
4318
|
+
...options.publishLive !== false ? [{ step: "publish_flow_live", method: "PUT", path: "/flow?flow_type=<platform-flow-type>&publish=1" }] : [],
|
|
4319
|
+
{ step: "bind_workspace_flow", method: "PUT", path: "/workspace/workspace_flow", params: { workspace } },
|
|
4320
|
+
{ step: "verify_workspace_binding", method: "GET", path: "/workspace/by_key", params: { key: workspace } }
|
|
4321
|
+
]
|
|
4322
|
+
};
|
|
4323
|
+
if (confirm3 !== expectedConfirm) {
|
|
4324
|
+
return {
|
|
4325
|
+
dry_run: true,
|
|
4326
|
+
domain: "flow-app",
|
|
4327
|
+
workspace,
|
|
4328
|
+
name,
|
|
4329
|
+
operation_plan: dryRunPlan,
|
|
4330
|
+
next: `Run again with --confirm "${expectedConfirm}" to create.`
|
|
4331
|
+
};
|
|
4332
|
+
}
|
|
4333
|
+
const client = createApiClient(profile);
|
|
4334
|
+
const createdResources = {};
|
|
4335
|
+
try {
|
|
4336
|
+
const formResponse = await apiRequest(
|
|
4337
|
+
client,
|
|
4338
|
+
"POST",
|
|
4339
|
+
"/form_template",
|
|
4340
|
+
{ data: formPayload, capability: `${formDefinition.capability}.create` }
|
|
4341
|
+
);
|
|
4342
|
+
const draftFormId = responseDataId(formResponse);
|
|
4343
|
+
if (draftFormId === void 0 || draftFormId === null || draftFormId === "") {
|
|
4344
|
+
throw new Error("flow-app create did not receive a draft form-template id.");
|
|
4345
|
+
}
|
|
4346
|
+
createdResources.draft_form_id = draftFormId;
|
|
4347
|
+
const formPublishResponse = await apiRequest(
|
|
4348
|
+
client,
|
|
4349
|
+
"POST",
|
|
4350
|
+
"/form_template/publish",
|
|
4351
|
+
{ data: { id: draftFormId }, capability: `${formDefinition.capability}.submit` }
|
|
4352
|
+
);
|
|
4353
|
+
const publishedFormId = responseDataId(formPublishResponse) ?? draftFormId;
|
|
4354
|
+
createdResources.published_form_id = publishedFormId;
|
|
4355
|
+
const flowCreateResponse = await apiRequest(
|
|
4356
|
+
client,
|
|
4357
|
+
"POST",
|
|
4358
|
+
"/flow/flow_type",
|
|
4359
|
+
{ data: flowShell, capability: `${flowDefinition.capability}.create` }
|
|
4360
|
+
);
|
|
4361
|
+
const flowType = responseFlowType(flowCreateResponse);
|
|
4362
|
+
createdResources.flow_type = flowType;
|
|
4363
|
+
const flowData = isRecord3(flowWorkRecord.data) ? { ...flowWorkRecord.data } : {};
|
|
4364
|
+
const flowMeta = isRecord3(flowData.meta) ? { ...flowData.meta } : {};
|
|
4365
|
+
flowMeta.form_template = publishedFormId;
|
|
4366
|
+
flowData.meta = flowMeta;
|
|
4367
|
+
const flowPayload = normalizeFlowTemplatePayload({
|
|
4368
|
+
...flowWorkRecord,
|
|
4369
|
+
name: flowShell.name,
|
|
4370
|
+
flow_type: flowType,
|
|
4371
|
+
key: "",
|
|
4372
|
+
type: flowWorkRecord.type || "main",
|
|
4373
|
+
meta_form_id: publishedFormId,
|
|
4374
|
+
data: flowData
|
|
4375
|
+
});
|
|
4376
|
+
const updateTime = flowPayload.update_time;
|
|
4377
|
+
delete flowPayload.publish_live;
|
|
4378
|
+
delete flowPayload.update_time;
|
|
4379
|
+
const draftEndpoint = `/flow?${flowIdentityQuery({ kind: "flow_type", flowType }, {
|
|
4380
|
+
publish: 2,
|
|
4381
|
+
...updateTime !== void 0 && updateTime !== null && updateTime !== "" ? { update_time: String(updateTime) } : {}
|
|
4382
|
+
})}`;
|
|
4383
|
+
const flowDraftResponse = await apiRequest(
|
|
4384
|
+
client,
|
|
4385
|
+
"PUT",
|
|
4386
|
+
draftEndpoint,
|
|
4387
|
+
{ data: flowPayload, capability: `${flowDefinition.capability}.submit` }
|
|
4388
|
+
);
|
|
4389
|
+
createdResources.flow_draft_saved = true;
|
|
4390
|
+
let flowLiveResponse = null;
|
|
4391
|
+
let liveEndpoint = null;
|
|
4392
|
+
if (options.publishLive !== false) {
|
|
4393
|
+
liveEndpoint = `/flow?${flowIdentityQuery({ kind: "flow_type", flowType }, {
|
|
4394
|
+
publish: 1,
|
|
4395
|
+
...updateTime !== void 0 && updateTime !== null && updateTime !== "" ? { update_time: String(updateTime) } : {}
|
|
4396
|
+
})}`;
|
|
4397
|
+
flowLiveResponse = await apiRequest(
|
|
4398
|
+
client,
|
|
4399
|
+
"PUT",
|
|
4400
|
+
liveEndpoint,
|
|
4401
|
+
{ data: flowPayload, capability: `${flowDefinition.capability}.submit` }
|
|
4402
|
+
);
|
|
4403
|
+
createdResources.flow_live_published = true;
|
|
4404
|
+
}
|
|
4405
|
+
const workspaceInfo = await apiRequest(
|
|
4406
|
+
client,
|
|
4407
|
+
"GET",
|
|
4408
|
+
"/workspace/by_key",
|
|
4409
|
+
{ params: { key: workspace }, capability: `${workspaceDefinition.capability}.export` }
|
|
4410
|
+
);
|
|
4411
|
+
const existingBindings = isRecord3(workspaceInfo) ? normalizeWorkspaceFlowItems(workspaceInfo.workspace_flow) : [];
|
|
4412
|
+
const bindingKey = buildWorkspaceFlowBindingKey(flowType, "");
|
|
4413
|
+
const nextBindings = existingBindings.some((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key) === bindingKey) ? existingBindings : [...existingBindings, { flow_type: flowType, flow_key: "", only_in_workspace: 0 }];
|
|
4414
|
+
const workspaceBindResponse = await apiRequest(
|
|
4415
|
+
client,
|
|
4416
|
+
"PUT",
|
|
4417
|
+
"/workspace/workspace_flow",
|
|
4418
|
+
{ data: { workspace_flow: nextBindings }, params: { workspace }, capability: `${workspaceDefinition.capability}.submit` }
|
|
4419
|
+
);
|
|
4420
|
+
createdResources.workspace_binding_submitted = { workspace, flow_type: flowType, flow_key: "" };
|
|
4421
|
+
const workspaceReadback = await apiRequest(
|
|
4422
|
+
client,
|
|
4423
|
+
"GET",
|
|
4424
|
+
"/workspace/by_key",
|
|
4425
|
+
{ params: { key: workspace }, capability: `${workspaceDefinition.capability}.export` }
|
|
4426
|
+
);
|
|
4427
|
+
const readbackBindings = isRecord3(workspaceReadback) ? normalizeWorkspaceFlowItems(workspaceReadback.workspace_flow) : [];
|
|
4428
|
+
if (!readbackBindings.some((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key) === bindingKey)) {
|
|
4429
|
+
throw new Error(`flow-app create workspace binding verification failed for ${workspace} ${bindingKey}.`);
|
|
4430
|
+
}
|
|
4431
|
+
return {
|
|
4432
|
+
dry_run: false,
|
|
4433
|
+
domain: "flow-app",
|
|
4434
|
+
workspace,
|
|
4435
|
+
name,
|
|
4436
|
+
draft_form_id: draftFormId,
|
|
4437
|
+
published_form_id: publishedFormId,
|
|
4438
|
+
flow_type: flowType,
|
|
4439
|
+
form_response: formResponse,
|
|
4440
|
+
form_publish_response: formPublishResponse,
|
|
4441
|
+
flow_create_response: flowCreateResponse,
|
|
4442
|
+
flow_draft_response: flowDraftResponse,
|
|
4443
|
+
...liveEndpoint ? { flow_live_response: flowLiveResponse, live_endpoint: liveEndpoint } : {},
|
|
4444
|
+
workspace_bind_response: workspaceBindResponse,
|
|
4445
|
+
workspace_readback_hash: hashJson(workspaceReadback)
|
|
4446
|
+
};
|
|
4447
|
+
} catch (error) {
|
|
4448
|
+
const message = error instanceof Error ? error.message : String(error || "");
|
|
4449
|
+
throw new Error(`flow-app create failed: ${message}. Created resources: ${JSON.stringify(createdResources)}. Next recovery: fix the failing step, then rerun the corresponding typed config command or rerun flow-app create only if duplicate resources are acceptable.`);
|
|
4450
|
+
}
|
|
4451
|
+
}
|
|
4067
4452
|
async function readBackConfigDomain(profile, domain, id, definition) {
|
|
4068
4453
|
const data = await readRemoteConfigDomain(profile, domain, id, definition);
|
|
4454
|
+
if (domain === "form-template") {
|
|
4455
|
+
assertFormTemplateDraftId(id, data, "verify");
|
|
4456
|
+
}
|
|
4069
4457
|
validateExpectedType(domain, definition, data);
|
|
4070
4458
|
return {
|
|
4071
4459
|
readback_hash: hashJson(data)
|
|
@@ -4158,6 +4546,9 @@ async function exportConfigDomain(config, profile, domain, id, outDir, options =
|
|
|
4158
4546
|
}
|
|
4159
4547
|
await ensureConfigCapability(profile, `${definition.capability}.export`);
|
|
4160
4548
|
const data = await readRemoteConfigDomain(profile, domain, id, definition);
|
|
4549
|
+
if (domain === "form-template") {
|
|
4550
|
+
assertFormTemplateDraftId(id, data, "export");
|
|
4551
|
+
}
|
|
4161
4552
|
validateExpectedType(domain, definition, data);
|
|
4162
4553
|
const baseHash = hashJson(data);
|
|
4163
4554
|
const stem = `${domain}-${id}`;
|
|
@@ -4187,7 +4578,8 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
4187
4578
|
}
|
|
4188
4579
|
const work = await readJsonFile(workFile);
|
|
4189
4580
|
const meta = metaFile ? await readJsonFile(metaFile) : {};
|
|
4190
|
-
|
|
4581
|
+
const createMode = isRecord3(work) && work.mode === "create" || isRecord3(meta) && meta.mode === "create";
|
|
4582
|
+
if (!isRecord3(meta) || meta.domain !== domain || !createMode && typeof meta.base_hash !== "string") {
|
|
4191
4583
|
throw new Error("Config build requires a meta file produced by `bpmax-cli config <domain> export`.");
|
|
4192
4584
|
}
|
|
4193
4585
|
const raw = typeof meta.raw_file === "string" ? await readJsonFile(meta.raw_file) : void 0;
|
|
@@ -4203,7 +4595,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
4203
4595
|
domain,
|
|
4204
4596
|
built_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4205
4597
|
meta,
|
|
4206
|
-
base_hash: meta.base_hash,
|
|
4598
|
+
base_hash: typeof meta.base_hash === "string" ? meta.base_hash : null,
|
|
4207
4599
|
payload
|
|
4208
4600
|
};
|
|
4209
4601
|
await writeJsonFile(outFile, result);
|
|
@@ -4235,6 +4627,83 @@ async function lintConfigWorkFile(file) {
|
|
|
4235
4627
|
async function submitConfigDomain(config, profile, domain, id, submitFile, confirm3, options = {}) {
|
|
4236
4628
|
void config;
|
|
4237
4629
|
const definition = CONFIG_DOMAINS[domain];
|
|
4630
|
+
if (domain === "workspace-flow") {
|
|
4631
|
+
if (definition.submitStatus !== "supported") {
|
|
4632
|
+
throw new Error(`${CONFIG_SUBMIT_UNSUPPORTED_MESSAGE} Domain: ${domain}.`);
|
|
4633
|
+
}
|
|
4634
|
+
await ensureConfigCapability(profile, `${definition.capability}.submit`);
|
|
4635
|
+
await ensureConfigCapability(profile, `${definition.capability}.export`);
|
|
4636
|
+
const submit2 = await readJsonFile(submitFile);
|
|
4637
|
+
if (!isRecord3(submit2) || submit2.domain !== domain || !isRecord3(submit2.payload)) {
|
|
4638
|
+
throw new Error("Config submit requires a payload produced by `bpmax-cli config <domain> build`.");
|
|
4639
|
+
}
|
|
4640
|
+
const meta2 = submit2.meta;
|
|
4641
|
+
if (!isRecord3(meta2)) {
|
|
4642
|
+
throw new Error("Config submit payload is missing export metadata. Export the remote config first, then rebuild with --meta.");
|
|
4643
|
+
}
|
|
4644
|
+
if (meta2.domain !== domain) {
|
|
4645
|
+
throw new Error(`Config submit metadata domain mismatch. Expected ${domain}, got ${String(meta2.domain)}.`);
|
|
4646
|
+
}
|
|
4647
|
+
if (normalizeWorkspaceKey(String(meta2.id || "")) !== normalizeWorkspaceKey(id)) {
|
|
4648
|
+
throw new Error(`Config submit metadata id mismatch. Expected ${id}, got ${String(meta2.id || "")}.`);
|
|
4649
|
+
}
|
|
4650
|
+
if (meta2.profile !== profile.name) {
|
|
4651
|
+
throw new Error(`Config submit metadata profile mismatch. Expected ${profile.name}, got ${String(meta2.profile)}.`);
|
|
4652
|
+
}
|
|
4653
|
+
const workspace = normalizeWorkspaceKey(String(submit2.payload.workspace || id));
|
|
4654
|
+
const metaWorkspace = normalizeWorkspaceKey(String(meta2.workspace || meta2.id || ""));
|
|
4655
|
+
if (metaWorkspace && metaWorkspace !== workspace) {
|
|
4656
|
+
throw new Error(`Config submit metadata workspace mismatch. Expected ${workspace}, got ${metaWorkspace}.`);
|
|
4657
|
+
}
|
|
4658
|
+
const endpoint2 = "/workspace/workspace_flow";
|
|
4659
|
+
const submitPayload2 = { workspace_flow: normalizeWorkspaceFlowItems(submit2.payload.workspace_flow) };
|
|
4660
|
+
const current2 = await readRemoteConfigDomain(profile, domain, workspace, definition);
|
|
4661
|
+
if (typeof submit2.base_hash === "string" && hashJson(current2) !== submit2.base_hash) {
|
|
4662
|
+
throw new Error("Remote config changed after export. Re-export before submitting.");
|
|
4663
|
+
}
|
|
4664
|
+
const expectedConfirm2 = `submit ${domain} ${id}`;
|
|
4665
|
+
if (confirm3 !== expectedConfirm2) {
|
|
4666
|
+
return {
|
|
4667
|
+
dry_run: true,
|
|
4668
|
+
domain,
|
|
4669
|
+
id,
|
|
4670
|
+
endpoint: endpoint2,
|
|
4671
|
+
method: "PUT",
|
|
4672
|
+
params: { workspace },
|
|
4673
|
+
payload: submitPayload2,
|
|
4674
|
+
current_hash: hashJson(current2),
|
|
4675
|
+
next: `Run again with --confirm "${expectedConfirm2}" to submit.`
|
|
4676
|
+
};
|
|
4677
|
+
}
|
|
4678
|
+
const client2 = createApiClient(profile);
|
|
4679
|
+
const response2 = await apiRequest(
|
|
4680
|
+
client2,
|
|
4681
|
+
"PUT",
|
|
4682
|
+
endpoint2,
|
|
4683
|
+
{ data: submitPayload2, params: { workspace }, capability: `${definition.capability}.submit` }
|
|
4684
|
+
);
|
|
4685
|
+
const readback2 = await readRemoteConfigDomain(profile, domain, workspace, definition);
|
|
4686
|
+
const bindings = isRecord3(readback2) ? normalizeWorkspaceFlowItems(readback2.workspace_flow) : [];
|
|
4687
|
+
const expectedBindings = normalizeWorkspaceFlowItems(submitPayload2.workspace_flow);
|
|
4688
|
+
const missingBindings = expectedBindings.filter(
|
|
4689
|
+
(expected) => !bindings.some(
|
|
4690
|
+
(actual) => buildWorkspaceFlowBindingKey(actual.flow_type, actual.flow_key) === buildWorkspaceFlowBindingKey(expected.flow_type, expected.flow_key)
|
|
4691
|
+
)
|
|
4692
|
+
);
|
|
4693
|
+
if (missingBindings.length) {
|
|
4694
|
+
throw new Error(`workspace-flow submit verification failed; missing bindings: ${missingBindings.map((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key)).join(", ")}`);
|
|
4695
|
+
}
|
|
4696
|
+
return {
|
|
4697
|
+
dry_run: false,
|
|
4698
|
+
domain,
|
|
4699
|
+
id,
|
|
4700
|
+
endpoint: endpoint2,
|
|
4701
|
+
method: "PUT",
|
|
4702
|
+
params: { workspace },
|
|
4703
|
+
response: response2,
|
|
4704
|
+
readback_hash: hashJson(readback2)
|
|
4705
|
+
};
|
|
4706
|
+
}
|
|
4238
4707
|
if (domain === "role" || domain === "api-platform" || domain === "nav-config") {
|
|
4239
4708
|
if (definition.submitStatus !== "supported") {
|
|
4240
4709
|
throw new Error(`${CONFIG_SUBMIT_UNSUPPORTED_MESSAGE} Domain: ${domain}.`);
|
|
@@ -4313,8 +4782,72 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
4313
4782
|
validateFlowTemplateStandardFlowType(submit.payload);
|
|
4314
4783
|
validateFlowTemplateIdentityStandard(id, submit.payload);
|
|
4315
4784
|
}
|
|
4785
|
+
const submitMode = isRecord3(meta) ? meta.mode : void 0;
|
|
4786
|
+
if (domain === "form-template" && submitMode === "create") {
|
|
4787
|
+
await ensureConfigCapability(profile, `${definition.capability}.create`);
|
|
4788
|
+
const expectedConfirm2 = `submit ${domain} ${id}`;
|
|
4789
|
+
const endpoint2 = "/form_template";
|
|
4790
|
+
if (confirm3 !== expectedConfirm2) {
|
|
4791
|
+
return {
|
|
4792
|
+
dry_run: true,
|
|
4793
|
+
domain,
|
|
4794
|
+
id,
|
|
4795
|
+
endpoint: endpoint2,
|
|
4796
|
+
method: "POST",
|
|
4797
|
+
payload: submit.payload,
|
|
4798
|
+
publish_endpoint: "/form_template/publish",
|
|
4799
|
+
next: `Run again with --confirm "${expectedConfirm2}" to submit.`
|
|
4800
|
+
};
|
|
4801
|
+
}
|
|
4802
|
+
const client2 = createApiClient(profile);
|
|
4803
|
+
const response2 = await apiRequest(
|
|
4804
|
+
client2,
|
|
4805
|
+
"POST",
|
|
4806
|
+
endpoint2,
|
|
4807
|
+
{ data: submit.payload, capability: `${definition.capability}.create` }
|
|
4808
|
+
);
|
|
4809
|
+
const draftId = responseDataId(response2);
|
|
4810
|
+
if (draftId === void 0 || draftId === null || draftId === "") {
|
|
4811
|
+
throw new Error("form-template create did not return a draft id.");
|
|
4812
|
+
}
|
|
4813
|
+
const publishResponse2 = await apiRequest(
|
|
4814
|
+
client2,
|
|
4815
|
+
"POST",
|
|
4816
|
+
"/form_template/publish",
|
|
4817
|
+
{ data: { id: draftId }, capability: `${definition.capability}.submit` }
|
|
4818
|
+
);
|
|
4819
|
+
const publishedId = responseDataId(publishResponse2) ?? draftId;
|
|
4820
|
+
const draftReadback = await apiRequest(
|
|
4821
|
+
client2,
|
|
4822
|
+
"GET",
|
|
4823
|
+
`/form_template/${draftId}`,
|
|
4824
|
+
{ capability: `${definition.capability}.export` }
|
|
4825
|
+
);
|
|
4826
|
+
const publishedReadback = await apiRequest(
|
|
4827
|
+
client2,
|
|
4828
|
+
"GET",
|
|
4829
|
+
`/form_template/${publishedId}`,
|
|
4830
|
+
{ capability: `${definition.capability}.export` }
|
|
4831
|
+
);
|
|
4832
|
+
return {
|
|
4833
|
+
dry_run: false,
|
|
4834
|
+
domain,
|
|
4835
|
+
id,
|
|
4836
|
+
endpoint: endpoint2,
|
|
4837
|
+
method: "POST",
|
|
4838
|
+
response: response2,
|
|
4839
|
+
draft_id: draftId,
|
|
4840
|
+
published_id: publishedId,
|
|
4841
|
+
publish_response: publishResponse2,
|
|
4842
|
+
draft_readback_hash: hashJson(draftReadback),
|
|
4843
|
+
published_readback_hash: hashJson(publishedReadback)
|
|
4844
|
+
};
|
|
4845
|
+
}
|
|
4316
4846
|
const expectedConfirm = `submit ${domain} ${id}`;
|
|
4317
4847
|
const current = await readRemoteConfigDomain(profile, domain, id, definition);
|
|
4848
|
+
if (domain === "form-template") {
|
|
4849
|
+
assertFormTemplateDraftId(id, current, "submit");
|
|
4850
|
+
}
|
|
4318
4851
|
validateExpectedType(domain, definition, current);
|
|
4319
4852
|
const currentHash = hashJson(current);
|
|
4320
4853
|
if (currentHash !== submit.base_hash) {
|
|
@@ -5281,6 +5814,24 @@ function registerConfigCommands(program2) {
|
|
|
5281
5814
|
next: `Run git -C ${environment.sysconfig_repo_path} status --short and git diff to inspect local changes.`
|
|
5282
5815
|
});
|
|
5283
5816
|
});
|
|
5817
|
+
config.command("flow-app").description("Create an end-to-end BPMAX flow app from form and flow work files").command("create").description("Create a form template, create a main flow, bind the published form, and bind the flow to a workspace").requiredOption("--workspace <workspace>", "Target workspace key, e.g. oa or w:oa").requiredOption("--form-work <file>", "Form-template work JSON file").requiredOption("--flow-work <file>", "Flow-template work JSON file").requiredOption("--name <name>", "Flow app name used in the confirmation text").option("--profile <profile>", "Profile name").option("--draft-only", "Save the created flow as draft only instead of publishing live").option("--confirm <text>", "Exact confirmation text").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
5818
|
+
const configData = await loadConfig();
|
|
5819
|
+
const resolved = resolveProfile(configData, options.profile);
|
|
5820
|
+
const result = await createFlowAppFromWork(
|
|
5821
|
+
configData,
|
|
5822
|
+
resolved,
|
|
5823
|
+
options.formWork,
|
|
5824
|
+
options.flowWork,
|
|
5825
|
+
options.confirm,
|
|
5826
|
+
{
|
|
5827
|
+
workspace: options.workspace,
|
|
5828
|
+
name: options.name,
|
|
5829
|
+
publishLive: !options.draftOnly
|
|
5830
|
+
}
|
|
5831
|
+
);
|
|
5832
|
+
await saveConfig(configData);
|
|
5833
|
+
printResult(options.format, result);
|
|
5834
|
+
});
|
|
5284
5835
|
const init = config.command("init").description("Initialize BPMAX configuration helper files");
|
|
5285
5836
|
init.command("workspace").description("Create or update an AGENTS.md BPMAX configuration guide in a workspace directory").requiredOption("--env <env>", "Configuration environment key").option("--profile <profile>", "Profile name").option("--cwd <dir>", "Target workspace directory", process.cwd()).option("--file <file>", "Agent guide file name", DEFAULT_AGENT_GUIDE_FILE).option("--dry-run", "Print the generated content without writing the file").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
5286
5837
|
const configData = await loadConfig();
|
|
@@ -5297,6 +5848,21 @@ function registerConfigCommands(program2) {
|
|
|
5297
5848
|
});
|
|
5298
5849
|
Object.keys(CONFIG_DOMAINS).forEach((domain) => {
|
|
5299
5850
|
const domainCommand = config.command(domain).description(`Manage BPMAX ${domain} configuration`);
|
|
5851
|
+
if (domain === "flow-template") {
|
|
5852
|
+
domainCommand.command("create").description("Create a new main flow template through the typed adapter").requiredOption("--work <file>", "Flow-template work JSON file").option("--profile <profile>", "Profile name").option("--publish-live", "Publish the created flow to live after saving draft").option("--confirm <text>", "Exact confirmation text").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
5853
|
+
const configData = await loadConfig();
|
|
5854
|
+
const resolved = resolveProfile(configData, options.profile);
|
|
5855
|
+
const result = await createFlowTemplateFromWork(
|
|
5856
|
+
configData,
|
|
5857
|
+
resolved,
|
|
5858
|
+
options.work,
|
|
5859
|
+
options.confirm,
|
|
5860
|
+
{ publishLive: Boolean(options.publishLive) }
|
|
5861
|
+
);
|
|
5862
|
+
await saveConfig(configData);
|
|
5863
|
+
printResult(options.format, result);
|
|
5864
|
+
});
|
|
5865
|
+
}
|
|
5300
5866
|
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) => {
|
|
5301
5867
|
const configData = await loadConfig();
|
|
5302
5868
|
const resolved = resolveProfile(configData, options.profile);
|
|
@@ -5426,7 +5992,7 @@ function registerEsCommands(program2) {
|
|
|
5426
5992
|
}
|
|
5427
5993
|
|
|
5428
5994
|
// src/commands/flow.ts
|
|
5429
|
-
function
|
|
5995
|
+
function normalizeWorkspaceKey2(workspace) {
|
|
5430
5996
|
const nextWorkspace = workspace.trim().replace(/^\/+|\/+$/g, "");
|
|
5431
5997
|
return nextWorkspace.startsWith("w:") ? nextWorkspace.slice(2) : nextWorkspace;
|
|
5432
5998
|
}
|
|
@@ -5437,11 +6003,12 @@ async function getWorkspaceFlowBindings(client, profile, options) {
|
|
|
5437
6003
|
if (options.all) {
|
|
5438
6004
|
return void 0;
|
|
5439
6005
|
}
|
|
5440
|
-
const workspace =
|
|
6006
|
+
const workspace = normalizeWorkspaceKey2(options.workspace || profile.config.workspace);
|
|
5441
6007
|
const workspaceInfo = await apiRequest(client, "GET", "/workspace/by_key", {
|
|
5442
6008
|
params: {
|
|
5443
6009
|
key: workspace
|
|
5444
|
-
}
|
|
6010
|
+
},
|
|
6011
|
+
capability: "flow.list"
|
|
5445
6012
|
});
|
|
5446
6013
|
return new Set(
|
|
5447
6014
|
(workspaceInfo.workspace_flow || []).map((item) => flowBindingKey(item.flow_type, item.flow_key))
|
|
@@ -6399,7 +6966,9 @@ async function fetchProjectFormTemplate(client, flowDetail) {
|
|
|
6399
6966
|
if (!templateId) {
|
|
6400
6967
|
return void 0;
|
|
6401
6968
|
}
|
|
6402
|
-
const template = await apiRequest(client, "GET", `/form_template/${templateId}
|
|
6969
|
+
const template = await apiRequest(client, "GET", `/form_template/${templateId}`, {
|
|
6970
|
+
capability: "project.create"
|
|
6971
|
+
});
|
|
6403
6972
|
return { templateId, template };
|
|
6404
6973
|
}
|
|
6405
6974
|
function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
@@ -6542,7 +7111,9 @@ async function validateCreateForm(client, options) {
|
|
|
6542
7111
|
}
|
|
6543
7112
|
const templateId = getFlowFormTemplateId(flowDetail);
|
|
6544
7113
|
if (options.projectFormTemplate || templateId) {
|
|
6545
|
-
const template = options.projectFormTemplate?.template ?? (templateId ? await apiRequest(client, "GET", `/form_template/${templateId}
|
|
7114
|
+
const template = options.projectFormTemplate?.template ?? (templateId ? await apiRequest(client, "GET", `/form_template/${templateId}`, {
|
|
7115
|
+
capability: "project.create"
|
|
7116
|
+
}) : void 0);
|
|
6546
7117
|
const templateFields = extractFormFields(template);
|
|
6547
7118
|
if (templateFields.length > 0) {
|
|
6548
7119
|
const result2 = validateFormAgainstFields(options.form, templateFields);
|
|
@@ -7503,9 +8074,14 @@ var schemaEntries = [
|
|
|
7503
8074
|
{ name: "config.adapters", description: "Show typed config adapter coverage and verified API surfaces.", bootstrap: true },
|
|
7504
8075
|
{ name: "config.init.workspace", description: "Create or update a local AGENTS.md BPMAX config guide.", bootstrap: true },
|
|
7505
8076
|
{ name: "config.form_template.export", description: "Export form template config.", method: "GET", path: "/api/form_template/:id" },
|
|
8077
|
+
{ name: "config.form_template.create", description: "Create and publish a form template through a verified typed adapter.", method: "POST", path: "/api/form_template + /api/form_template/publish" },
|
|
7506
8078
|
{ name: "config.form_template.submit", description: "Submit form template edits through a verified typed adapter.", method: "PUT/POST", path: "/api/form_template/:id + /api/form_template/publish" },
|
|
7507
8079
|
{ name: "config.flow_template.export", description: "Export flow template config when a verified draft-aware adapter is available.", method: "GET", path: "/api/flow?flow_type=:flow_type&key=:key&draft=1" },
|
|
8080
|
+
{ name: "config.flow_template.create", description: "Create a platform-generated main flow shell through a verified typed adapter.", method: "POST", path: "/api/flow/flow_type" },
|
|
7508
8081
|
{ name: "config.flow_template.submit", description: "Submit flow template config when a verified draft-aware adapter is available.", method: "PUT", path: "/api/flow?flow_type=:flow_type&key=:key&publish=:publish" },
|
|
8082
|
+
{ name: "config.workspace_flow.export", description: "Export workspace-bound flow relations.", method: "GET", path: "/api/workspace/by_key?key=:workspace" },
|
|
8083
|
+
{ name: "config.workspace_flow.submit", description: "Submit workspace-bound flow relations through a verified typed adapter.", method: "PUT", path: "/api/workspace/workspace_flow" },
|
|
8084
|
+
{ name: "config.flow_app.create", description: "Create form template, create flow template, bind form, and bind the flow to a workspace.", method: "POST/PUT", path: "/api/form_template + /api/flow/flow_type + /api/flow + /api/workspace/workspace_flow" },
|
|
7509
8085
|
{ name: "config.list_template.export", description: "Export list template config.", method: "GET", path: "/api/flow_page_template/:id?skip_i18n=true" },
|
|
7510
8086
|
{ name: "config.list_template.submit", description: "Submit list template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id" },
|
|
7511
8087
|
{ name: "config.filter_template.export", description: "Export filter template config.", method: "GET", path: "/api/flow_page_template/:id?skip_i18n=true" },
|