@stalfh233/omc-fake-platform 0.6.54 → 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 +0 -1
- package/dist/app.js +116 -2
- package/dist/state.d.ts +6 -0
- package/dist/state.js +1 -0
- package/package.json +2 -2
package/dist/app.d.ts
CHANGED
package/dist/app.js
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-fake-platform",
|
|
3
|
-
"version": "0.6.
|
|
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.
|
|
21
|
+
"omc-core": "0.6.55"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=22.13"
|