@stalfh233/omc-fake-platform 0.4.91 → 0.4.92
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/custom-page.d.ts +2 -0
- package/dist/custom-page.js +112 -0
- package/dist/routes.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { NOT_HANDLED, businessRefusal } from "./state.js";
|
|
2
|
+
function pages(ctx) {
|
|
3
|
+
const holder = ctx.state;
|
|
4
|
+
holder.customPages ??= new Map();
|
|
5
|
+
return holder.customPages;
|
|
6
|
+
}
|
|
7
|
+
export const customPageRoute = (ctx, input) => {
|
|
8
|
+
const store = pages(ctx);
|
|
9
|
+
const q = input.query ?? {};
|
|
10
|
+
const body = (input.body ?? {});
|
|
11
|
+
if (input.path === "/api/api/custom/create" && input.method === "POST") {
|
|
12
|
+
const code = String(body.code ?? "");
|
|
13
|
+
if (!code)
|
|
14
|
+
return businessRefusal(100002, "参数为空!");
|
|
15
|
+
if (String(body.menuPointType ?? "") === "")
|
|
16
|
+
return businessRefusal(50000, "服务异常");
|
|
17
|
+
if (store.has(code))
|
|
18
|
+
return businessRefusal(40000, "应用功能编码已存在");
|
|
19
|
+
store.set(code, {
|
|
20
|
+
code,
|
|
21
|
+
name: String(body.name ?? code),
|
|
22
|
+
appCode: String(body.appCode ?? "test"),
|
|
23
|
+
parentId: String(body.parentId ?? "folder-1"),
|
|
24
|
+
menuPointType: String(body.menuPointType),
|
|
25
|
+
pcAble: body.pcAble !== false,
|
|
26
|
+
mobileAble: body.mobileAble !== false,
|
|
27
|
+
openMode: String(body.openMode ?? "VUE_MODE"),
|
|
28
|
+
...(typeof body.icon === "string" ? { icon: body.icon } : {}),
|
|
29
|
+
draftContent: null,
|
|
30
|
+
publishedContent: null,
|
|
31
|
+
existDraft: false,
|
|
32
|
+
published: false,
|
|
33
|
+
});
|
|
34
|
+
return { id: `cf-${code}`, code, name: body.name ?? code, type: "Page" };
|
|
35
|
+
}
|
|
36
|
+
if (input.path === "/api/api/custom/update" && input.method === "POST") {
|
|
37
|
+
const code = String(body.code ?? "");
|
|
38
|
+
const page = store.get(code);
|
|
39
|
+
if (!page)
|
|
40
|
+
return businessRefusal(50000, "需要更新的数据不存在");
|
|
41
|
+
if (String(body.parentId ?? "") === "")
|
|
42
|
+
return businessRefusal(50000, "服务异常");
|
|
43
|
+
page.name = String(body.name ?? page.name);
|
|
44
|
+
page.parentId = String(body.parentId);
|
|
45
|
+
page.menuPointType = String(body.menuPointType ?? page.menuPointType);
|
|
46
|
+
if (body.pcAble !== undefined)
|
|
47
|
+
page.pcAble = body.pcAble !== false;
|
|
48
|
+
if (body.mobileAble !== undefined)
|
|
49
|
+
page.mobileAble = body.mobileAble !== false;
|
|
50
|
+
if (typeof body.openMode === "string")
|
|
51
|
+
page.openMode = body.openMode;
|
|
52
|
+
if (typeof body.icon === "string")
|
|
53
|
+
page.icon = body.icon;
|
|
54
|
+
return { id: `cf-${code}`, code, name: page.name, type: "Page" };
|
|
55
|
+
}
|
|
56
|
+
if (input.path === "/api/api/custom/get" && input.method === "GET") {
|
|
57
|
+
const page = store.get(String(q.code ?? ""));
|
|
58
|
+
if (!page)
|
|
59
|
+
return businessRefusal(302033, "自定义表单不存在!");
|
|
60
|
+
return {
|
|
61
|
+
code: page.code, name: page.name, appCode: page.appCode, parentId: page.parentId,
|
|
62
|
+
menuPointType: page.menuPointType, pcAble: page.pcAble, mobileAble: page.mobileAble,
|
|
63
|
+
openMode: page.openMode, ...(page.icon !== undefined ? { icon: page.icon } : {}),
|
|
64
|
+
existDraft: page.existDraft, published: page.published,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (input.path === "/api/api/custom/list" && input.method === "GET") {
|
|
68
|
+
// `/custom/list?modeType=` is the CustomPageModel face; the node-indexed
|
|
69
|
+
// list_by_appcode filters NodeType.CustomPage and misses nodes created by
|
|
70
|
+
// /custom/create (which forces NodeType.Page) — live 1.1.25.
|
|
71
|
+
return [...store.values()].map((page) => ({
|
|
72
|
+
code: page.code, name: page.name, appCode: page.appCode, parentId: page.parentId,
|
|
73
|
+
menuPointType: page.menuPointType, published: page.published, existDraft: page.existDraft,
|
|
74
|
+
draftContent: page.draftContent, publishedContent: page.publishedContent,
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
if (input.path === "/api/api/custom/page/content/get" && input.method === "GET") {
|
|
78
|
+
const page = store.get(String(q.code ?? ""));
|
|
79
|
+
if (!page)
|
|
80
|
+
return null;
|
|
81
|
+
return { code: page.code, draftContent: page.draftContent, publishedContent: page.publishedContent, existDraft: page.existDraft, published: page.published };
|
|
82
|
+
}
|
|
83
|
+
if (input.path === "/api/api/custom/page/content/update" && input.method === "POST") {
|
|
84
|
+
const code = String(body.code ?? "");
|
|
85
|
+
const page = store.get(code);
|
|
86
|
+
if (!page)
|
|
87
|
+
return businessRefusal(40000, "数据模型不存在!");
|
|
88
|
+
page.draftContent = typeof body.draftContent === "string" ? body.draftContent : null;
|
|
89
|
+
if (typeof body.publishedContent === "string")
|
|
90
|
+
page.publishedContent = body.publishedContent;
|
|
91
|
+
page.existDraft = true;
|
|
92
|
+
page.published = false;
|
|
93
|
+
return { code, draftContent: page.draftContent, publishedContent: page.publishedContent, existDraft: true, published: false };
|
|
94
|
+
}
|
|
95
|
+
if (input.path === "/api/api/custom/page/content/publish" && input.method === "POST") {
|
|
96
|
+
const code = String(body.code ?? "");
|
|
97
|
+
const page = store.get(code);
|
|
98
|
+
if (!page)
|
|
99
|
+
return businessRefusal(40000, "数据模型不存在!");
|
|
100
|
+
if (typeof body.draftContent === "string")
|
|
101
|
+
page.draftContent = body.draftContent;
|
|
102
|
+
page.publishedContent = typeof body.publishedContent === "string" ? body.publishedContent : page.draftContent;
|
|
103
|
+
page.existDraft = false;
|
|
104
|
+
page.published = true;
|
|
105
|
+
return { code, draftContent: page.draftContent, publishedContent: page.publishedContent, existDraft: false, published: true };
|
|
106
|
+
}
|
|
107
|
+
if (input.path === "/api/api/custom/delete" && input.method === "GET") {
|
|
108
|
+
store.delete(String(q.code ?? ""));
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
return NOT_HANDLED;
|
|
112
|
+
};
|
package/dist/routes.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { appRoute } from "./app.js";
|
|
2
|
+
import { customPageRoute } from "./custom-page.js";
|
|
2
3
|
import { b2Route } from "./b2-registration.js";
|
|
3
4
|
import { businessRuleRoute } from "./businessrule.js";
|
|
4
5
|
import { dataRuleRoute } from "./datarule.js";
|
|
@@ -34,6 +35,7 @@ const LANE_ROUTES = [
|
|
|
34
35
|
onlineJsRoute,
|
|
35
36
|
b2Route,
|
|
36
37
|
listViewRoute,
|
|
38
|
+
customPageRoute,
|
|
37
39
|
reportRoute,
|
|
38
40
|
];
|
|
39
41
|
export function dispatchFakeRoute(ctx, input) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-fake-platform",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.92",
|
|
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.4.
|
|
21
|
+
"omc-core": "0.4.92"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=22.13"
|