@stalfh233/omc-fake-platform 0.6.53 → 0.6.54
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/workflow.js +102 -0
- package/package.json +2 -2
package/dist/workflow.js
CHANGED
|
@@ -424,6 +424,108 @@ export const workflowRoute = (ctx, input) => {
|
|
|
424
424
|
const existed = ctx.state.workflowInstances.delete(id);
|
|
425
425
|
return existed;
|
|
426
426
|
}
|
|
427
|
+
// r64:运维三件套依赖的两个读回面(此前只有真机测试,fake 未建模)。
|
|
428
|
+
case "/api/api/runtime/workflow/list_workflow_instance_activity": {
|
|
429
|
+
// 从 workItems 派生活动清单:PENDING 待办所在节点 status=1(带参与人),
|
|
430
|
+
// 其余出现过的节点 status=0。真机语义见 workflow.instanceActivity 契约。
|
|
431
|
+
const instanceId = String(q.workflowInstanceId ?? "");
|
|
432
|
+
const items = [...ctx.state.workItems.values()].filter((item) => item.instanceId === instanceId);
|
|
433
|
+
if (items.length === 0 && !ctx.state.workflowInstances.has(instanceId))
|
|
434
|
+
return businessRefusal(402504, "流程实例状态不存在!");
|
|
435
|
+
const byCode = new Map();
|
|
436
|
+
for (const item of items) {
|
|
437
|
+
const active = PENDING_STATES.has(item.state);
|
|
438
|
+
const existing = byCode.get(item.activityCode);
|
|
439
|
+
if (!existing) {
|
|
440
|
+
byCode.set(item.activityCode, {
|
|
441
|
+
activityCode: item.activityCode,
|
|
442
|
+
activityName: item.activityName,
|
|
443
|
+
activityType: "PARTICIPANT",
|
|
444
|
+
participantors: active ? [{ name: item.participantName ?? item.participant, id: item.participant }] : null,
|
|
445
|
+
status: active ? 1 : 0,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
else if (active) {
|
|
449
|
+
existing.status = 1;
|
|
450
|
+
existing.participantors = [{ name: item.participantName ?? item.participant, id: item.participant }];
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return [...byCode.values()];
|
|
454
|
+
}
|
|
455
|
+
case "/api/api/runtime/workflow/get_instance_baseinfo": {
|
|
456
|
+
const instanceId = String(q.workflowInstanceId ?? "");
|
|
457
|
+
const instance = ctx.state.workflowInstances.get(instanceId);
|
|
458
|
+
if (!instance) {
|
|
459
|
+
// startWorkflowInstance(直起路径)只写 workItems 不建实例行——从待办
|
|
460
|
+
// 存在性合成基线状态,运维读回不 404。
|
|
461
|
+
const items = [...ctx.state.workItems.values()].filter((item) => item.instanceId === instanceId);
|
|
462
|
+
if (items.length === 0)
|
|
463
|
+
return businessRefusal(402504, "流程实例状态不存在!");
|
|
464
|
+
return { workflowInstanceId: instanceId, workflowName: items[0].workflowCode, status: "PROCESSING" };
|
|
465
|
+
}
|
|
466
|
+
return { workflowInstanceId: instanceId, workflowCode: instance.workflowCode, workflowName: instance.workflowCode, status: instance.status };
|
|
467
|
+
}
|
|
468
|
+
case "/api/api/runtime/workflow/workflow_operation": {
|
|
469
|
+
const instanceId = String(body.workflowInstanceId ?? "");
|
|
470
|
+
const instance = ctx.state.workflowInstances.get(instanceId);
|
|
471
|
+
if (!instance)
|
|
472
|
+
return businessRefusal(402504, "流程实例状态不存在!");
|
|
473
|
+
if (typeof body.approval !== "object" || body.approval === null || Array.isArray(body.approval))
|
|
474
|
+
return businessRefusal(10009, "类型转换异常(approval 必须是对象 {activityCode,commonSet,deleted,resources,content})");
|
|
475
|
+
const operationType = String(body.operationType ?? "");
|
|
476
|
+
if (operationType === "ADJUST_PARTICIPANT") {
|
|
477
|
+
const ids = Array.isArray(body.participantors) ? body.participantors.map(String) : [];
|
|
478
|
+
if (ids.length === 0)
|
|
479
|
+
return businessRefusal(40000, "participantors 为空");
|
|
480
|
+
let hit = false;
|
|
481
|
+
for (const item of ctx.state.workItems.values()) {
|
|
482
|
+
if (item.instanceId !== instanceId || !PENDING_STATES.has(item.state))
|
|
483
|
+
continue;
|
|
484
|
+
if (body.activityCode !== undefined && item.activityCode !== String(body.activityCode))
|
|
485
|
+
continue;
|
|
486
|
+
item.participant = ids[0];
|
|
487
|
+
item.participantName = ids[0];
|
|
488
|
+
hit = true;
|
|
489
|
+
}
|
|
490
|
+
return hit;
|
|
491
|
+
}
|
|
492
|
+
if (operationType === "ACTIVATE_ACTIVITY") {
|
|
493
|
+
const target = String(body.activityCode ?? "");
|
|
494
|
+
if (!target)
|
|
495
|
+
return businessRefusal(40000, "activityCode 为空");
|
|
496
|
+
const ids = Array.isArray(body.participantors) ? body.participantors.map(String) : [];
|
|
497
|
+
for (const item of ctx.state.workItems.values()) {
|
|
498
|
+
if (item.instanceId !== instanceId)
|
|
499
|
+
continue;
|
|
500
|
+
if (PENDING_STATES.has(item.state))
|
|
501
|
+
item.state = "FINISHED";
|
|
502
|
+
if (item.activityCode === target) {
|
|
503
|
+
// fake 的待办状态词表是 NOTSTARTED/INPROGRESS/DRAFT(PENDING_STATES),
|
|
504
|
+
// 别写 PENDING——那不在集合里,读回会当成已完结。
|
|
505
|
+
item.state = "INPROGRESS";
|
|
506
|
+
if (ids.length > 0) {
|
|
507
|
+
item.participant = ids[0];
|
|
508
|
+
item.participantName = ids[0];
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
return businessRefusal(40000, `operationType ${operationType} 未建模(fake 仅 ADJUST_PARTICIPANT/ACTIVATE_ACTIVITY)`);
|
|
515
|
+
}
|
|
516
|
+
case "/api/api/runtime/workflow/finish_instance_by_post": {
|
|
517
|
+
// r64:发起人「结束流程」——正常完结语义(end 规则照常触发)。
|
|
518
|
+
const instanceId = String(body.workflowInstanceId ?? "");
|
|
519
|
+
const instance = ctx.state.workflowInstances.get(instanceId);
|
|
520
|
+
if (!instance)
|
|
521
|
+
return businessRefusal(402504, "流程实例状态不存在!");
|
|
522
|
+
instance.status = "COMPLETED";
|
|
523
|
+
for (const item of ctx.state.workItems.values()) {
|
|
524
|
+
if (item.instanceId === instanceId && PENDING_STATES.has(item.state))
|
|
525
|
+
item.state = "FINISHED";
|
|
526
|
+
}
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
427
529
|
case "/api/api/runtime/workflow/list_workitems": {
|
|
428
530
|
// The JPA-spec face (WorkflowInstanceController.listWorkItems): it queri
|
|
429
531
|
// the work-item table directly instead of resolving each hit's template,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-fake-platform",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.54",
|
|
4
4
|
"description": "OMC 的内存假 CloudPivot 平台(wire 接缝的第二个适配器)+ HTTP 假服务器——@stalfh233/omc-cli 的测试与 bench 基准基座",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"build": "tsc --project tsconfig.build.json"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"omc-core": "0.6.
|
|
21
|
+
"omc-core": "0.6.54"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=22.13"
|