@macrowing/inbiz-codegen 0.0.0-stage → 1.0.0
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/README.md +592 -2
- package/bin/inbiz-codegen.mjs +7 -0
- package/package.json +32 -4
- package/scripts/prepare-templates.mjs +35 -0
- package/src/backend/init.mjs +170 -0
- package/src/config.mjs +150 -0
- package/src/favicon.mjs +100 -0
- package/src/generate.mjs +935 -0
- package/src/generated-output.mjs +107 -0
- package/src/index.mjs +346 -0
- package/src/menu/build.mjs +252 -0
- package/src/menu/check.mjs +163 -0
- package/src/menu/command.mjs +179 -0
- package/src/migrate-runtime.mjs +106 -0
- package/src/platform/client.mjs +167 -0
- package/src/platform/command.mjs +386 -0
- package/src/platform/pack.mjs +591 -0
- package/src/platform/recover.mjs +236 -0
- package/src/platform/startup.mjs +343 -0
- package/src/platform/state.mjs +116 -0
- package/src/platform/update.mjs +157 -0
- package/src/platform/zip.mjs +134 -0
- package/src/pull.mjs +284 -0
- package/src/scaffold/commands.mjs +349 -0
- package/src/scaffold/init.mjs +370 -0
- package/src/scaffold/template-files.mjs +40 -0
- package/src/scaffold/template-source.mjs +235 -0
- package/src/scaffold/template-sync.mjs +335 -0
- package/src/transform/heaviness.mjs +380 -0
- package/src/transform/preview-props.mjs +108 -0
- package/src/transform/published-page-links.mjs +61 -0
- package/src/transform/published-script.mjs +110 -0
- package/src/transform/registry.mjs +781 -0
- package/src/transform/schema-to-jsx.mjs +1708 -0
- package/src/util/des.mjs +10 -0
- package/templates/README.md +34 -0
- package/templates/backend/Directory.Build.props +19 -0
- package/templates/backend/Directory.Packages.props +49 -0
- package/templates/backend/Macrowing.Scaffold.slnx +13 -0
- package/templates/backend/host/Macrowing.Start/Init/app.json +8 -0
- package/templates/backend/host/Macrowing.Start/Init/menus.json +4 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationDefinition.cs +245 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationEndpoints.cs +57 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationHostedService.cs +63 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationOptions.cs +44 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationRunner.cs +294 -0
- package/templates/backend/host/Macrowing.Start/Initialization/InitializationState.cs +72 -0
- package/templates/backend/host/Macrowing.Start/Initialization/MenuFactory.cs +118 -0
- package/templates/backend/host/Macrowing.Start/Initialization/PackageBuilder.cs +317 -0
- package/templates/backend/host/Macrowing.Start/Initialization/PlatformAppImporter.cs +371 -0
- package/templates/backend/host/Macrowing.Start/Macrowing.Start.csproj +26 -0
- package/templates/backend/host/Macrowing.Start/Program.cs +33 -0
- package/templates/backend/host/Macrowing.Start/StartModule.cs +67 -0
- package/templates/backend/host/Macrowing.Start/appsettings.json +38 -0
- package/templates/backend/modules/Macrowing.Generated/Application/GeneratedApplicationAutoMapperProfile.cs +42 -0
- package/templates/backend/modules/Macrowing.Generated/Domain/Entities/GeneratedEntityBase.cs +72 -0
- package/templates/backend/modules/Macrowing.Generated/Domain/GeneratedConsts.cs +50 -0
- package/templates/backend/modules/Macrowing.Generated/EntityFrameworkCore/GeneratedDbContext.cs +55 -0
- package/templates/backend/modules/Macrowing.Generated/EntityFrameworkCore/GeneratedDbContextModelBuilderExtensions.cs +61 -0
- package/templates/backend/modules/Macrowing.Generated/EntityFrameworkCore/IGeneratedDbContext.cs +32 -0
- package/templates/backend/modules/Macrowing.Generated/GeneratedModule.cs +89 -0
- package/templates/backend/modules/Macrowing.Generated/Macrowing.Generated.csproj +22 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Cms/CmsClient.cs +95 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Cms/CmsModels.cs +81 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Dictionary/DictionaryClient.cs +44 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/InBizSdkModule.cs +16 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/InterfaceEngine/InterfaceEngineClient.cs +50 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Localization/LocalizationClient.cs +28 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Macrowing.InBiz.SDK.csproj +16 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Message/MessageClient.cs +99 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Message/MessageModels.cs +63 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Model/ModelClient.cs +131 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Model/ModelQuery.cs +108 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Model/ModelWrite.cs +44 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Permission/PermissionClient.cs +86 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Platform/InBizPlatformException.cs +42 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Platform/InBizPlatformRegistration.cs +60 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Platform/InBizPlatformTransport.cs +96 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/Platform/InBizRequestContext.cs +27 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/README.md +117 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Details/WorkFlowDetailsClient.cs +35 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Details/WorkFlowDetailsQuery.cs +20 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Operations/WorkFlowOperationRequests.cs +105 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Operations/WorkFlowOperationsClient.cs +53 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/README.md +132 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Tracking/WorkFlowTrackingClient.cs +50 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Upgrade/WorkFlowUpgradeClient.cs +78 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Upgrade/WorkFlowUpgradeModels.cs +34 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/WorkFlowContracts.cs +88 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/WorkFlowRegistration.cs +59 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/WorkFlowTransport.cs +163 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Workbench/WorkFlowWorkbenchClient.cs +59 -0
- package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Workbench/WorkFlowWorkbenchModels.cs +76 -0
- package/templates/backend/modules/Macrowing.OC.SDK/Macrowing.OC.SDK.csproj +20 -0
- package/templates/backend/modules/Macrowing.OC.SDK/OcSdkModule.cs +18 -0
- package/templates/backend/modules/Macrowing.OC.SDK/Protos/README.md +22 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/Macrowing.InBiz.SDK.Tests.csproj +14 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/PlatformContractTests.cs +288 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/PlatformLiveTests.cs +173 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowHttpServer.cs +113 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowLiveTests.cs +269 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowOperationsTests.cs +80 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowQueryTests.cs +163 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowTransportTests.cs +111 -0
- package/templates/backend/tests/Macrowing.InBiz.SDK.Tests/WorkFlowUpgradeTests.cs +87 -0
- package/templates/frontend/components/README.md +39 -0
- package/templates/frontend/components/app-components/README.md +33 -0
- package/templates/frontend/components/app-components/common/.gitkeep +0 -0
- package/templates/frontend/components/app-components/components/.gitkeep +0 -0
- package/templates/frontend/components/app-components/package.json +20 -0
- package/templates/frontend/mgt/.umirc.ts +574 -0
- package/templates/frontend/mgt/package.json +96 -0
- package/templates/frontend/mgt/src/app-extends.ts +9 -0
- package/templates/frontend/mgt/src/app.tsx +20 -0
- package/templates/frontend/mgt/src/config/app.ts +31 -0
- package/templates/frontend/mgt/src/layout/header.tsx +14 -0
- package/templates/frontend/mgt/src/layout/index.tsx +11 -0
- package/templates/frontend/mgt/src/layout/sidebar.tsx +14 -0
- package/templates/frontend/mgt/src/locales.ts +8 -0
- package/templates/frontend/mgt/src/pages/.gitkeep +0 -0
- package/templates/frontend/mgt/src/root.tsx +12 -0
- package/templates/frontend/mgt/src/route-view.tsx +3 -0
- package/templates/frontend/mgt/src/runtime.ts +21 -0
- package/templates/frontend/mgt/src/styles/app.css +1 -0
- package/templates/frontend/mgt/src/styles/layout.less +79 -0
- package/templates/frontend/mgt/tsconfig.json +65 -0
- package/templates/frontend/mgt/typings.d.ts +57 -0
- package/templates/frontend/wap/.umirc.ts +574 -0
- package/templates/frontend/wap/package.json +73 -0
- package/templates/frontend/wap/src/app-extends.ts +9 -0
- package/templates/frontend/wap/src/app.tsx +28 -0
- package/templates/frontend/wap/src/config/app.ts +31 -0
- package/templates/frontend/wap/src/layout/header.tsx +14 -0
- package/templates/frontend/wap/src/layout/index.tsx +18 -0
- package/templates/frontend/wap/src/layout/sidebar.tsx +14 -0
- package/templates/frontend/wap/src/locales.ts +8 -0
- package/templates/frontend/wap/src/pages/.gitkeep +0 -0
- package/templates/frontend/wap/src/root.tsx +12 -0
- package/templates/frontend/wap/src/route-view.tsx +3 -0
- package/templates/frontend/wap/src/runtime.ts +21 -0
- package/templates/frontend/wap/src/styles/adaptation.less +190 -0
- package/templates/frontend/wap/src/styles/app.css +7 -0
- package/templates/frontend/wap/src/styles/global.less +81 -0
- package/templates/frontend/wap/src/styles/layout.less +92 -0
- package/templates/frontend/wap/tsconfig.json +66 -0
- package/templates/frontend/wap/typings.d.ts +24 -0
- package/templates/frontend/web/.umirc.ts +574 -0
- package/templates/frontend/web/package.json +26 -0
- package/templates/frontend/web/src/app-extends.ts +9 -0
- package/templates/frontend/web/src/app.tsx +25 -0
- package/templates/frontend/web/src/config/app.ts +31 -0
- package/templates/frontend/web/src/layout/header.tsx +14 -0
- package/templates/frontend/web/src/layout/index.tsx +11 -0
- package/templates/frontend/web/src/layout/sidebar.tsx +14 -0
- package/templates/frontend/web/src/locales.ts +8 -0
- package/templates/frontend/web/src/root.tsx +12 -0
- package/templates/frontend/web/src/route-view.tsx +3 -0
- package/templates/frontend/web/src/runtime.ts +21 -0
- package/templates/frontend/web/src/styles/app.css +104 -0
- package/templates/frontend/web/src/styles/layout.less +124 -0
- package/templates/frontend/web/tsconfig.json +91 -0
- package/templates/frontend/web/typings.d.ts +46 -0
- package/templates/package.json +14 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
using System.Text.Json;
|
|
2
|
+
using Macrowing.InBiz.SDK.WorkFlow;
|
|
3
|
+
using static Macrowing.InBiz.SDK.Tests.WorkFlowHttpServer;
|
|
4
|
+
|
|
5
|
+
namespace Macrowing.InBiz.SDK.Tests;
|
|
6
|
+
|
|
7
|
+
public sealed class WorkFlowQueryTests
|
|
8
|
+
{
|
|
9
|
+
private const string Page = """{"code":"200","details":{"total":3600000000,"currPage":2,"pageSize":20,"rows":[{"id":"p1"}]}}""";
|
|
10
|
+
|
|
11
|
+
[Fact]
|
|
12
|
+
public async Task StartableProcessesUsesFlatSpringQueryAndParsesPage()
|
|
13
|
+
{
|
|
14
|
+
await using var server = await StartAsync(new Response(Page));
|
|
15
|
+
var result = await server.Client<IWorkFlowWorkbenchClient>().GetStartableProcessesAsync(Credential, new("user")
|
|
16
|
+
{
|
|
17
|
+
PageIndex = 2, PageSize = 20, QueryParameter = "\u5ba1\u6279+C&D", OrderName = "name", OrderType = "asc",
|
|
18
|
+
DptKey = "dept", ProcessName = "p", ProcessGroupName = "group", ProcessKey = "p1", ProcessGroupId = "g1",
|
|
19
|
+
WebSiteId = "s1", IncludeOtherSites = false
|
|
20
|
+
});
|
|
21
|
+
AssertPage(result);
|
|
22
|
+
AssertRequest(Assert.Single(server.Requests), "GET", "process/getResults/getMyApply",
|
|
23
|
+
[("userId", "user"), ("pageIndex", "2"), ("pageSize", "20"), ("queryParameter", "\u5ba1\u6279+C&D"),
|
|
24
|
+
("orderName", "name"), ("orderType", "asc"), ("dptKey", "dept"), ("processName", "p"), ("processGroupName", "group"),
|
|
25
|
+
("processKey", "p1"), ("processGroupId", "g1"), ("webSiteId", "s1"), ("isotherSites", "false")]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
[Fact]
|
|
29
|
+
public async Task EmptyInboxWithoutDetailsIsSuccessful()
|
|
30
|
+
{
|
|
31
|
+
await using var server = await StartAsync(new Response("""{"code":"200","message":"\u67e5\u8be2\u7ed3\u679c\u4e3a\u7a7a"}"""));
|
|
32
|
+
var result = await server.Client<IWorkFlowWorkbenchClient>().GetMyPendingTasksAsync(Credential,
|
|
33
|
+
new("user") { ProcessInstanceId = "terminated-instance" });
|
|
34
|
+
Assert.Equal("200", result.Code);
|
|
35
|
+
Assert.Null(result.Details);
|
|
36
|
+
AssertRequest(Assert.Single(server.Requests), "GET", "process/getResults/getMyInbox",
|
|
37
|
+
[("userId", "user"), ("processInstanceId", "terminated-instance")]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[Theory]
|
|
41
|
+
[InlineData("getMyInbox")]
|
|
42
|
+
[InlineData("getMyComplete")]
|
|
43
|
+
[InlineData("getMyArchive")]
|
|
44
|
+
[InlineData("getMyCctome")]
|
|
45
|
+
[InlineData("getMyInitiatorv6")]
|
|
46
|
+
public async Task WorkbenchListsUseCorrectRouteAndFlatFilters(string action)
|
|
47
|
+
{
|
|
48
|
+
await using var server = await StartAsync(new Response(Page));
|
|
49
|
+
var client = server.Client<IWorkFlowWorkbenchClient>();
|
|
50
|
+
var query = new WorkFlowListQuery("user")
|
|
51
|
+
{
|
|
52
|
+
PageIndex = 2, PageSize = 20, ProcessInstanceId = "i1", QueryParameter = "a&b", Sort = "date", Order = "desc",
|
|
53
|
+
DptKey = "dept", Classification = "class", ProcessName = "p", ProcessGroupName = "group", StarterId = "u1",
|
|
54
|
+
Status = "1", Date = "2026-11-25", ProcessDefinitionId = "p:1", WebSiteId = "s1"
|
|
55
|
+
};
|
|
56
|
+
var result = await (action switch
|
|
57
|
+
{
|
|
58
|
+
"getMyInbox" => client.GetMyPendingTasksAsync(Credential, query),
|
|
59
|
+
"getMyComplete" => client.GetMyCompletedTasksAsync(Credential, query),
|
|
60
|
+
"getMyArchive" => client.GetMyArchivedProcessesAsync(Credential, query),
|
|
61
|
+
"getMyCctome" => client.GetMyCopiedProcessesAsync(Credential, query),
|
|
62
|
+
"getMyInitiatorv6" => client.GetMyInitiatedProcessesAsync(Credential, query, underApplication: false),
|
|
63
|
+
_ => throw new ArgumentOutOfRangeException(nameof(action))
|
|
64
|
+
});
|
|
65
|
+
AssertPage(result);
|
|
66
|
+
(string, string)[] filters =
|
|
67
|
+
[("userId", "user"), ("pageIndex", "2"), ("pageSize", "20"), ("processInstanceId", "i1"), ("queryParameter", "a&b"),
|
|
68
|
+
("sort", "date"), ("order", "desc"), ("dptKey", "dept"), ("classification", "class"), ("processName", "p"),
|
|
69
|
+
("processGroupName", "group"), ("starterId", "u1"), ("status", "1"), ("date", "2026-11-25"),
|
|
70
|
+
("processDefinitionId", "p:1"), ("webSiteId", "s1")];
|
|
71
|
+
AssertRequest(Assert.Single(server.Requests), "GET", "process/getResults/" + action,
|
|
72
|
+
action == "getMyInitiatorv6" ? [.. filters, ("isunderApplication", "false")] : filters);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
[Theory]
|
|
76
|
+
[InlineData(false, "getProcessDetails")]
|
|
77
|
+
[InlineData(true, "getInitProcessDetails")]
|
|
78
|
+
public async Task DetailsUsesCorrectActionAndInitiationFlag(bool initiating, string action)
|
|
79
|
+
{
|
|
80
|
+
await using var server = await StartAsync(new Response("""{"code":"200","details":[{"taskId":"t1"}]}"""));
|
|
81
|
+
var client = server.Client<IWorkFlowDetailsClient>();
|
|
82
|
+
var query = new WorkFlowDetailsQuery
|
|
83
|
+
{
|
|
84
|
+
TaskIds = initiating ? null : "t1,t2", ProcessInstanceId = initiating ? null : "i1",
|
|
85
|
+
ProcessDefinitionId = "p:1", SiteType = 2, GroupId = "g1", ProcessMark = "m1"
|
|
86
|
+
};
|
|
87
|
+
var result = initiating ? await client.GetStartProcessDetailsAsync(Credential, query) : await client.GetProcessDetailsAsync(Credential, query);
|
|
88
|
+
Assert.Equal("t1", result.Details!.Value[0].GetProperty("taskId").GetString());
|
|
89
|
+
(string, string)[] filters =
|
|
90
|
+
[("processDefinitionId", "p:1"), ("siteType", "2"), ("groupId", "g1"), ("processMark", "m1"),
|
|
91
|
+
("inItiateApplication", initiating ? "true" : "false")];
|
|
92
|
+
AssertRequest(Assert.Single(server.Requests), "GET", "process/getResults/" + action,
|
|
93
|
+
initiating ? filters : [.. filters, ("taskIds", "t1,t2"), ("processInstanceId", "i1")]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
[Fact]
|
|
97
|
+
public async Task ReadsNewProcessAttributeFlag()
|
|
98
|
+
{
|
|
99
|
+
await using var server = await StartAsync(new Response("""{"code":"200","details":false}"""));
|
|
100
|
+
Assert.False((await server.Client<IWorkFlowDetailsClient>().UsesNewProcessAttributesAsync(Credential, "i1")).Details);
|
|
101
|
+
AssertRequest(Assert.Single(server.Requests), "GET", "process/getResults/getProcessType", [("processInstanceId", "i1")]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
[Fact]
|
|
105
|
+
public async Task ReadsProcessLogForOneInstance()
|
|
106
|
+
{
|
|
107
|
+
await using var server = await StartAsync(new Response(Page));
|
|
108
|
+
var log = await server.Client<IWorkFlowTrackingClient>().GetProcessLogAsync(Credential, "i1");
|
|
109
|
+
Assert.Equal("p1", log.Details!.Value.GetProperty("rows")[0].GetProperty("id").GetString());
|
|
110
|
+
AssertRequest(Assert.Single(server.Requests), "GET", "process/getResults/getProcessLog", [("processInstanceId", "i1")]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
[Fact]
|
|
114
|
+
public async Task RejectsCommaDelimitedProcessLogIdsBeforeSending()
|
|
115
|
+
{
|
|
116
|
+
await using var server = await StartAsync(new Response(Page));
|
|
117
|
+
var client = server.Client<IWorkFlowTrackingClient>();
|
|
118
|
+
await Assert.ThrowsAsync<ArgumentException>("processInstanceId",
|
|
119
|
+
() => client.GetProcessLogAsync(Credential, "i1,i2"));
|
|
120
|
+
Assert.Empty(server.Requests);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
[Theory]
|
|
124
|
+
[InlineData("getProcessLogChart", "process/logs/p:1?id/getProcessLogChart")]
|
|
125
|
+
[InlineData("getHighlighted", "process/logs/process-instance/p:1?id/getHighlighted")]
|
|
126
|
+
[InlineData("getActivityInfos", "process/logs/process-instance/p:1?id/getActivityInfos")]
|
|
127
|
+
public async Task BareChartObjectAndPathSegmentEncoding(string action, string route)
|
|
128
|
+
{
|
|
129
|
+
await using var server = await StartAsync(new Response("""{"activities":[]}"""));
|
|
130
|
+
var client = server.Client<IWorkFlowTrackingClient>();
|
|
131
|
+
var result = await (action switch
|
|
132
|
+
{
|
|
133
|
+
"getProcessLogChart" => client.GetProcessLogChartAsync(Credential, "p:1?id"),
|
|
134
|
+
"getHighlighted" => client.GetHighlightedNodesAsync(Credential, "p:1?id"),
|
|
135
|
+
"getActivityInfos" => client.GetActivityInfosAsync(Credential, "p:1?id"),
|
|
136
|
+
_ => throw new ArgumentOutOfRangeException(nameof(action))
|
|
137
|
+
});
|
|
138
|
+
Assert.Equal(JsonValueKind.Array, result.GetProperty("activities").ValueKind);
|
|
139
|
+
var request = Assert.Single(server.Requests);
|
|
140
|
+
AssertRequest(request, "GET", route);
|
|
141
|
+
Assert.Contains("/p%3A1%3Fid/", request.RawTarget);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
[Fact]
|
|
145
|
+
public async Task FlowChartUsesResultEnvelopeAndOmitsNullParameters()
|
|
146
|
+
{
|
|
147
|
+
await using var server = await StartAsync(new Response("""{"code":"200","details":{"activities":[]}}"""));
|
|
148
|
+
var result = await server.Client<IWorkFlowTrackingClient>().GetFlowChartAsync(Credential, null, "i1", customType: 0);
|
|
149
|
+
Assert.Equal(JsonValueKind.Array, result.Details!.Value.GetProperty("activities").ValueKind);
|
|
150
|
+
AssertRequest(Assert.Single(server.Requests), "GET", "process/logs/process-instance/getFlowChart",
|
|
151
|
+
[("processInstanceId", "i1"), ("customType", "0")]);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private static void AssertPage(WorkFlowResult<WorkFlowPage> result)
|
|
155
|
+
{
|
|
156
|
+
Assert.Equal("200", result.Code);
|
|
157
|
+
var page = Assert.IsType<WorkFlowPage>(result.Details);
|
|
158
|
+
Assert.Equal(3600000000L, page.Total);
|
|
159
|
+
Assert.Equal(2, page.CurrPage);
|
|
160
|
+
Assert.Equal(20, page.PageSize);
|
|
161
|
+
Assert.Equal("p1", Assert.Single(page.Rows!).GetProperty("id").GetString());
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
using System.Net;
|
|
2
|
+
using Macrowing.InBiz.SDK.WorkFlow;
|
|
3
|
+
using static Macrowing.InBiz.SDK.Tests.WorkFlowHttpServer;
|
|
4
|
+
|
|
5
|
+
namespace Macrowing.InBiz.SDK.Tests;
|
|
6
|
+
|
|
7
|
+
public sealed class WorkFlowTransportTests
|
|
8
|
+
{
|
|
9
|
+
[Theory]
|
|
10
|
+
[InlineData(403)]
|
|
11
|
+
[InlineData(200)]
|
|
12
|
+
public async Task EngineExpiryJsonIsRecognizedEvenWhenLabeledHtml(int status)
|
|
13
|
+
{
|
|
14
|
+
await using var server = await StartAsync(new Response("""{"errorCode":"ErrorCode4","message":"expired"}""", status, "text/html;charset=UTF-8"));
|
|
15
|
+
var error = await Assert.ThrowsAsync<WorkFlowSessionException>(() => ReadDraftFlag(server));
|
|
16
|
+
Assert.Equal((HttpStatusCode)status, error.StatusCode);
|
|
17
|
+
Assert.Equal("ErrorCode4", error.ErrorCode);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[Theory]
|
|
21
|
+
[InlineData("""{"errorCode":"OtherError"}""")]
|
|
22
|
+
[InlineData("<html>Access denied</html>")]
|
|
23
|
+
public async Task HttpForbiddenIsNotAutomaticallyAnExpiredSession(string body)
|
|
24
|
+
{
|
|
25
|
+
await using var server = await StartAsync(new Response(body, 403));
|
|
26
|
+
var error = await Assert.ThrowsAsync<WorkFlowHttpException>(() => ReadDraftFlag(server));
|
|
27
|
+
Assert.Equal(HttpStatusCode.Forbidden, error.StatusCode);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
[Fact]
|
|
31
|
+
public async Task BareEndpointCanReturnBusinessErrorEnvelope()
|
|
32
|
+
{
|
|
33
|
+
await using var server = await StartAsync(new Response("""
|
|
34
|
+
{"code":"403","message":"denied","details":{"hint":"access required"},"innerException":"engine reason","errorCode":"Denied"}
|
|
35
|
+
"""));
|
|
36
|
+
var error = await Assert.ThrowsAsync<WorkFlowBusinessException>(() => ReadDraftFlag(server));
|
|
37
|
+
Assert.Equal("403", error.Code);
|
|
38
|
+
Assert.Equal("denied", error.EngineMessage);
|
|
39
|
+
Assert.Equal("access required", error.Details!.Value.GetProperty("hint").GetString());
|
|
40
|
+
Assert.Equal("engine reason", error.EngineInnerException);
|
|
41
|
+
Assert.Equal("Denied", error.ErrorCode);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[Theory]
|
|
45
|
+
[InlineData("<html>Login</html>")]
|
|
46
|
+
[InlineData("{")]
|
|
47
|
+
[InlineData("[]")]
|
|
48
|
+
[InlineData("""{"code":200}""")]
|
|
49
|
+
[InlineData("""{"code":"200","details":[]}""")]
|
|
50
|
+
public async Task HtmlMissingEnvelopeOrInvalidPageIsProtocolError(string body)
|
|
51
|
+
{
|
|
52
|
+
await using var server = await StartAsync(new Response(body));
|
|
53
|
+
var client = server.Client<IWorkFlowWorkbenchClient>();
|
|
54
|
+
await Assert.ThrowsAsync<WorkFlowProtocolException>(() => client.GetMyPendingTasksAsync(Credential, new("user")));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[Fact]
|
|
58
|
+
public async Task RedirectCannotReplayOperationOrForwardCredentials()
|
|
59
|
+
{
|
|
60
|
+
await using var server = await StartAsync(new Response("", 307, Location: "/edoc2Flow-web/other"), new Response("""{"code":"200"}"""));
|
|
61
|
+
var error = await Assert.ThrowsAsync<WorkFlowHttpException>(
|
|
62
|
+
() => server.Client<IWorkFlowUpgradeClient>().UpgradeXmlAsync(Credential));
|
|
63
|
+
Assert.Equal(HttpStatusCode.TemporaryRedirect, error.StatusCode);
|
|
64
|
+
AssertRequest(Assert.Single(server.Requests), "POST", "process/upgrade/processUpgradexml");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[Fact]
|
|
68
|
+
public async Task UpstreamFailureDoesNotRetryWriteOperation()
|
|
69
|
+
{
|
|
70
|
+
await using var server = await StartAsync(new Response("Unavailable", 503), new Response("""{"code":"200"}"""));
|
|
71
|
+
var error = await Assert.ThrowsAsync<WorkFlowHttpException>(
|
|
72
|
+
() => server.Client<IWorkFlowOperationsClient>().CompleteTaskAsync(Credential, new("task-1")));
|
|
73
|
+
Assert.Equal(HttpStatusCode.ServiceUnavailable, error.StatusCode);
|
|
74
|
+
AssertRequest(Assert.Single(server.Requests), "POST", "process/operation/processCompletion",
|
|
75
|
+
json: """{"taskId":"task-1","isrefuse":false}""");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[Fact]
|
|
79
|
+
public async Task UpstreamCookiesAreNotReusedAcrossCredentials()
|
|
80
|
+
{
|
|
81
|
+
await using var server = await StartAsync(new Response("true", SetCookie: "JSESSIONID=first; Path=/"), new Response("false"));
|
|
82
|
+
Assert.True(await ReadDraftFlag(server));
|
|
83
|
+
Assert.False(await server.Client<IWorkFlowOperationsClient>().CanSaveDraftAsync(WorkFlowCredential.Jwt(Jwt), "draft"));
|
|
84
|
+
Assert.Equal(2, server.Requests.Length);
|
|
85
|
+
Assert.All(server.Requests, request => Assert.Empty(request.Cookie));
|
|
86
|
+
AssertRequest(server.Requests[1], "GET", "process/operation/getIsDrafts", [("processId", "draft")], withJwt: true);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
[Fact]
|
|
90
|
+
public async Task CancellationAbortsInFlightHttpRequest()
|
|
91
|
+
{
|
|
92
|
+
var received = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
|
93
|
+
var disconnected = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
|
94
|
+
await using var server = await StartAsync(async context =>
|
|
95
|
+
{
|
|
96
|
+
received.TrySetResult();
|
|
97
|
+
using var registration = context.RequestAborted.Register(() => disconnected.TrySetResult());
|
|
98
|
+
await disconnected.Task.WaitAsync(TimeSpan.FromSeconds(5));
|
|
99
|
+
});
|
|
100
|
+
using var cancellation = new CancellationTokenSource();
|
|
101
|
+
var request = server.Client<IWorkFlowOperationsClient>().CanSaveDraftAsync(Credential, "draft", cancellation.Token);
|
|
102
|
+
await received.Task.WaitAsync(TimeSpan.FromSeconds(5));
|
|
103
|
+
await cancellation.CancelAsync();
|
|
104
|
+
await Assert.ThrowsAnyAsync<OperationCanceledException>(() => request);
|
|
105
|
+
await disconnected.Task.WaitAsync(TimeSpan.FromSeconds(5));
|
|
106
|
+
Assert.Single(server.Requests);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private static Task<bool> ReadDraftFlag(WorkFlowHttpServer server) =>
|
|
110
|
+
server.Client<IWorkFlowOperationsClient>().CanSaveDraftAsync(Credential, "draft");
|
|
111
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
using Macrowing.InBiz.SDK.WorkFlow;
|
|
2
|
+
using static Macrowing.InBiz.SDK.Tests.WorkFlowHttpServer;
|
|
3
|
+
|
|
4
|
+
namespace Macrowing.InBiz.SDK.Tests;
|
|
5
|
+
|
|
6
|
+
public sealed class WorkFlowUpgradeTests
|
|
7
|
+
{
|
|
8
|
+
[Theory]
|
|
9
|
+
[InlineData(WorkFlowUpgradeCheck.LegacyDesign, "0", """{"code":"200","message":"no upgrade required"}""", null)]
|
|
10
|
+
[InlineData(WorkFlowUpgradeCheck.DesignerXml, "1", """{"code":"200","message":"upgrade required","details":true}""", true)]
|
|
11
|
+
public async Task ChecksRightUpgradeType(WorkFlowUpgradeCheck check, string wireType, string response, bool? expected)
|
|
12
|
+
{
|
|
13
|
+
await using var server = await StartAsync(new Response(response));
|
|
14
|
+
var result = await server.Client<IWorkFlowUpgradeClient>().CheckUpgradeAsync(Credential, check);
|
|
15
|
+
Assert.Equal(expected, result.Details);
|
|
16
|
+
AssertRequest(Assert.Single(server.Requests), "GET", "process/upgrade/upgradeTesting", [("type", wireType)]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[Theory]
|
|
20
|
+
[InlineData("processUpgrade", "403", "processUpgrade")]
|
|
21
|
+
[InlineData("processUpgradexml", "403", "processUpgrade")]
|
|
22
|
+
[InlineData("upgradeRelease", "200", "upgradeRelease")]
|
|
23
|
+
public async Task SubmitsBodylessJobAndInterpretsLegacyResponse(string action, string code, string key)
|
|
24
|
+
{
|
|
25
|
+
await using var server = await StartAsync(new Response($$"""{"code":"{{code}}","details":"{{key}}"}"""));
|
|
26
|
+
var client = server.Client<IWorkFlowUpgradeClient>();
|
|
27
|
+
var result = await (action switch
|
|
28
|
+
{
|
|
29
|
+
"processUpgrade" => client.UpgradeDesignAsync(Credential),
|
|
30
|
+
"processUpgradexml" => client.UpgradeXmlAsync(Credential),
|
|
31
|
+
"upgradeRelease" => client.ReleaseUpgradedDesignsAsync(Credential),
|
|
32
|
+
_ => throw new ArgumentOutOfRangeException(nameof(action))
|
|
33
|
+
});
|
|
34
|
+
Assert.Equal(new(key, code, null), result);
|
|
35
|
+
AssertRequest(Assert.Single(server.Requests), "POST", "process/upgrade/" + action);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[Fact]
|
|
39
|
+
public async Task ReadsDocumentControlMigrationReport()
|
|
40
|
+
{
|
|
41
|
+
await using var server = await StartAsync(new Response("""{"code":"200","details":"migration report"}"""));
|
|
42
|
+
var result = await server.Client<IWorkFlowUpgradeClient>().UpgradeDocumentControlAsync(Credential);
|
|
43
|
+
Assert.Equal("migration report", result.Details);
|
|
44
|
+
AssertRequest(Assert.Single(server.Requests), "POST", "process/upgrade/docConProcessUpgrade");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[Fact]
|
|
48
|
+
public async Task ProgressSeparatesAbsentRunningAndConsumedFinalReport()
|
|
49
|
+
{
|
|
50
|
+
await using var server = await StartAsync(
|
|
51
|
+
new Response("""{"code":"200","message":"no result"}"""),
|
|
52
|
+
new Response("""{"code":"201","details":"working"}"""),
|
|
53
|
+
new Response("""{"code":"202","details":"processed: 5, failed: 1"}"""),
|
|
54
|
+
new Response("""{"code":"200","message":"no result"}"""));
|
|
55
|
+
var client = server.Client<IWorkFlowUpgradeClient>();
|
|
56
|
+
var expected = new WorkFlowUpgradeProgress[]
|
|
57
|
+
{
|
|
58
|
+
new(WorkFlowUpgradeState.NoResult, "200", null, "no result"),
|
|
59
|
+
new(WorkFlowUpgradeState.InProgress, "201", "working", null),
|
|
60
|
+
new(WorkFlowUpgradeState.Finished, "202", "processed: 5, failed: 1", null),
|
|
61
|
+
new(WorkFlowUpgradeState.NoResult, "200", null, "no result")
|
|
62
|
+
};
|
|
63
|
+
foreach (var progress in expected)
|
|
64
|
+
Assert.Equal(progress, await client.GetUpgradeResultAsync(Credential, "processUpgrade"));
|
|
65
|
+
|
|
66
|
+
Assert.Equal(expected.Length, server.Requests.Length);
|
|
67
|
+
Assert.All(server.Requests, request => AssertRequest(request, "GET", "process/upgrade/getUpgadeResult", [("key", "processUpgrade")]));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[Theory]
|
|
71
|
+
[InlineData("""{"code":"403","message":"permission denied","details":"not a job"}""")]
|
|
72
|
+
[InlineData("""{"code":"403","details":"processUpgrade","errorCode":"denied"}""")]
|
|
73
|
+
public async Task NormalUpgradeRejectionIsNotAJob(string response)
|
|
74
|
+
{
|
|
75
|
+
await using var server = await StartAsync(new Response(response));
|
|
76
|
+
var error = await Assert.ThrowsAsync<WorkFlowBusinessException>(() => server.Client<IWorkFlowUpgradeClient>().UpgradeXmlAsync(Credential));
|
|
77
|
+
Assert.Equal("403", error.Code);
|
|
78
|
+
Assert.Single(server.Requests);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
[Fact]
|
|
82
|
+
public async Task UpgradeSuccessCodeWithoutJobKeyIsProtocolError()
|
|
83
|
+
{
|
|
84
|
+
await using var server = await StartAsync(new Response("""{"code":"200"}"""));
|
|
85
|
+
await Assert.ThrowsAsync<WorkFlowProtocolException>(() => server.Client<IWorkFlowUpgradeClient>().ReleaseUpgradedDesignsAsync(Credential));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# 应用定制组件包
|
|
2
|
+
|
|
3
|
+
本目录存放**应用独有**的组件包。一个组件包一个子目录,目录名与包名对应:
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
components/
|
|
7
|
+
├─ README.md # 本文件:只写约定,不放代码
|
|
8
|
+
├─ app-components/ # 一个组件包 = 一个子目录
|
|
9
|
+
│ ├─ package.json # 包清单(name / exports / files)
|
|
10
|
+
│ ├─ components/ # 组件实现
|
|
11
|
+
│ │ └─ <分组>/<组件名>/preview/{web,wap,locale}
|
|
12
|
+
│ ├─ common/ # 组件共用 hooks / 工具
|
|
13
|
+
│ ├─ locales.ts # 组件文案汇总
|
|
14
|
+
│ └─ global.ts # 包公共入口
|
|
15
|
+
└─ <另一个包>/ # 需要拆分时,再建一个子目录
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 约定
|
|
19
|
+
|
|
20
|
+
1. **根目录只放文档**。不要在这里直接生成 `package.json`、`components/` 之类
|
|
21
|
+
具体组件包的内容 —— 那会让「哪个文件属于哪个包」失去边界。
|
|
22
|
+
2. **目录名与包名对应**。子目录 `app-components/` 对应 `@macrowing/app-components`;
|
|
23
|
+
包名改了,目录名跟着改。
|
|
24
|
+
3. **包是自包含的**。每个子目录有自己的 `package.json`、依赖声明和入口;
|
|
25
|
+
包与包之间不通过相对路径互相 import。
|
|
26
|
+
4. **不复制平台组件**。平台通用能力按版本依赖 `@macrowing/inbiz-components`,
|
|
27
|
+
只有「这个应用才有」的组件才放这里。
|
|
28
|
+
5. **产物不入库**。`node_modules/`、`dist/` 由构建生成,不提交。
|
|
29
|
+
|
|
30
|
+
## 三端如何引用
|
|
31
|
+
|
|
32
|
+
三端工程的 `tsconfig.json` 都把 `@custom/*` 指到本目录:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
// web / mgt / wap 里的写法
|
|
36
|
+
import MyWidget from '@custom/app-components/components/basic/MyWidget/preview/web';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
新增组件包后,只需保证包目录名稳定;三端不需要改任何配置。
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @macrowing/app-components
|
|
2
|
+
|
|
3
|
+
本应用独有的组件包,不对外发布。目录名 `app-components` 与包名对应。
|
|
4
|
+
|
|
5
|
+
## 目录约定
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
components/
|
|
9
|
+
<分组>/<组件名>/preview/
|
|
10
|
+
web/index.tsx # 桌面端实现
|
|
11
|
+
wap/index.tsx # 移动端实现(仅当三端都要用)
|
|
12
|
+
locale.ts # 组件文案
|
|
13
|
+
basic/ # 基础组件
|
|
14
|
+
business/ # 业务组件
|
|
15
|
+
common/ # 组件共用的 hooks / 工具
|
|
16
|
+
locales.ts # 组件文案汇总
|
|
17
|
+
global.ts # 组件公共入口
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 与平台组件库的边界
|
|
21
|
+
|
|
22
|
+
- 平台通用能力用 `@macrowing/inbiz-components`,按 npmjs 版本依赖,**不要复制进来**;
|
|
23
|
+
- 只有「这个应用才有」的组件才放这里;
|
|
24
|
+
- 组件包自己的构建产物(`dist/`、`node_modules/`)不入库。
|
|
25
|
+
|
|
26
|
+
## 在出码工程里引用
|
|
27
|
+
|
|
28
|
+
三端工程的 `tsconfig.json` 把 `@custom/*` 指到 `frontend/components/`,
|
|
29
|
+
页面与布局按 `@custom/app-components/<相对路径>` 引用。例如:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import MyWidget from '@custom/app-components/components/basic/MyWidget/preview/web';
|
|
33
|
+
```
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@macrowing/app-components",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "应用定制组件(本应用独有,不对外发布)",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./components/*": "./components/*",
|
|
9
|
+
"./common/*": "./common/*",
|
|
10
|
+
"./locales": "./locales.ts",
|
|
11
|
+
"./global": "./global.ts"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"components",
|
|
15
|
+
"common",
|
|
16
|
+
"locales.ts",
|
|
17
|
+
"global.ts",
|
|
18
|
+
"README.md"
|
|
19
|
+
]
|
|
20
|
+
}
|