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