SessionZero-Client/.hidden/src/SessionZero.Shared/Schema/Schema.cs

120 lines
3.1 KiB
C#

namespace SessionZero.Shared.Schema;
/// <summary>
/// Valid types for fields.
/// </summary>
public enum FieldType
{
Text,
MultiText,
Number,
Boolean,
Formula,
List
}
/// <summary>
/// Represents a list of allowed values for a field with type List.
/// </summary>
public class SzListType
{
// NOTE: Only one of these lists should be allowed
public List<string>? AllowedDatasetTypes { get; set; }
public List<DatasetLink>? AllowedDatasetIds { get; set; }
public string? CustomValues { get; set; }
}
/// <summary>
/// Represents a formula field.
/// </summary>
public class SzFormulaType
{
// TODO: Implement a way to parse formulas
public string? Formula { get; set; }
}
/// <summary>
/// Used to link a dataset in other data or template objects.
/// </summary>
public class DatasetLink
{
public required Guid DatapackId { get; set; }
public required string DatasetId { get; set; }
public required string Version { get; set; }
}
/// <summary>
/// Used to link a character template in other template objects.
/// </summary>
public class CharacterTemplateLink
{
public required Guid DatapackId { get; set; }
public required string TemplateId { get; set; }
public required string Version { get; set; }
}
/// <summary>
/// Represents a field value.
/// </summary>
public class FieldValue
{
public required FieldType Type { get; set; }
public required object Value { get; set; }
}
/// <summary>
/// Represents a group of fields in a dataset.
/// </summary>
public class DataGroup
{
public required string Id { get; set; }
public required string Name { get; set; }
public required Dictionary<string, FieldValue> Fields { get; set; } = new();
}
/// <summary>
/// Represents a dataset entry used in datasets.
/// </summary>
public class DatasetEntry
{
public required string Id { get; set; }
public required string Name { get; set; }
public string Description { get; set; } = string.Empty;
public string Icon { get; set; } = string.Empty;
public Dictionary<string, FieldValue>? TopLevelFields { get; set; } = new();
public List<DataGroup>? Groups { get; set; } = new();
}
/// <summary>
/// Represents a section in a template that houses multiple groups.
/// </summary>
public class TemplateSection
{
public required string Id { get; set; }
public required string Name { get; set; }
public required List<TemplateGroup> Groups { get; set; } = new();
}
/// <summary>
/// Represents a group of fields in a template.
/// </summary>
public class TemplateGroup
{
public required string Id { get; set; }
public required string Name { get; set; }
public required List<TemplateFieldDefinition>? Fields { get; set; } = new();
}
/// <summary>
/// Represents a field definition in a template
/// (Does not hold actual field values as templates are meant to be filled in upon instance creation).
/// </summary>
public class TemplateFieldDefinition
{
public required string Id { get; set; }
public required string Name { get; set; }
public required FieldType Type { get; set; }
public object? DefaultValue { get; set; }
public DatasetLink? DatasetLink { get; set; }
}