microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
d8982a75d68ff326c7355970158bdf91d6590eac

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

dotnet/autoShell/ActionSchemaFile.cs

49lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#nullable enable
5
6using System.Collections.Generic;
7using System.Text.Json.Serialization;
8
9namespace autoShell;
10
11/// <summary>
12/// Typed model for <c>.pas.json</c> schema files produced by the TypeAgent action schema compiler.
13/// Only the fields needed for action-name extraction and validation are modeled.
14/// </summary>
15internal record ActionSchemaFile(
16 [property: JsonPropertyName("version")] int Version,
17 [property: JsonPropertyName("types")] Dictionary<string, ActionSchemaType>? Types
18);
19
20/// <summary>
21/// A named type in the schema (e.g., <c>VolumeAction</c>, <c>DesktopActions</c>, <c>KnownPrograms</c>).
22/// </summary>
23internal record ActionSchemaType(
24 [property: JsonPropertyName("name")] string? Name,
25 [property: JsonPropertyName("type")] ActionSchemaTypeBody? Type
26);
27
28/// <summary>
29/// The body of a type definition. The <see cref="Kind"/> discriminator determines which
30/// fields are populated:
31/// <list type="bullet">
32/// <item><c>"object"</c> — <see cref="Fields"/> contains the property definitions.</item>
33/// <item><c>"string-union"</c> — <see cref="TypeEnum"/> contains the allowed string values.</item>
34/// <item><c>"type-union"</c> — references to other types (not modeled further).</item>
35/// </list>
36/// </summary>
37internal record ActionSchemaTypeBody(
38 [property: JsonPropertyName("type")] string? Kind,
39 [property: JsonPropertyName("fields")] Dictionary<string, ActionSchemaField>? Fields,
40 [property: JsonPropertyName("typeEnum")] string[]? TypeEnum
41);
42
43/// <summary>
44/// A field within an object type (e.g., <c>actionName</c>, <c>parameters</c>).
45/// </summary>
46internal record ActionSchemaField(
47 [property: JsonPropertyName("type")] ActionSchemaTypeBody? Type,
48 [property: JsonPropertyName("optional")] bool Optional
49);