载入中...
搜索中...
未找到
EditorPackage.cpp
浏览该文件的文档.
2
3namespace eve::editing {
4
5Result<void> validateEditorPackage(const EditorPackage& package, bool allowIncomplete) {
6 if (package.ownerModule.empty())
7 return failed<void>(Status::Rejected, RuleId("editing.package.empty-owner"),
8 "EditorPackage.ownerModule must not be empty");
9 if (package.incomplete && !allowIncomplete)
10 return failed<void>(Status::Rejected, RuleId("editing.package.incomplete"),
11 "EditorPackage is marked incomplete and Host rejected the mount");
12
13 const bool hasAutomationCommand = [&] {
14 for (const EditingCommandDescriptor& command : package.commands)
15 if (command.automationAllowed) return true;
16 return false;
17 }();
18
19 if (hasAutomationCommand && package.panels.empty())
20 return failed<void>(Status::Rejected, RuleId("editing.package.panel-required"),
21 "Automation-allowed commands require at least one package panel");
22
23 for (const EditorPanelSpec& panel : package.panels) {
24 if (panel.id.empty() || panel.region.empty() || panel.capability.empty() || panel.context.empty())
25 return failed<void>(Status::Rejected, RuleId("editing.package.panel-incomplete"),
26 "EditorPanelSpec requires id, region, capability and context");
27 }
28
29 for (const EditingCommandDescriptor& command : package.commands) {
30 if (command.id.empty() || command.ownerModule.empty())
31 return failed<void>(Status::Rejected, RuleId("editing.package.command-id"),
32 "Package commands require id and ownerModule");
33 if (command.ownerModule != package.ownerModule)
34 return failed<void>(Status::Rejected, RuleId("editing.package.command-owner"),
35 "Package command ownerModule must match package.ownerModule");
36 if (command.payloadSchema.typeId.empty() && command.payloadSchema.properties.empty())
37 return failed<void>(Status::Rejected, RuleId("editing.package.payload-schema"),
38 "Package commands require an explicit payloadSchema (use emptyObject)");
39 if (command.automationAllowed) {
40 if (command.panelCapability.empty() || command.panelContext.empty())
41 return failed<void>(Status::Rejected, RuleId("editing.package.panel-binding"),
42 "Automation-allowed commands require panelCapability and panelContext");
43 bool bound = false;
44 for (const EditorPanelSpec& panel : package.panels) {
45 if (panel.capability == command.panelCapability && panel.context == command.panelContext) {
46 bound = true;
47 break;
48 }
49 }
50 if (!bound)
51 return failed<void>(Status::Rejected, RuleId("editing.package.panel-binding-missing"),
52 "Command panelBinding does not match any package panel");
53 }
54 }
55
56 for (const EditorTargetTypeSpec& target : package.targetTypes) {
57 if (target.type.empty())
58 return failed<void>(Status::Rejected, RuleId("editing.package.target-type"),
59 "Package targetTypes require a non-empty type");
60 if (target.createSchema.typeId.empty() && target.createSchema.properties.empty())
61 return failed<void>(Status::Rejected, RuleId("editing.package.create-schema"),
62 "Package targetTypes require an explicit createSchema (use emptyObject)");
63 }
64
65 return applied<void>();
66}
67
68} // namespace eve::editing
LogicalId target
Move-only operation result carrying either a value or Status.
Definition Result.h:176
StrongId< RuleIdTag > RuleId
Definition EditingIds.h:60
Result< void > validateEditorPackage(const EditorPackage &package, bool allowIncomplete)
Validate package completeness for Host mount.
Domain-owned metadata for one planned editing command.
Single domain-editor deliverable for Host discover/autoMount.
std::vector< EditorTargetTypeSpec > targetTypes
std::vector< EditingCommandDescriptor > commands
std::vector< EditorPanelSpec > panels
UI-neutral panel descriptor contributed by a domain editor package.
Target type advertised for automation create, with optional createSchema.