Skip to content

Commit

Permalink
V3 YAML schema for Data Sources (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamevaalet authored Sep 4, 2024
1 parent 2e59eee commit 1349006
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ public void DeserializeExamplePaYamlApp(string path, int expectedAppPropertiesCo
paFileRoot.App.Should().NotDefineMember("Children", "App.Children is still under design review");
}

[TestMethod]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/DataSources/DataSources1.pa.yaml")]
public void DeserializeExamplePaYamlDataSources(string path)
{
var paFileRoot = PaYamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
paFileRoot.ShouldNotBeNull();

// Top level properties
paFileRoot.DataSources.ShouldNotBeNull();
paFileRoot.App.Should().BeNull();
paFileRoot.ComponentDefinitions.Should().BeNullOrEmpty();
paFileRoot.Screens.Should().BeNullOrEmpty();

paFileRoot.DataSources.Should().HaveCount(3);
}

[TestMethod]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Screens/Screen1.pa.yaml", 2, 8, 14, 2, 3)]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Screens/FormsScreen2.pa.yaml", 0, 1, 62, 0, 0)]
Expand Down Expand Up @@ -140,6 +156,7 @@ public void DeserializeExamplePaYamlSingleFileApp()
[DataRow(@"_TestData/SchemaV3_0/FullSchemaUses/App.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/FullSchemaUses/Screens-general-controls.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/FullSchemaUses/Screens-with-components.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/DataSources/DataSources1.pa.yaml")]
public void RoundTripFromYaml(string path)
{
var originalYaml = File.ReadAllText(path);
Expand Down
18 changes: 18 additions & 0 deletions src/Persistence/PaYaml/Models/SchemaV3/DataSourceInstance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using YamlDotNet.Serialization;

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3;

public enum DataSourceInstanceType
{
DataverseTable,
}

public record DataSourceInstance
{
[YamlMember(DefaultValuesHandling = DefaultValuesHandling.Preserve)]
public required DataSourceInstanceType Type { get; init; }
public string? TableLogicalName { get; init; }
}
1 change: 1 addition & 0 deletions src/Persistence/PaYaml/Models/SchemaV3/PaModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public record PaModule
public AppInstance? App { get; init; }
public NamedObjectMapping<ComponentDefinition> ComponentDefinitions { get; init; } = new();
public NamedObjectMapping<ScreenInstance> Screens { get; init; } = new();
public NamedObjectMapping<DataSourceInstance> DataSources { get; init; } = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DataSources:
Accounts:
Type: DataverseTable
TableLogicalName: account
Contacts:
Type: DataverseTable
TableLogicalName: contact
Users:
Type: DataverseTable
TableLogicalName: systemuser

0 comments on commit 1349006

Please sign in to comment.