Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PaYamlV3 schema and OM updates #713

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 43 additions & 59 deletions schemas/pa-yaml/v3.0/pa.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ properties:
$ref: "#/definitions/Screens-name-instance-map"
ComponentDefinitions:
$ref: "#/definitions/ComponentDefinitions-name-instance-map"
DataSources:
$ref: "#/definitions/DataSources-name-instance-map"

defaultSnippets:
- label: App
body:
Expand Down Expand Up @@ -56,9 +59,7 @@ definitions:
type: object
additionalProperties: false
properties:
CreationParameters: { $ref: "#/definitions/InstanceCreationParameters" }
Properties: { $ref: "#/definitions/Properties-formula-map" }
Groups: { $ref: "#/definitions/Groups-of-controls" }
Children: { $ref: "#/definitions/Children-Control-instance-sequence" }

Children-Control-instance-sequence:
Expand Down Expand Up @@ -170,6 +171,7 @@ definitions:
required: [Control]
properties:
Control: { $ref: "#/definitions/ControlTypeId" }
Group: { $ref: "#/definitions/Control-Group-name" }
Properties: { $ref: "#/definitions/Properties-formula-map" }
if:
required: [Control]
Expand All @@ -187,6 +189,7 @@ definitions:
Control: true
ComponentLibraryUniqueName: { $ref: "#/definitions/ComponentLibrary-unique-name" }
ComponentName: { $ref: "#/definitions/ComponentDefinition-name" }
Group: true
Properties: true
- if:
properties:
Expand All @@ -197,73 +200,26 @@ definitions:
properties:
Control: true
ComponentName: { $ref: "#/definitions/CodeComponent-name" }
Group: true
Properties: true
else:
additionalProperties: false
properties:
Control: true
CreationParameters: { $ref: "#/definitions/InstanceCreationParameters" }
Variant:
type: string
minLength: 1
Group: true
Properties: true
Groups: { $ref: "#/definitions/Groups-of-controls" }
Children: { $ref: "#/definitions/Children-Control-instance-sequence" }

InstanceCreationParameters:
description: A set of optional internal creation parameters coming from the Maker.
type: object
additionalProperties: false
properties:
Variant:
type: string
minLength: 1
Layout:
type: string
minLength: 1
ParentTemplate:
description: Metadata needed to identify the parent template that originally created this instance.
type: object
additionalProperties: false
properties:
CompositionName:
description: The name of the composition template that originally created this instance.
type: string
minLength: 1
Variant:
description: The variant of the parent template that originally created this instance.
type: string
minLength: 1
MetadataId:
type: string
minLength: 1
StyleName:
type: string
minLength: 1

Groups-of-controls:
Control-Group-name:
description: |-
A mapping of groups of controls under this container. The keys of this object represent the name of the Group.
The name of the group of controls to associate this control with.

Groups do not impact the behavior of an app, but are used in the Studio to organize controls when editing.
type: object
propertyNames: { $ref: "#/definitions/Control-instance-name" }
additionalProperties:
type: object
required: [ControlNames]
additionalProperties: false
properties:
ControlNames:
description: |-
An array of the names of controls that are part of this group.
A group must have at least two (2) controls in it.
type: array
minItems: 2
items: { $ref: "#/definitions/Control-instance-name" }
defaultSnippets:
- label: Add Group
body:
${1:Group1}:
ControlNames:
- ${2:ControlName1}
- ${3:ControlName2}
allOf:
- { $ref: "#/definitions/Control-instance-name" }

CodeComponent-name:
description: |-
Expand Down Expand Up @@ -306,7 +262,6 @@ definitions:
- Height
- Width
- OnReset
Groups: { $ref: "#/definitions/Groups-of-controls" }
Children: { $ref: "#/definitions/Children-Control-instance-sequence" }

ComponentDefinition-name:
Expand Down Expand Up @@ -436,6 +391,35 @@ definitions:
pattern: |-
[.\\/:*?"<>|]


DataSources-name-instance-map:
type: object
propertyNames: { $ref: "#/definitions/DataSource-name" }
additionalProperties:
$ref: "#/definitions/DataSource-instance"

DataSource-name:
$ref: "#/definitions/entity-name"

DataSource-Type:
enum:
- DataverseTable

DataSource-instance:
type: object
required: [Type]
properties:
Type: { $ref: "#/definitions/DataSource-Type" }
oneOf:
- required: [Type]
additionalProperties: false
properties:
Type:
const: DataverseTable
TableLogicalName:
type: string
minLength: 1

Properties-formula-map:
description: >-
A map of property names to formulas.
Expand Down
12 changes: 0 additions & 12 deletions src/PAModel/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
"version": 1,
"dependencies": {
".NETStandard,Version=v2.0": {
"Microsoft.Net.Compilers.Toolset.Framework": {
"type": "Direct",
"requested": "[4.10.0-3.24216.12, )",
"resolved": "4.10.0-3.24216.12",
"contentHash": "Y1T1ZN3cHWToRYZHhRs8xby1tMCkF23Jb//zK+Tdf4ourzwbMQ4GiTRVVFAlWvmA10iVNUyCZucAeLt5XeiDqA=="
},
"NETStandard.Library": {
"type": "Direct",
"requested": "[2.0.3, )",
Expand Down Expand Up @@ -103,12 +97,6 @@
}
},
"net8.0": {
"Microsoft.Net.Compilers.Toolset.Framework": {
"type": "Direct",
"requested": "[4.10.0-3.24216.12, )",
"resolved": "4.10.0-3.24216.12",
"contentHash": "Y1T1ZN3cHWToRYZHhRs8xby1tMCkF23Jb//zK+Tdf4ourzwbMQ4GiTRVVFAlWvmA10iVNUyCZucAeLt5XeiDqA=="
},
"Newtonsoft.Json": {
"type": "Direct",
"requested": "[13.0.1, )",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,29 @@ public void DeserializeExamplePaYamlScreen(string path, int expectedScreenProper
if (expectedScreenChildrenCount == 0)
screen.Children.Should().BeNull();
else
{
screen.Children.Should().HaveCount(expectedScreenChildrenCount);
GetGroupCount(screen).Should().Be(expectedScreenGroupsCount);
}

if (expectedDescendantsCount == 0)
screen.Properties.Should().BeNull();
else
screen.DescendantControlInstances().Should().HaveCount(expectedDescendantsCount);

if (expectedScreenGroupsCount == 0)
screen.Properties.Should().BeNull();
else
screen.Groups.Should().HaveCount(expectedScreenGroupsCount);
screen.DescendantControlInstances().SelectMany(nc => nc.Value.Groups ?? []).Should().HaveCount(expectedTotalGroupsCount - expectedScreenGroupsCount);
screen.DescendantControlInstances().Sum(nc => GetGroupCount(nc.Value)).Should().Be(expectedTotalGroupsCount - expectedScreenGroupsCount);

static int GetGroupCount(IPaControlInstanceContainer container)
{
if (container.Children is null)
return 0;

return container.Children
.Select(c => c.Value.GroupName)
.Where(g => g != null)
.Distinct()
.Count();
}
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public record ComponentDefinition : IPaControlInstanceContainer

public NamedObjectMapping<PFxExpressionYaml>? Properties { get; init; }

public NamedObjectMapping<ControlGroup>? Groups { get; init; }

public NamedObjectSequence<ControlInstance>? Children { get; init; }
}

Expand Down
12 changes: 0 additions & 12 deletions src/Persistence/PaYaml/Models/SchemaV3/ControlGroup.cs

This file was deleted.

11 changes: 8 additions & 3 deletions src/Persistence/PaYaml/Models/SchemaV3/ControlInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ public ControlInstance(string controlTypeId)
[property: YamlMember(Alias = "Control")]
public required string ControlTypeId { get; init; }

public string? Variant { get; init; }

public string? ComponentName { get; init; }

public string? ComponentLibraryUniqueName { get; init; }

public InstanceCreationParameters? CreationParameters { get; init; }
/// <summary>
/// The name of the group of controls that this control should be grouped with.
/// This does not impact the visual layout of the control or behavior, but is used to group controls together for organizational purposes from within the Studio.
/// </summary>
[property: YamlMember(Alias = "Group")]
public string? GroupName { get; init; }

public NamedObjectMapping<PFxExpressionYaml>? Properties { get; init; }

public NamedObjectMapping<ControlGroup>? Groups { get; init; }

public NamedObjectSequence<ControlInstance>? Children { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3;

public interface IPaControlInstanceContainer
{
NamedObjectMapping<ControlGroup>? Groups { get; }
NamedObjectSequence<ControlInstance>? Children { get; }
}

This file was deleted.

4 changes: 0 additions & 4 deletions src/Persistence/PaYaml/Models/SchemaV3/ScreenInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3;

public record ScreenInstance : IPaControlInstanceContainer
{
public InstanceCreationParameters? CreationParameters { get; init; }

public NamedObjectMapping<PFxExpressionYaml>? Properties { get; init; }

public NamedObjectMapping<ControlGroup>? Groups { get; init; }

public NamedObjectSequence<ControlInstance>? Children { get; init; }
}
Loading
Loading