@macrowing/inbiz-codegen 0.0.0-stage → 1.0.1
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 +392 -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
package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Workbench/WorkFlowWorkbenchClient.cs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
namespace Macrowing.InBiz.SDK.WorkFlow;
|
|
2
|
+
|
|
3
|
+
/// <summary>Read the workbench lists for the specified user.</summary>
|
|
4
|
+
public interface IWorkFlowWorkbenchClient
|
|
5
|
+
{
|
|
6
|
+
/// <summary>Lists process definitions the user can start, not their existing applications.</summary>
|
|
7
|
+
Task<WorkFlowResult<WorkFlowPage>> GetStartableProcessesAsync(WorkFlowCredential credential, WorkFlowStartableQuery query, CancellationToken cancellationToken = default);
|
|
8
|
+
/// <summary>Lists tasks awaiting action by the specified user.</summary>
|
|
9
|
+
Task<WorkFlowResult<WorkFlowPage>> GetMyPendingTasksAsync(WorkFlowCredential credential, WorkFlowListQuery query, CancellationToken cancellationToken = default);
|
|
10
|
+
/// <summary>Lists tasks handled by the specified user and still shown in the completed view.</summary>
|
|
11
|
+
Task<WorkFlowResult<WorkFlowPage>> GetMyCompletedTasksAsync(WorkFlowCredential credential, WorkFlowListQuery query, CancellationToken cancellationToken = default);
|
|
12
|
+
/// <summary>Lists instances available in the user's workflow archive.</summary>
|
|
13
|
+
Task<WorkFlowResult<WorkFlowPage>> GetMyArchivedProcessesAsync(WorkFlowCredential credential, WorkFlowListQuery query, CancellationToken cancellationToken = default);
|
|
14
|
+
/// <summary>Lists workflows copied to the user.</summary>
|
|
15
|
+
Task<WorkFlowResult<WorkFlowPage>> GetMyCopiedProcessesAsync(WorkFlowCredential credential, WorkFlowListQuery query, CancellationToken cancellationToken = default);
|
|
16
|
+
/// <summary>Lists instances started by the user, optionally applying the engine's application-view filter.</summary>
|
|
17
|
+
Task<WorkFlowResult<WorkFlowPage>> GetMyInitiatedProcessesAsync(WorkFlowCredential credential, WorkFlowListQuery query, bool? underApplication = null, CancellationToken cancellationToken = default);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
internal sealed class WorkFlowWorkbenchClient(WorkFlowTransport transport) : IWorkFlowWorkbenchClient
|
|
21
|
+
{
|
|
22
|
+
private const string Prefix = "process/getResults/";
|
|
23
|
+
|
|
24
|
+
public Task<WorkFlowResult<WorkFlowPage>> GetStartableProcessesAsync(WorkFlowCredential credential, WorkFlowStartableQuery query, CancellationToken cancellationToken) =>
|
|
25
|
+
Get(credential, "getMyApply", cancellationToken,
|
|
26
|
+
[("userId", query.UserId), ("pageIndex", query.PageIndex), ("pageSize", query.PageSize),
|
|
27
|
+
("queryParameter", query.QueryParameter), ("orderName", query.OrderName), ("orderType", query.OrderType),
|
|
28
|
+
("dptKey", query.DptKey), ("processName", query.ProcessName), ("processGroupName", query.ProcessGroupName),
|
|
29
|
+
("processKey", query.ProcessKey), ("processGroupId", query.ProcessGroupId), ("webSiteId", query.WebSiteId),
|
|
30
|
+
("isotherSites", query.IncludeOtherSites)]);
|
|
31
|
+
|
|
32
|
+
public Task<WorkFlowResult<WorkFlowPage>> GetMyPendingTasksAsync(WorkFlowCredential credential, WorkFlowListQuery query, CancellationToken cancellationToken) =>
|
|
33
|
+
List(credential, "getMyInbox", query, cancellationToken);
|
|
34
|
+
|
|
35
|
+
public Task<WorkFlowResult<WorkFlowPage>> GetMyCompletedTasksAsync(WorkFlowCredential credential, WorkFlowListQuery query, CancellationToken cancellationToken) =>
|
|
36
|
+
List(credential, "getMyComplete", query, cancellationToken);
|
|
37
|
+
|
|
38
|
+
public Task<WorkFlowResult<WorkFlowPage>> GetMyArchivedProcessesAsync(WorkFlowCredential credential, WorkFlowListQuery query, CancellationToken cancellationToken) =>
|
|
39
|
+
List(credential, "getMyArchive", query, cancellationToken);
|
|
40
|
+
|
|
41
|
+
public Task<WorkFlowResult<WorkFlowPage>> GetMyCopiedProcessesAsync(WorkFlowCredential credential, WorkFlowListQuery query, CancellationToken cancellationToken) =>
|
|
42
|
+
List(credential, "getMyCctome", query, cancellationToken);
|
|
43
|
+
|
|
44
|
+
public Task<WorkFlowResult<WorkFlowPage>> GetMyInitiatedProcessesAsync(WorkFlowCredential credential, WorkFlowListQuery query, bool? underApplication, CancellationToken cancellationToken) =>
|
|
45
|
+
List(credential, "getMyInitiatorv6", query, cancellationToken, underApplication);
|
|
46
|
+
|
|
47
|
+
private Task<WorkFlowResult<WorkFlowPage>> Get(WorkFlowCredential credential, string action, CancellationToken cancellationToken,
|
|
48
|
+
(string Name, object? Value)[] query) => transport.GetResultAsync<WorkFlowPage>(credential, HttpMethod.Get, Prefix + action, cancellationToken, query);
|
|
49
|
+
|
|
50
|
+
private Task<WorkFlowResult<WorkFlowPage>> List(WorkFlowCredential credential, string action, WorkFlowListQuery query,
|
|
51
|
+
CancellationToken cancellationToken, bool? underApplication = null) =>
|
|
52
|
+
Get(credential, action, cancellationToken,
|
|
53
|
+
[("userId", query.UserId), ("pageIndex", query.PageIndex), ("pageSize", query.PageSize),
|
|
54
|
+
("processInstanceId", query.ProcessInstanceId), ("queryParameter", query.QueryParameter), ("sort", query.Sort),
|
|
55
|
+
("order", query.Order), ("dptKey", query.DptKey), ("classification", query.Classification), ("processName", query.ProcessName),
|
|
56
|
+
("processGroupName", query.ProcessGroupName), ("starterId", query.StarterId), ("status", query.Status),
|
|
57
|
+
("date", query.Date), ("processDefinitionId", query.ProcessDefinitionId), ("webSiteId", query.WebSiteId),
|
|
58
|
+
("isunderApplication", underApplication)]);
|
|
59
|
+
}
|
package/templates/backend/modules/Macrowing.InBiz.SDK/WorkFlow/Workbench/WorkFlowWorkbenchModels.cs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
using System.Text.Json;
|
|
2
|
+
|
|
3
|
+
namespace Macrowing.InBiz.SDK.WorkFlow;
|
|
4
|
+
|
|
5
|
+
/// <summary>One workbench result page. Row shape varies between definitions, tasks and instances.</summary>
|
|
6
|
+
/// <param name="Total">Total matching records reported by the engine.</param>
|
|
7
|
+
/// <param name="PageSize">Page size reported by the engine.</param>
|
|
8
|
+
/// <param name="CurrPage">Current page reported by the engine.</param>
|
|
9
|
+
/// <param name="Rows">Workbench records, possibly absent.</param>
|
|
10
|
+
public sealed record WorkFlowPage(long Total, int PageSize, int CurrPage, IReadOnlyList<JsonElement>? Rows);
|
|
11
|
+
|
|
12
|
+
/// <summary>Shared filters for workbench task and instance lists. Omitted filters use engine defaults.</summary>
|
|
13
|
+
/// <param name="UserId">Organization user ID whose workbench is requested.</param>
|
|
14
|
+
public sealed record WorkFlowListQuery(string UserId)
|
|
15
|
+
{
|
|
16
|
+
/// <summary>Requested page index as understood by the workbench endpoint.</summary>
|
|
17
|
+
public int? PageIndex { get; init; }
|
|
18
|
+
/// <summary>Maximum rows to request per page.</summary>
|
|
19
|
+
public int? PageSize { get; init; }
|
|
20
|
+
/// <summary>Restricts results to an existing workflow instance.</summary>
|
|
21
|
+
public string? ProcessInstanceId { get; init; }
|
|
22
|
+
/// <summary>Workbench search text or engine query parameter.</summary>
|
|
23
|
+
public string? QueryParameter { get; init; }
|
|
24
|
+
/// <summary>Engine field to sort on, when supported by the list.</summary>
|
|
25
|
+
public string? Sort { get; init; }
|
|
26
|
+
/// <summary>Engine sort direction, for example <c>asc</c> or <c>desc</c>.</summary>
|
|
27
|
+
public string? Order { get; init; }
|
|
28
|
+
/// <summary>Optional department key filter.</summary>
|
|
29
|
+
public string? DptKey { get; init; }
|
|
30
|
+
/// <summary>Optional engine classification filter.</summary>
|
|
31
|
+
public string? Classification { get; init; }
|
|
32
|
+
/// <summary>Workflow name filter.</summary>
|
|
33
|
+
public string? ProcessName { get; init; }
|
|
34
|
+
/// <summary>Workflow group name filter.</summary>
|
|
35
|
+
public string? ProcessGroupName { get; init; }
|
|
36
|
+
/// <summary>Organization ID of the initiator to filter by.</summary>
|
|
37
|
+
public string? StarterId { get; init; }
|
|
38
|
+
/// <summary>Engine status filter for the requested list.</summary>
|
|
39
|
+
public string? Status { get; init; }
|
|
40
|
+
/// <summary>Engine date filter in the format expected by the requested list.</summary>
|
|
41
|
+
public string? Date { get; init; }
|
|
42
|
+
/// <summary>Exact deployed workflow definition ID to filter by.</summary>
|
|
43
|
+
public string? ProcessDefinitionId { get; init; }
|
|
44
|
+
/// <summary>Site ID restricting the requested workbench list.</summary>
|
|
45
|
+
public string? WebSiteId { get; init; }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// <summary>Filters the catalog of workflow definitions available to start.</summary>
|
|
49
|
+
/// <param name="UserId">Organization user ID whose start permissions are evaluated.</param>
|
|
50
|
+
public sealed record WorkFlowStartableQuery(string UserId)
|
|
51
|
+
{
|
|
52
|
+
/// <summary>Requested page index as understood by the workbench endpoint.</summary>
|
|
53
|
+
public int? PageIndex { get; init; }
|
|
54
|
+
/// <summary>Maximum definitions to request per page.</summary>
|
|
55
|
+
public int? PageSize { get; init; }
|
|
56
|
+
/// <summary>Workbench search text or engine query parameter.</summary>
|
|
57
|
+
public string? QueryParameter { get; init; }
|
|
58
|
+
/// <summary>Engine field to sort the catalog by.</summary>
|
|
59
|
+
public string? OrderName { get; init; }
|
|
60
|
+
/// <summary>Engine sort direction for the catalog.</summary>
|
|
61
|
+
public string? OrderType { get; init; }
|
|
62
|
+
/// <summary>Optional department key filter.</summary>
|
|
63
|
+
public string? DptKey { get; init; }
|
|
64
|
+
/// <summary>Workflow name filter.</summary>
|
|
65
|
+
public string? ProcessName { get; init; }
|
|
66
|
+
/// <summary>Workflow group name filter.</summary>
|
|
67
|
+
public string? ProcessGroupName { get; init; }
|
|
68
|
+
/// <summary>Workflow definition key filter, independent of deployment version.</summary>
|
|
69
|
+
public string? ProcessKey { get; init; }
|
|
70
|
+
/// <summary>Workflow group ID filter.</summary>
|
|
71
|
+
public string? ProcessGroupId { get; init; }
|
|
72
|
+
/// <summary>Site ID used to scope the catalog.</summary>
|
|
73
|
+
public string? WebSiteId { get; init; }
|
|
74
|
+
/// <summary>Whether the catalog should include permitted definitions from other sites.</summary>
|
|
75
|
+
public bool? IncludeOtherSites { get; init; }
|
|
76
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<RootNamespace>Macrowing.OC.SDK</RootNamespace>
|
|
5
|
+
<AssemblyName>Macrowing.OC.SDK</AssemblyName>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
|
|
8
|
+
<ItemGroup>
|
|
9
|
+
<PackageReference Include="Volo.Abp.Core" />
|
|
10
|
+
<PackageReference Include="Grpc.Net.Client" />
|
|
11
|
+
<PackageReference Include="Google.Protobuf" />
|
|
12
|
+
<PackageReference Include="Grpc.Tools" PrivateAssets="All" />
|
|
13
|
+
</ItemGroup>
|
|
14
|
+
|
|
15
|
+
<ItemGroup>
|
|
16
|
+
<!-- 文档云 gRPC 契约:从 InBiz 仓库复制 proto,与平台侧保持同源 -->
|
|
17
|
+
<Protobuf Include="Protos\**\*.proto" GrpcServices="Client" />
|
|
18
|
+
</ItemGroup>
|
|
19
|
+
|
|
20
|
+
</Project>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
using Volo.Abp.Modularity;
|
|
2
|
+
|
|
3
|
+
namespace Macrowing.OC.SDK;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// 文档云(OpenContent)SDK 模块。
|
|
7
|
+
///
|
|
8
|
+
/// 出码页面中凡是涉及「文档」的能力——上传、预览、检索、下载、权限——
|
|
9
|
+
/// 都经由本模块,而不是让生成代码直连 gRPC。
|
|
10
|
+
///
|
|
11
|
+
/// 契约来源:InBiz 仓库中的 ECM gRPC 契约
|
|
12
|
+
/// Backend/src/backend/ecm/EDoc2.InBiz.Ecm.Grpc.Contracts
|
|
13
|
+
/// Backend/src/backend/ecm/EDoc2.InBiz.Ecm.Core.Grpc.Contracts
|
|
14
|
+
/// 复制 proto 到本模块 Protos/ 下,保持与平台同源。
|
|
15
|
+
/// </summary>
|
|
16
|
+
public class OcSdkModule : AbpModule
|
|
17
|
+
{
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Protos
|
|
2
|
+
|
|
3
|
+
文档云 gRPC 契约存放目录。
|
|
4
|
+
|
|
5
|
+
## 来源
|
|
6
|
+
|
|
7
|
+
从 InBiz 仓库复制,保持与平台同源,**不要手改**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Backend/src/backend/ecm/EDoc2.InBiz.Ecm.Grpc.Contracts/
|
|
11
|
+
Backend/src/backend/ecm/EDoc2.InBiz.Ecm.Core.Grpc.Contracts/
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 复制规则
|
|
15
|
+
|
|
16
|
+
只取 `.proto` 文件(不含 `bin/`、`obj/`),并把 `option csharp_namespace` 统一改为
|
|
17
|
+
`Macrowing.OC.SDK.Grpc`,避免与平台侧生成类冲突。
|
|
18
|
+
|
|
19
|
+
## 为什么复制而不是引用
|
|
20
|
+
|
|
21
|
+
SDK 要能独立发包、独立升级。直接 `ProjectReference` 到 InBiz 的契约工程会把出码产物
|
|
22
|
+
绑死在 InBiz 源码树上,违背「不修改、不依赖 InBiz 服务端代码」的前提。
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
<PropertyGroup>
|
|
3
|
+
<IsTestProject>true</IsTestProject>
|
|
4
|
+
<IsPackable>false</IsPackable>
|
|
5
|
+
</PropertyGroup>
|
|
6
|
+
<ItemGroup>
|
|
7
|
+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
|
8
|
+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
|
9
|
+
<PackageReference Include="xunit" />
|
|
10
|
+
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" />
|
|
11
|
+
<ProjectReference Include="../../modules/Macrowing.InBiz.SDK/Macrowing.InBiz.SDK.csproj" />
|
|
12
|
+
<Using Include="Xunit" />
|
|
13
|
+
</ItemGroup>
|
|
14
|
+
</Project>
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
using System.Net;
|
|
2
|
+
using System.Text.Json;
|
|
3
|
+
using System.Text.Json.Nodes;
|
|
4
|
+
using Macrowing.InBiz.SDK.Cms;
|
|
5
|
+
using Macrowing.InBiz.SDK.Dictionary;
|
|
6
|
+
using Macrowing.InBiz.SDK.InterfaceEngine;
|
|
7
|
+
using Macrowing.InBiz.SDK.Localization;
|
|
8
|
+
using Macrowing.InBiz.SDK.Message;
|
|
9
|
+
using Macrowing.InBiz.SDK.Model;
|
|
10
|
+
using Macrowing.InBiz.SDK.Permission;
|
|
11
|
+
using Macrowing.InBiz.SDK.Platform;
|
|
12
|
+
using Microsoft.AspNetCore.Http;
|
|
13
|
+
|
|
14
|
+
namespace Macrowing.InBiz.SDK.Tests;
|
|
15
|
+
|
|
16
|
+
public sealed class PlatformContractTests
|
|
17
|
+
{
|
|
18
|
+
private static readonly InBizRequestContext Caller = new("application-id", "token+/=");
|
|
19
|
+
|
|
20
|
+
[Fact]
|
|
21
|
+
public async Task ModelQueriesPreserveWireFiltersAndRecordValues()
|
|
22
|
+
{
|
|
23
|
+
await using var server = await WorkFlowHttpServer.StartAsync(
|
|
24
|
+
new("""{"Success":0,"Total":1,"Rows":[{"OriginalName":"sample","Flag":true}],"primary":"id","RelationField":"ParentID"}"""),
|
|
25
|
+
new("""{"ID":"1","Amount":15.75,"Name":null,"error":{"message":"ordinary model field"}}"""),
|
|
26
|
+
new("", 204),
|
|
27
|
+
new("""{"Success":0,"Total":0,"Rows":[]}"""));
|
|
28
|
+
|
|
29
|
+
var model = server.Client<IModelClient>();
|
|
30
|
+
var result = await model.QueryAsync(Caller, new("active-orders")
|
|
31
|
+
{
|
|
32
|
+
PageInfo = new(2, 10),
|
|
33
|
+
Conditions = [new(0, [new("Order", "Status", ModelOperator.IsNotNull)], ModelConnector.Or,
|
|
34
|
+
[new(1, [new("Order", "Tags", ModelOperator.ContainsDelimited, "verified")])])],
|
|
35
|
+
OrderInfo = [new("Order", "Name"), new("Order", "id", Descending: true, Order: 1)],
|
|
36
|
+
LazyModel = "OrderLine"
|
|
37
|
+
});
|
|
38
|
+
Assert.NotNull(result);
|
|
39
|
+
Assert.Equal(1, result.Total);
|
|
40
|
+
Assert.Equal("id", result.Primary);
|
|
41
|
+
Assert.Equal("ParentID", result.RelationField);
|
|
42
|
+
Assert.True(Assert.Single(result.Rows)["Flag"].GetBoolean());
|
|
43
|
+
Assert.Equal("sample", result.Rows[0]["OriginalName"].GetString());
|
|
44
|
+
var record = await model.GetAsync(Caller, "Order", "1");
|
|
45
|
+
Assert.Equal(15.75m, record["Amount"].GetDecimal());
|
|
46
|
+
Assert.Equal(JsonValueKind.Null, record["Name"].ValueKind);
|
|
47
|
+
Assert.Equal("ordinary model field", record["error"].GetProperty("message").GetString());
|
|
48
|
+
Assert.Null(await model.QueryAsync(Caller, new("not-a-model") { PageInfo = null }));
|
|
49
|
+
Assert.Empty((await model.QueryAsync(Caller, new("empty")))!.Rows);
|
|
50
|
+
|
|
51
|
+
Assert.Collection(server.Requests,
|
|
52
|
+
r => Check(r, "POST", "v1/model/queryDatas", """
|
|
53
|
+
{"key":"active-orders","pageInfo":{"index":2,"size":10},"dropDownList":false,"lazyModel":"OrderLine",
|
|
54
|
+
"conditions":[{"index":0,"connector":1,"condition":[{"modelName":"Order","field":"Status","operator":16,"connector":0}],
|
|
55
|
+
"childGroup":[{"index":1,"connector":0,"condition":[{"modelName":"Order","field":"Tags","operator":9,"value":"verified","connector":0}]}]}],
|
|
56
|
+
"orderInfo":[{"modelName":"Order","fieldName":"Name","order":0,"sortType":"asc"},{"modelName":"Order","fieldName":"id","order":1,"sortType":"desc"}]}
|
|
57
|
+
"""),
|
|
58
|
+
r => Check(r, "POST", "v1/model/selectData", """{"modelName":"Order","id":"1"}"""),
|
|
59
|
+
r => Check(r, "POST", "v1/model/queryDatas", """{"key":"not-a-model","dropDownList":false}"""),
|
|
60
|
+
r => Check(r, "POST", "v1/model/queryDatas", """{"key":"empty","pageInfo":{"index":1,"size":20},"dropDownList":false}"""));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[Fact]
|
|
64
|
+
public async Task ModelWritePreservesOperationsRelationshipsAndExplicitNull()
|
|
65
|
+
{
|
|
66
|
+
await using var server = await WorkFlowHttpServer.StartAsync(
|
|
67
|
+
new("""{"result":0,"data":"master-id"}"""), new("""{"result":1,"message":"write rejected"}"""));
|
|
68
|
+
var client = server.Client<IModelClient>();
|
|
69
|
+
var write = new ModelWrite(new Dictionary<string, IReadOnlyList<ModelRowChange>>
|
|
70
|
+
{
|
|
71
|
+
["Order"] = [new(ModelRowOperation.Update, new Dictionary<string, object?> { ["id"] = "master-id" })],
|
|
72
|
+
["OrderLine"] =
|
|
73
|
+
[
|
|
74
|
+
new(ModelRowOperation.Insert, new Dictionary<string, object?> { ["OriginalCase"] = "item", ["Memo"] = null }),
|
|
75
|
+
new(ModelRowOperation.Delete, new Dictionary<string, object?> { ["id"] = "old" }),
|
|
76
|
+
new(ModelRowOperation.Unchanged, new Dictionary<string, object?> { ["id"] = "existing" })
|
|
77
|
+
]
|
|
78
|
+
}, new("Order", Children: [new("OrderLine", ModelRelationType.OneToMany, "OrderID")]));
|
|
79
|
+
Assert.Equal("master-id", await client.WriteAsync(Caller, write));
|
|
80
|
+
var business = await Assert.ThrowsAsync<InBizPlatformException>(() => client.WriteAsync(Caller, write));
|
|
81
|
+
Assert.Equal(InBizFailureKind.Business, business.Kind);
|
|
82
|
+
Assert.Equal(1, business.Result);
|
|
83
|
+
Assert.Equal("write rejected", business.PlatformMessage);
|
|
84
|
+
await Assert.ThrowsAsync<ArgumentException>(() => client.WriteAsync(Caller, write with { Relation = new("OrderLine") }));
|
|
85
|
+
Assert.Equal(2, server.Requests.Length);
|
|
86
|
+
Check(server.Requests[0], "POST", "v1/model/data", """
|
|
87
|
+
{"relation":{"name":"Order","type":0,"childrens":[{"name":"OrderLine","type":1,"refField":"OrderID"}]},
|
|
88
|
+
"data":{"Order":[{"id":"master-id","_opt":"edit"}],"OrderLine":[
|
|
89
|
+
{"OriginalCase":"item","Memo":null,"_opt":"add"},{"id":"old","_opt":"del"},{"id":"existing"}]}}
|
|
90
|
+
""");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[Fact]
|
|
94
|
+
public async Task MessageUsesTemplateChannelAndBatchCredentialsContract()
|
|
95
|
+
{
|
|
96
|
+
await using var server = await WorkFlowHttpServer.StartAsync(
|
|
97
|
+
new("""[{"Id":"1","TemplateKey":"notice","Category":5,"Title":"title","Content":"hello","LinkUrl":"/docs"}]"""),
|
|
98
|
+
new("false"), new("true"));
|
|
99
|
+
var client = server.Client<IMessageClient>();
|
|
100
|
+
Assert.Equal("/docs", Assert.Single(await client.GetTemplateAsync(Caller, "a+b & c")).LinkUrl);
|
|
101
|
+
var parameters = new Dictionary<string, string> { ["OriginalKey"] = "value" };
|
|
102
|
+
Assert.False(await client.SendAsync(Caller, new("notice", [new("u")], parameters)));
|
|
103
|
+
Assert.True(await client.SendManyAsync(Caller, new("notice", [new([new("d", MessageMemberType.Department)], parameters)])));
|
|
104
|
+
Assert.Collection(server.Requests,
|
|
105
|
+
r => { Check(r, "GET", "v1/message"); Assert.Equal("a+b & c", r.Query["key"]); },
|
|
106
|
+
r => Check(r, "POST", "v1/message/send", """
|
|
107
|
+
{"templateKey":"notice","memberModels":[{"memberId":"u","memberType":0}],"parameter":{"OriginalKey":"value"}}
|
|
108
|
+
"""),
|
|
109
|
+
r => Check(r, "POST", "v1/message/sendMany", """
|
|
110
|
+
{"appId":"application-id","token":"token+/=","templateKey":"notice","memberParas":[{"memberModels":[{"memberId":"d","memberType":5}],"parameter":{"OriginalKey":"value"}}]}
|
|
111
|
+
"""));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
[Fact]
|
|
115
|
+
public async Task CustomMessageUsesChannelKeyAndBodySubstitutionsWithoutSendingTheTokenInJson()
|
|
116
|
+
{
|
|
117
|
+
await using var server = await WorkFlowHttpServer.StartAsync(new WorkFlowHttpServer.Response("false"));
|
|
118
|
+
var client = server.Client<IMessageClient>();
|
|
119
|
+
var request = new SendCustomMessage("in-app", [new("u")], "New order", "{OrderId}",
|
|
120
|
+
new Dictionary<string, string> { ["OrderId"] = "200" });
|
|
121
|
+
Assert.False(await client.SendCustomAsync(Caller, request));
|
|
122
|
+
await Assert.ThrowsAsync<ArgumentException>(() => client.SendCustomAsync(Caller, request with { MemberModels = [] }));
|
|
123
|
+
Check(Assert.Single(server.Requests), "POST", "v1/message/sendCustom", """
|
|
124
|
+
{"msgCategoryKey":"in-app","memberModels":[{"memberId":"u","memberType":0}],"msgTitle":"New order",
|
|
125
|
+
"content":"{OrderId}","parameter":{"OrderId":"200"}}
|
|
126
|
+
""");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
[Fact]
|
|
130
|
+
public async Task ConfiguredInterfaceEncodesParametersAndReturnsRawOrQuotedText()
|
|
131
|
+
{
|
|
132
|
+
await using var server = await WorkFlowHttpServer.StartAsync(
|
|
133
|
+
new("""{"ok":true}""", ContentType: "text/plain"), new(""""upstream message""""));
|
|
134
|
+
var client = server.Client<IInterfaceEngineClient>();
|
|
135
|
+
var values = new Dictionary<string, object?> { ["Original"] = 42 };
|
|
136
|
+
var invocation = new InterfaceInvocation("order.lookup", values, values, values, values);
|
|
137
|
+
Assert.Equal("""{"ok":true}""", await client.InvokeAsync(Caller, invocation));
|
|
138
|
+
Assert.Equal("upstream message", await client.InvokeAsync(Caller, new("status")));
|
|
139
|
+
Check(server.Requests[0], "POST", "v1/apiEngineApp/invoke", """
|
|
140
|
+
{"key":"order.lookup","appId":"application-id","header":"{\"Original\":42}","body":"{\"Original\":42}",
|
|
141
|
+
"query":"{\"Original\":42}","path":"{\"Original\":42}"}
|
|
142
|
+
""");
|
|
143
|
+
Check(server.Requests[1], "POST", "v1/apiEngineApp/invoke", """{"key":"status","appId":"application-id"}""");
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
[Fact]
|
|
147
|
+
public async Task DictionariesAndTranslationsUsePublishedRoutes()
|
|
148
|
+
{
|
|
149
|
+
await using var server = await WorkFlowHttpServer.StartAsync(
|
|
150
|
+
new("""{"Status":[{"Id":"entry","Text":"label","Value":"code","GroupId":"Status","ColumnSort":2}]}"""),
|
|
151
|
+
new("""{"Title":"name","nested":{"Original":"translation"}}"""));
|
|
152
|
+
var dict = await server.Client<IDictionaryClient>().GetGroupsAsync(Caller, ["Status", "Other & Group"], "zh-cn");
|
|
153
|
+
Assert.Equal("code", Assert.Single(dict["Status"]).Value);
|
|
154
|
+
var texts = await server.Client<ILocalizationClient>().GetTextsAsync(Caller, "zh-cn");
|
|
155
|
+
Assert.Equal("translation", texts["nested"].GetProperty("Original").GetString());
|
|
156
|
+
Assert.Collection(server.Requests,
|
|
157
|
+
r =>
|
|
158
|
+
{
|
|
159
|
+
Check(r, "GET", "front/modelengine/v3/dictData/groupIds/application-id");
|
|
160
|
+
Assert.Equal("Status,Other & Group", r.Query["groupKeys"]);
|
|
161
|
+
Assert.Equal("zh-cn", r.Query["kindCode"]);
|
|
162
|
+
},
|
|
163
|
+
r =>
|
|
164
|
+
{
|
|
165
|
+
Check(r, "GET", "languagengine/v3/language/json/application-id");
|
|
166
|
+
Assert.Equal("zh-cn", r.Query["kindCode"]);
|
|
167
|
+
Assert.Equal("0", r.Query["type"]);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
[Fact]
|
|
172
|
+
public async Task PermissionChecksUseDistinctRoutesAndPreserve64BitValues()
|
|
173
|
+
{
|
|
174
|
+
await using var server = await WorkFlowHttpServer.StartAsync(
|
|
175
|
+
new("false"), new("""[{"Route":"/orders","IsHavePerm":false},{"Route":"/home","IsHavePerm":true}]"""),
|
|
176
|
+
new("""[{"ParentValue":"Order","ObjectValue":"select","PermissionValue":"9007199254740993"}]"""));
|
|
177
|
+
var permission = server.Client<IPermissionClient>();
|
|
178
|
+
Assert.False(await permission.HasApplicationManagementAccessAsync(Caller));
|
|
179
|
+
var routes = await permission.GetMenuRoutesAsync(Caller, "site-id", ["/orders", "/home"]);
|
|
180
|
+
Assert.False(routes[0].IsHavePerm);
|
|
181
|
+
Assert.True(routes[1].IsHavePerm);
|
|
182
|
+
Assert.Equal(9007199254740993L,
|
|
183
|
+
Assert.Single(await permission.GetModelButtonsAsync(Caller, "site-id", [new("Order", ["select"])] )).PermissionValue);
|
|
184
|
+
Assert.Collection(server.Requests,
|
|
185
|
+
r => Check(r, "GET", "v1/permission/haveAppPerm"),
|
|
186
|
+
r =>
|
|
187
|
+
{
|
|
188
|
+
Check(r, "GET", "v1/permission/havePerm");
|
|
189
|
+
Assert.Equal("site-id", r.Query["siteOutId"]);
|
|
190
|
+
Assert.Equal("/orders,/home", r.Query["routes"]);
|
|
191
|
+
Assert.Contains("&routes=%2Forders&routes=%2Fhome", r.RawTarget);
|
|
192
|
+
},
|
|
193
|
+
r => Check(r, "POST", "v1/permission/getButtonPerm", """{"siteOutId":"site-id","list":[{"modelKey":"Order","objectValues":["select"]}]}"""));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
[Fact]
|
|
197
|
+
public async Task CmsUsesCategoryPageAndDetailContracts()
|
|
198
|
+
{
|
|
199
|
+
await using var server = await WorkFlowHttpServer.StartAsync(
|
|
200
|
+
new("""[{"Key":"news&announcements","Title":"News"}]"""),
|
|
201
|
+
new("""{"ContentList":[{"ID":"abc","Title":"News","ContentType":1}],"TopList":null,"PageIndex":2,"PageSize":5,"PageCount":2,"Total":6}"""),
|
|
202
|
+
new("""{"ID":"abc","Content":"<p>Body</p>","ContentType":1,"Timestamp":"9876543210"}"""));
|
|
203
|
+
var cms = server.Client<ICmsClient>();
|
|
204
|
+
var category = Assert.Single(await cms.GetCategoriesAsync(Caller, CmsContentKind.News));
|
|
205
|
+
var page = await cms.ListAsync(Caller, new(CmsContentKind.News, category.Key) { PageIndex = 2, PageSize = 5, Tag = "x+y" });
|
|
206
|
+
Assert.Empty(page.TopList);
|
|
207
|
+
Assert.Equal(6, page.Total);
|
|
208
|
+
var detail = await cms.GetAsync(Caller, Assert.Single(page.ContentList).Id);
|
|
209
|
+
Assert.NotNull(detail);
|
|
210
|
+
Assert.Equal("<p>Body</p>", detail.Content);
|
|
211
|
+
Assert.Equal(9876543210L, detail.Timestamp);
|
|
212
|
+
Assert.Collection(server.Requests,
|
|
213
|
+
r =>
|
|
214
|
+
{
|
|
215
|
+
Check(r, "GET", "cms/v3/cms/categoryTree/0000-0000-0000");
|
|
216
|
+
Assert.Equal("1", r.Query["categoryType"]);
|
|
217
|
+
},
|
|
218
|
+
r =>
|
|
219
|
+
{
|
|
220
|
+
Check(r, "GET", "cms/v3/cms/contentList");
|
|
221
|
+
Assert.Equal(category.Key, r.Query["categoryId"]);
|
|
222
|
+
Assert.Equal("2", r.Query["pageIndex"]);
|
|
223
|
+
Assert.Equal("5", r.Query["pageSize"]);
|
|
224
|
+
Assert.Equal("x+y", r.Query["tag"]);
|
|
225
|
+
},
|
|
226
|
+
r => Check(r, "GET", "cms/v3/cms/abc/detailContentInfo"));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
[Theory]
|
|
230
|
+
[InlineData(401, "{}", false, InBizFailureKind.AuthenticationOrPermission)]
|
|
231
|
+
[InlineData(403, "{}", false, InBizFailureKind.AuthenticationOrPermission)]
|
|
232
|
+
[InlineData(500, """{"Error":{"Code":"example:001","Message":"draft missing"}}""", false, InBizFailureKind.Business)]
|
|
233
|
+
[InlineData(200, """{"Error":{"Code":"example:001","Message":"draft missing"}}""", true, InBizFailureKind.Business)]
|
|
234
|
+
[InlineData(500, """{"error":{}}""", false, InBizFailureKind.Http)]
|
|
235
|
+
[InlineData(302, "", false, InBizFailureKind.Http)]
|
|
236
|
+
[InlineData(200, "null", false, InBizFailureKind.Protocol)]
|
|
237
|
+
[InlineData(200, "\"true\"", false, InBizFailureKind.Protocol)]
|
|
238
|
+
[InlineData(200, "<html>Login</html>", false, InBizFailureKind.Protocol)]
|
|
239
|
+
public async Task TransportDistinguishesFailuresWithoutRedirectOrRetry(int status, string body, bool marked,
|
|
240
|
+
InBizFailureKind expected)
|
|
241
|
+
{
|
|
242
|
+
await using var server = await WorkFlowHttpServer.StartAsync(
|
|
243
|
+
new WorkFlowHttpServer.Response(body, status, Location: status == 302 ? "/login" : null, AbpError: marked));
|
|
244
|
+
var error = await Assert.ThrowsAsync<InBizPlatformException>(
|
|
245
|
+
() => server.Client<IPermissionClient>().HasApplicationManagementAccessAsync(Caller));
|
|
246
|
+
Assert.Equal(expected, error.Kind);
|
|
247
|
+
Assert.Equal((HttpStatusCode)status, error.StatusCode);
|
|
248
|
+
if (expected == InBizFailureKind.Business)
|
|
249
|
+
{
|
|
250
|
+
Assert.Equal("example:001", error.ErrorCode);
|
|
251
|
+
Assert.Equal("draft missing", error.PlatformMessage);
|
|
252
|
+
}
|
|
253
|
+
Assert.Single(server.Requests);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
[Fact]
|
|
257
|
+
public async Task ConcurrentCallersDoNotShareAuthorizationOrServerCookies()
|
|
258
|
+
{
|
|
259
|
+
await using var server = await WorkFlowHttpServer.StartAsync(async http =>
|
|
260
|
+
{
|
|
261
|
+
http.Response.Headers.SetCookie = "token=server-cookie; Path=/";
|
|
262
|
+
var ok = http.Request.Headers["token"].ToString() == "token-" + http.Request.Headers["appId"];
|
|
263
|
+
await http.Response.WriteAsync(ok ? "true" : "false");
|
|
264
|
+
});
|
|
265
|
+
var permission = server.Client<IPermissionClient>();
|
|
266
|
+
var contexts = Enumerable.Range(1, 12).Select(i => new InBizRequestContext($"app-{i}", $"token-app-{i}")).ToArray();
|
|
267
|
+
Assert.True(await permission.HasApplicationManagementAccessAsync(contexts[0]));
|
|
268
|
+
Assert.All(await Task.WhenAll(contexts.Select(c => permission.HasApplicationManagementAccessAsync(c))), value => Assert.True(value));
|
|
269
|
+
Assert.Equal(13, server.Requests.Length);
|
|
270
|
+
Assert.All(server.Requests, r => Assert.Empty(r.Cookie));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private static void Check(WorkFlowHttpServer.Request request, string method, string path, string? json = null)
|
|
274
|
+
{
|
|
275
|
+
Assert.Equal(method, request.Method);
|
|
276
|
+
Assert.Equal("/inbiz/api/services/" + path, request.Path);
|
|
277
|
+
Assert.Equal("application-id", request.AppId);
|
|
278
|
+
Assert.Equal("token+/=", request.Token);
|
|
279
|
+
Assert.Empty(request.Cookie);
|
|
280
|
+
if (json is null)
|
|
281
|
+
Assert.Empty(request.Body);
|
|
282
|
+
else
|
|
283
|
+
{
|
|
284
|
+
Assert.StartsWith("application/json", request.ContentType);
|
|
285
|
+
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(json), JsonNode.Parse(request.Body)), request.Body);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|