@stalfh233/omc-fake-platform 0.6.53 → 0.6.55

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/app.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  import { type LaneRoute } from "./state.js";
2
- /** app-management lane: application package CRUD. Twin of src/lanes/app.ts. */
3
2
  export declare const appRoute: LaneRoute;
package/dist/app.js CHANGED
@@ -1,5 +1,64 @@
1
- import { NOT_HANDLED } from "./state.js";
2
- /** app-management lane: application package CRUD. Twin of src/lanes/app.ts. */
1
+ import { buildZip } from "omc-core/zip";
2
+ import { businessRefusal, NOT_HANDLED, rawResponse } from "./state.js";
3
+ /**
4
+ * r64b fixtures: the two real export faces.
5
+ *
6
+ * - `/app/apppackage/export` (AppImportExportController.exportApp) streams one
7
+ * app package `<code>-<uuid>/{manifest.json, meta/…, dependencies/…}`;
8
+ * refusals stay HTTP-200 envelopes (10005 empty code, 600005 unknown app).
9
+ * - `/lifeCycle/apppackage/lifeCycleExport` (LifeCycleIEFacadeImpl) streams
10
+ * `metadata.zip` with EVERY app package under metadata/app/applist/<code>/,
11
+ * appgroup.json, all biz services + datasources, and metadata/manifest.json;
12
+ * a non-POST call answers 40007 请求方法不正确.
13
+ */
14
+ function modelRowsOf(ctx, appCode) {
15
+ return [...ctx.state.models.values()]
16
+ .filter((model) => (model.appCode ?? "") === appCode)
17
+ .map((model) => ({ code: model.code, name: model.name, appCode }));
18
+ }
19
+ function appPackageFiles(ctx, app, references, staging) {
20
+ const json = (value) => Buffer.from(JSON.stringify(value, null, "\t"), "utf8");
21
+ const files = [
22
+ {
23
+ name: `${staging}/manifest.json`,
24
+ data: json({
25
+ code: app.code,
26
+ name: app.name,
27
+ systemVersion: null,
28
+ schemaVersion: "1.0",
29
+ bizModels: modelRowsOf(ctx, app.code),
30
+ modelGroups: [],
31
+ reportModels: [],
32
+ customPages: [],
33
+ appPages: [],
34
+ }),
35
+ },
36
+ { name: `${staging}/meta/dm/${app.code}.dm.json`, data: json({ bizObjectModels: [], businessRule: [], dataRule: [] }) },
37
+ { name: `${staging}/meta/form/${app.code}.form.json`, data: json({}) },
38
+ { name: `${staging}/meta/view/${app.code}.view.json`, data: json({}) },
39
+ { name: `${staging}/meta/workflow/${app.code}.workflow.json`, data: json({}) },
40
+ { name: `${staging}/meta/report/${app.code}.report.json`, data: json({}) },
41
+ { name: `${staging}/dependencies/platform/environment/environment.json`, data: json({ environment: {} }) },
42
+ { name: `${staging}/version.md`, data: Buffer.from("8.6.26", "utf8") },
43
+ { name: `${staging}/README.md`, data: Buffer.from("# 应用详细介绍和使用说明文档\n", "utf8") },
44
+ ];
45
+ const dependencies = `${staging}/dependencies/platform`;
46
+ const dictionaries = references.relativeDictionary;
47
+ if (Array.isArray(dictionaries) && dictionaries.length > 0)
48
+ files.push({ name: `${dependencies}/dictionary/dictionary.json`, data: json({ dictionaries }) });
49
+ const roles = references.relativeRole;
50
+ if (Array.isArray(roles) && roles.length > 0)
51
+ files.push({ name: `${dependencies}/role/role.json`, data: json({ roles }) });
52
+ const bizServices = references.relativeBizService;
53
+ if (Array.isArray(bizServices) && bizServices.length > 0)
54
+ files.push({ name: `${dependencies}/bizMethod/bizMethod.json`, data: json({ categories: [], services: bizServices, methodsMap: {} }) });
55
+ const datasource = {
56
+ relativeAdvanceDataSource: references.relativeAdvanceDataSource ?? null,
57
+ relativeReportAdvanceDataSource: references.relativeReportAdvanceDataSource ?? null,
58
+ };
59
+ files.push({ name: `${dependencies}/datasource/datasource.json`, data: json(datasource) });
60
+ return files;
61
+ }
3
62
  export const appRoute = (ctx, input) => {
4
63
  const q = input.query ?? {};
5
64
  const body = (input.body ?? {});
@@ -61,6 +120,61 @@ export const appRoute = (ctx, input) => {
61
120
  case "/api/api/app/apppackage/delete":
62
121
  ctx.state.apps.delete(String(q.appCode));
63
122
  return null;
123
+ case "/api/api/app/apppackage/dependencies": {
124
+ const appCode = String(q.appCode ?? body.appCode ?? "");
125
+ return ctx.state.appDependencies.get(appCode) ?? {
126
+ relativeApps: [],
127
+ relativeSchemas: [],
128
+ relativeDepartment: [],
129
+ relativeUser: [],
130
+ relativeRole: [],
131
+ relativeDictionary: [],
132
+ relativeBizService: [],
133
+ relativeEnvironment: [],
134
+ relativeAppPage: [],
135
+ relativeDashboard: [],
136
+ relativeAdvanceDataSource: [],
137
+ relativeReportAdvanceDataSource: [],
138
+ inheritSchemas: [],
139
+ templateSchema: null,
140
+ relativeCustomPage: [],
141
+ };
142
+ }
143
+ case "/api/api/app/apppackage/export": {
144
+ const appCode = String(body.appCode ?? "");
145
+ if (!appCode)
146
+ return businessRefusal(10005, "应用编码不能为空");
147
+ const app = [...ctx.state.apps.values()].find((row) => row.code === appCode);
148
+ if (!app)
149
+ return businessRefusal(600005, "应用不存在!");
150
+ const references = (body.references ?? {});
151
+ const staging = `${appCode}-${String(Math.random()).slice(2, 14)}`;
152
+ return rawResponse(buildZip(appPackageFiles(ctx, app, references, staging)));
153
+ }
154
+ case "/api/api/lifeCycle/apppackage/lifeCycleExport": {
155
+ if (input.method !== "POST")
156
+ return businessRefusal(40007, "请求方法不正确");
157
+ const json = (value) => Buffer.from(JSON.stringify(value, null, "\t"), "utf8");
158
+ const files = [];
159
+ for (const app of ctx.state.apps.values()) {
160
+ // LifeCycleIEFacadeImpl.exportApps passes NO references per app.
161
+ files.push(...appPackageFiles(ctx, app, {}, `metadata/app/applist/${app.code}`));
162
+ }
163
+ files.push({ name: "metadata/app/appgroup.json", data: json([...ctx.state.appGroups.values()].map((group) => ({ ...group }))) });
164
+ const services = [...ctx.state.services.values()];
165
+ const methodsMap = {};
166
+ for (const service of services)
167
+ methodsMap[service.code] = service.methods.map((method) => ({ code: method.code, serviceCode: service.code }));
168
+ files.push({ name: "metadata/bizservice/manifest.json", data: json({ services: services.map((service) => ({ code: service.code, name: service.name })), methodsMap }) });
169
+ files.push({ name: "metadata/bizservice/servicegroup.json", data: json(ctx.state.categories.map((category) => ({ id: category.id, name: category.name }))) });
170
+ files.push({ name: "metadata/bizservice/bizdatasource.json", data: json({ relativeAdvanceDataSource: null, relativeReportAdvanceDataSource: null }) });
171
+ files.push({ name: "metadata/bizservice/version.md", data: Buffer.from("8.6.26", "utf8") });
172
+ files.push({
173
+ name: "metadata/manifest.json",
174
+ data: json({ author: null, base: null, code: "fake-lifecycle", dependencies: null, description: null, name: "云枢应用", version: { app: "0", cloudpivot: "8.6.26" } }),
175
+ });
176
+ return rawResponse(buildZip(files));
177
+ }
64
178
  default:
65
179
  return NOT_HANDLED;
66
180
  }
package/dist/state.d.ts CHANGED
@@ -519,6 +519,12 @@ export interface FakeState {
519
519
  }>;
520
520
  apps: Map<string, FakeApp>;
521
521
  appGroups: Map<string, FakeAppGroup>;
522
+ /**
523
+ * r64b: `/app/apppackage/dependencies?appCode=` fixture. The design UI feeds
524
+ * the returned rows back VERBATIM as `references` to apppackage/export, so a
525
+ * test seeds the five refTabsKey arrays here and asserts they reach the wire.
526
+ */
527
+ appDependencies: Map<string, Record<string, unknown>>;
522
528
  callLog: FakeCallLogEntry[];
523
529
  }
524
530
  export interface FakeRequestInput {
package/dist/state.js CHANGED
@@ -87,6 +87,7 @@ export function createFakeState(options = {}) {
87
87
  models: new Map(),
88
88
  apps: new Map([[defaultAppCode, { id: "app-1", code: defaultAppCode, name: "Test App", groupId: "group-1" }]]),
89
89
  appGroups: new Map([["group-1", { id: "group-1", code: "default", name: "默认分组" }]]),
90
+ appDependencies: new Map(),
90
91
  callLog: [],
91
92
  };
92
93
  }
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.53",
3
+ "version": "0.6.55",
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.53"
21
+ "omc-core": "0.6.55"
22
22
  },
23
23
  "engines": {
24
24
  "node": ">=22.13"