Skip to content

Commit

Permalink
Added support for partial Interface Aliases in Use Flows of YAML AaC (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SlavaVedernikov authored Mar 16, 2024
2 parents fcc757a + 7739ca2 commit fdf5e06
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 112 deletions.
4 changes: 2 additions & 2 deletions C4InterFlow.Automation/C4InterFlow.Automation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<Deterministic>true</Deterministic>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>0.37.0</Version>
<Version>0.38.0</Version>
</PropertyGroup>

<PropertyGroup>
<PackageId>C4InterFlow.Automation</PackageId>
<PackageVersion>0.37.0</PackageVersion>
<PackageVersion>0.38.0</PackageVersion>
<Authors>Slava Vedernikov</Authors>
<Description>Revolutionise your Application Architecture Documentation with C4InterFlow. Designed for Architects and Engineers, this tool leverages the widely-recognised C4 Model (Architecture Visualisation framework), enhanced with unique features like Interface and Flow, to describe your Application Architecture as Code. Experience an intuitive, efficient way to document complex systems, ensuring clarity and consistency across your teams and products.</Description>
<Copyright>Copyright 2024 Slava Vedernikov</Copyright>
Expand Down
32 changes: 32 additions & 0 deletions C4InterFlow.Automation/Readers/JObjectStructuresResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public JObjectStructuresResolver()
public JObjectStructuresResolver(JObject rootJObject)
{
RootJObject = rootJObject;
CompletePartialUseFlowExpressions();
}

public T? GetInstance<T>(string? alias) where T : Structure
Expand Down Expand Up @@ -234,6 +235,37 @@ public IEnumerable<T> GetNestedInstances<T>(string? alias) where T : Structure
return result;
}

public void CompletePartialUseFlowExpressions()
{
var interfaces = RootJObject.SelectTokens("..Interfaces.*");

foreach (var @interface in interfaces)
{
var useFlows = @interface.SelectTokens("..[?(@.Type=='Use')]");

foreach (var useFlow in useFlows)
{
var usesInterfaceAlias = useFlow["Expression"].ToString();
var usesInterface = RootJObject.SelectToken(usesInterfaceAlias);

if (usesInterface == null)
{
var parent = @interface;
do
{
parent = parent.Parent;
usesInterface = parent.SelectToken(usesInterfaceAlias);
} while (usesInterface == null && parent.Parent != null);

if(usesInterface != null)
{
useFlow["Expression"] = usesInterface.Path;
}
}
}
}
}

public void Validate(out IEnumerable<string> errors)
{
var errorsInternal = new List<string>();
Expand Down
2 changes: 1 addition & 1 deletion C4InterFlow.Cli/C4InterFlow.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.37.0</Version>
<Version>0.38.0</Version>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
Expand Down
2 changes: 1 addition & 1 deletion C4InterFlow.Cli/CLI Commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ execute-aac-strategy --aac-root-namespace "BigBankPlc" --aac-output-path "Archit

draw-diagrams --aac-input-paths "C:\C4InterFlow\Samples\Internet Banking System\CSV\Architecture\Yaml" --aac-reader-strategy "C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation" --interfaces BigBankPlc.SoftwareSystems.*.Containers.*.Interfaces.* --business-processes BigBankPlc.BusinessProcesses.* --levels-of-details context container --output-dir "C:\C4InterFlow\Samples\Internet Banking System\CSV\Diagrams"

draw-diagrams --aac-input-paths "C:\C4InterFlow\Samples\E-Commerce Platform\Yaml\Architecture" --aac-reader-strategy "C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation" --interfaces ECommercePlatform.SoftwareSystems.*.Containers.*.Interfaces.* --output-dir "C:\C4InterFlow\Samples\E-Commerce Platform\Yaml\Diagrams"
draw-diagrams --aac-input-paths "C:\C4InterFlow\Samples\E-Commerce Platform\Yaml\Architecture" --aac-reader-strategy "C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation" --interfaces ECommercePlatform.SoftwareSystems.*.Interfaces.* ECommercePlatform.SoftwareSystems.*.Containers.*.Interfaces.* --levels-of-details context container --output-dir "C:\C4InterFlow\Samples\E-Commerce Platform\Yaml\Diagrams"
2 changes: 1 addition & 1 deletion C4InterFlow.Cli/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"C4InterFlow.Cli": {
"commandName": "Project",
"commandLineArgs": "draw-diagrams --aac-input-paths \"C:\\C4InterFlow\\Samples\\Internet Banking System\\CSV\\Architecture\\Yaml\" --aac-reader-strategy \"C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation\" --interfaces BigBankPlc.SoftwareSystems.*.Containers.*.Interfaces.* --business-processes BigBankPlc.BusinessProcesses.* --levels-of-details context container --output-dir \"C:\\C4InterFlow\\Samples\\Internet Banking System\\CSV\\Diagrams\"\r\n",
"commandLineArgs": "draw-diagrams --aac-input-paths \"C:\\C4InterFlow\\Samples\\E-Commerce Platform\\Yaml\\Architecture\" --aac-reader-strategy \"C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation\" --interfaces ECommercePlatform.SoftwareSystems.*.Interfaces.* ECommercePlatform.SoftwareSystems.*.Containers.*.Interfaces.* --levels-of-details context container --output-dir \"C:\\C4InterFlow\\Samples\\E-Commerce Platform\\Yaml\\Diagrams\"",
"workingDirectory": "C:\\C4InterFlow\\Samples\\Internet Banking System\\CSV"
}
}
Expand Down
4 changes: 2 additions & 2 deletions C4InterFlow/C4InterFlow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<Deterministic>true</Deterministic>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>0.37.0</Version>
<Version>0.38.0</Version>
</PropertyGroup>

<PropertyGroup>
<PackageId>C4InterFlow</PackageId>
<PackageVersion>0.37.0</PackageVersion>
<PackageVersion>0.38.0</PackageVersion>
<Authors>Slava Vedernikov</Authors>
<Description>Revolutionise your Application Architecture Documentation with C4InterFlow. Designed for Architects and Engineers, this tool leverages the widely-recognised C4 Model (Architecture Visualisation framework), enhanced with unique features like Interface and Flow, to describe your Application Architecture as Code. Experience an intuitive, efficient way to document complex systems, ensuring clarity and consistency across your teams and products.</Description>
<Copyright>Copyright 2024 Slava Vedernikov</Copyright>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ ECommercePlatform:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BasketService.Containers.Database.Interfaces.SelectItems
Expression: Database.Interfaces.SelectItems
AddItem:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BasketService.Containers.Database.Interfaces.InsertItem
Expression: Database.Interfaces.InsertItem
UpdateItem:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BasketService.Containers.Database.Interfaces.UpdateItem
Expression: Database.Interfaces.UpdateItem
DeleteItem:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BasketService.Containers.Database.Interfaces.DeleteItem
Expression: Database.Interfaces.DeleteItem
DeleteBasket:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BasketService.Containers.Database.Interfaces.DeleteBasket
Expression: Database.Interfaces.DeleteBasket
Database:
Interfaces:
InsertItem: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ ECommercePlatform:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Api.Interfaces.GetPurchaseOrders
Expression: BuyingService.Containers.Api.Interfaces.GetPurchaseOrders
CreatePurchaseOrder:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Api.Interfaces.CreatePurchaseOrder
Expression: BuyingService.Containers.Api.Interfaces.CreatePurchaseOrder
UpdatePurchaseOrder:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Api.Interfaces.UpdatePurchaseOrder
Expression: BuyingService.Containers.Api.Interfaces.UpdatePurchaseOrder
DeletePurchaseOrder:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Api.Interfaces.DeletePurchaseOrder
Expression: BuyingService.Containers.Api.Interfaces.DeletePurchaseOrder
ViewProductPrices:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.PricingService.Containers.Api.Interfaces.GetProductPrices
Expression: PricingService.Containers.Api.Interfaces.GetProductPrices
UpdateProductPrices:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.PricingService.Containers.Api.Interfaces.UpdateProductPrices
Expression: PricingService.Containers.Api.Interfaces.UpdateProductPrices
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ ECommercePlatform:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Database.Interfaces.SelectPurchaseOrder
Expression: Database.Interfaces.SelectPurchaseOrder
CreatePurchaseOrder:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Database.Interfaces.InsertPurchaseOrder
Expression: Database.Interfaces.InsertPurchaseOrder
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Messaging.Interfaces.SendPurchaseOrderCreatedEvent
Expression: Messaging.Interfaces.SendPurchaseOrderCreatedEvent
UpdatePurchaseOrder:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Database.Interfaces.UpdatePurchaseOrder
Expression: Database.Interfaces.UpdatePurchaseOrder
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Messaging.Interfaces.SendPurchaseOrderUpdatedEvent
Expression: Messaging.Interfaces.SendPurchaseOrderUpdatedEvent
DeletePurchaseOrder:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Database.Interfaces.DeletePurchaseOrder
Expression: Database.Interfaces.DeletePurchaseOrder
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Messaging.Interfaces.SendPurchaseOrderDeletedEvent
Expression: Messaging.Interfaces.SendPurchaseOrderDeletedEvent
Database:
Interfaces:
InsertPurchaseOrder: {}
Expand All @@ -50,20 +50,20 @@ ECommercePlatform:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Messaging.Interfaces.ReceivePurchaseOrderCreatedEvent
Expression: Messaging.Interfaces.ReceivePurchaseOrderCreatedEvent
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.WMS.Interfaces.CreatePurchaseOrder
Expression: WMS.Interfaces.CreatePurchaseOrder
HandlePurchaseOrderUpdatedEvent:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Messaging.Interfaces.ReceivePurchaseOrderUpdatedEvent
Expression: Messaging.Interfaces.ReceivePurchaseOrderUpdatedEvent
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.WMS.Interfaces.UpdatePurchaseOrder
Expression: WMS.Interfaces.UpdatePurchaseOrder
HandlePurchaseOrderDeletedEvent:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.BuyingService.Containers.Messaging.Interfaces.ReceivePurchaseOrderDeletedEvent
Expression: Messaging.Interfaces.ReceivePurchaseOrderDeletedEvent
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.WMS.Interfaces.DeletePurchaseOrder
Expression: WMS.Interfaces.DeletePurchaseOrder
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ ECommercePlatform:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FraudService.Containers.Api.Interfaces.GetHighRiskOrders
Expression: FraudService.Containers.Api.Interfaces.GetHighRiskOrders
UpdateOrderFraudCheckResult:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FraudService.Containers.Api.Interfaces.UpdateOrderFraudCheckResult
Expression: FraudService.Containers.Api.Interfaces.UpdateOrderFraudCheckResult
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ ECommercePlatform:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FraudService.Containers.Database.Interfaces.SelectHighRiskOrders
Expression: Database.Interfaces.SelectHighRiskOrders
UpdateOrderFraudCheckResult:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FraudService.Containers.Database.Interfaces.UpdateFraudCheckResult
Expression: Database.Interfaces.UpdateFraudCheckResult
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FraudService.Containers.Messaging.Interfaces.SendFraudCheckResultEvent
Expression: Messaging.Interfaces.SendFraudCheckResultEvent
Database:
Interfaces:
InsertOrder: {}
Expand All @@ -32,12 +32,12 @@ ECommercePlatform:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.OrderService.Containers.Messaging.Interfaces.ReceiveOrderCreatedEvent
Expression: OrderService.Containers.Messaging.Interfaces.ReceiveOrderCreatedEvent
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FraudService.Containers.Database.Interfaces.InsertOrder
Expression: Database.Interfaces.InsertOrder
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FraudEngine.Interfaces.GetFraudCheckResult
Expression: FraudEngine.Interfaces.GetFraudCheckResult
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FraudService.Containers.Database.Interfaces.InsertFraudCheckResult
Expression: Database.Interfaces.InsertFraudCheckResult
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FraudService.Containers.Messaging.Interfaces.SendFraudCheckResultEvent
Expression: Messaging.Interfaces.SendFraudCheckResultEvent
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ ECommercePlatform:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FulfilmentService.Containers.Database.Interfaces.UpdateOrderStatus
Expression: Database.Interfaces.UpdateOrderStatus
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FulfilmentService.Containers.Messaging.Interfaces.SendOrderShippedEvent
Expression: Messaging.Interfaces.SendOrderShippedEvent
Database:
Interfaces:
InsertOrder: {}
Expand All @@ -25,13 +25,13 @@ ECommercePlatform:
Flow:
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.OrderService.Containers.Messaging.Interfaces.ReceiveOrderStatusChangedEvent
Expression: OrderService.Containers.Messaging.Interfaces.ReceiveOrderStatusChangedEvent
- Type: If
Expression: Order Status is 'Pending Shipment'
Flows:
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FulfilmentService.Containers.Database.Interfaces.InsertOrder
Expression: Database.Interfaces.InsertOrder
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.WMS.Interfaces.ShipOrder
Expression: WMS.Interfaces.ShipOrder
- Type: Use
Expression: ECommercePlatform.SoftwareSystems.FulfilmentService.Containers.Database.Interfaces.UpdateOrderStatus
Expression: Database.Interfaces.UpdateOrderStatus
Loading

0 comments on commit fdf5e06

Please sign in to comment.